Skip to content

Mix.cmd sometimes crashes with error in encoding on Windows 11 #14026

Closed
@clemensm

Description

@clemensm

Elixir and Erlang/OTP versions

Erlang/OTP 25 [erts-13.0.4] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1]

Elixir 1.17.3 (compiled with Erlang/OTP 25)

Operating system

windows 11 home

Current behavior

Hi all

We've got a Phoenix project where in the mix assets.deploy phase we copy a couple of files in the windows build using basically this line:

"cmd robocopy a b /MIR"

This is working fine when being executed manually (i.e. we've got a build.bat script), i.e. logged into the machine, running a cmd session, running the bat file. However if we execute this via Jenkins, where the same computer that we've used manually is running as a Jenkins slave, this will fail with an error:

** (ArgumentError) argument error
(stdlib 5.2.3.2) io.erl:103: :io.put_chars(:standard_io, <<32, 32, 32, 82, 79, 66, 79, 67, 79, 80, 89, 32, 32, 32, 32, 32, 58, 58, 32, 32, 32, 32, 32, 82, 111, 98, 117, 115, 116, 101, 115, 32, 68, 97, 116, 101, 105, 107, 111, 112, 105, 101, 114, 101, 110, 32, 102, 129, 114, 32, ...>>)
(elixir 1.17.3) lib/system.ex:1145: System.do_port_byte/3
(elixir 1.17.3) lib/system.ex:1131: System.do_cmd/3
(mix 1.17.3) lib/mix/shell.ex:132: Mix.Shell.cmd/3
(mix 1.17.3) lib/mix/tasks/cmd.ex:72: Mix.Tasks.Cmd.run/1
(mix 1.17.3) lib/mix/task.ex:495: anonymous fn/3 in Mix.Task.run_task/5
(mix 1.17.3) lib/mix/task.ex:561: Mix.Task.run_alias/6
(mix 1.17.3) lib/mix/cli.ex:96: Mix.CLI.run_task/2

After trying around a bit I stumbled upon this, which has the same error when compiling argon2_elixir (which was happening with us as well, but an update of elixir_make solved the issue):

#13637

Trying out that fix suggested by @josevalim by modifying the line mix.exs solved this problem:

"cmd cscp 65001 & robocopy a b /MIR"

So I assume that in mix there is a very similar line somewhere?

Sadly it's hard to reproduce, since you need to setup a Jenkins master server, and a Jenkins slave as well to trigger this, so I hope this information is enough to find the issue...

Happy to help if you need more info!

Expected behavior

The line should be executed without an error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions