Can't compile app with mix phx.server: (ArgumentError) argument error

I can’t compile phoenix app after delete _build folder (OS Win 11). The same error is always given, in the same place:

mix phx.server
==> file_system
Compiling 7 files (.ex)
Generated file_system app
==> decimal
Compiling 4 files (.ex)
Generated decimal app
==> mime
Compiling 1 file (.ex)
Generated mime app
==> nimble_options
Compiling 3 files (.ex)
Generated nimble_options app
==> bunt
Compiling 2 files (.ex)
Generated bunt app
** (ArgumentError) argument error
    (stdlib 5.0.2) io.erl:99: :io.put_chars(:standard_io, <<210, 229, 234, 243, 249, 224, 255, 32, 234, 238, 228, 238, 226, 224, 255, 32, 241, 242, 240, 224, 237, 232, 246, 224, 58, 32, 49, 50, 53, 49, 13, 10>>)
    (elixir 1.15.6) lib/system.ex:1121: System.do_port_byte/3
    (elixir 1.15.6) lib/system.ex:1107: System.do_cmd/3
    (mix 1.15.6) lib/mix/shell.ex:128: Mix.Shell.cmd/3
    (mix 1.15.6) lib/mix/tasks/deps.compile.ex:300: Mix.Tasks.Deps.Compile.do_command/5
    (mix 1.15.6) lib/mix/tasks/deps.compile.ex:211: Mix.Tasks.Deps.Compile.do_rebar3/2
    (mix 1.15.6) lib/mix/tasks/deps.compile.ex:93: anonymous fn/4 in Mix.Tasks.Deps.Compile.compile/2
    (elixir 1.15.6) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2

Valeriy!

I’ve just created an app to reproduce the error you are mentioning. I was indeed able to run mix phx.server with no problem at all, even after removing the _build folder with rm -rf _build within the app directory. The files were recompiled and placed again the aforementioned folder. I am on Elixir 1.15.


Caleb

What version of Erlang are you on?

elixir -v
Erlang/OTP 26 [erts-14.0.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Elixir 1.15.6 (compiled with Erlang/OTP 26)

mix phx.new --version
Phoenix installer v1.7.2

I try to reinstall Erlang/Elixir on my work machine but it didn’t help (i get the same error).

I tried to compile the project on another machine and it compiled successfully. In order to continue working, I copied the _build folder from this computer to my work computer. When I modify the project files it recompiles successfully.
But compiling from clear list on my computer doesn’t work (i get the same error).

I tried this:

iex(1)> bin = <<210, 229, 234, 243, 249, 224, 255, 32, 234, 238, 228, 238, 226, 224, 255, 32, 241, 242, 240, 224, 237, 232, 246, 224, 58, 32, 49, 50, 53, 49, 13, 10>>
<<210, 229, 234, 243, 249, 224, 255, 32, 234, 238, 228, 238, 226, 224, 255, 32,
  241, 242, 240, 224, 237, 232, 246, 224, 58, 32, 49, 50, 53, 49, 13, 10>>
iex(2)> IO.puts(bin)
** (ArgumentError) argument error
    (stdlib 5.1.1) io.erl:103: :io.put_chars(:standard_io, [<<210, 229, 234, 243, 249, 224, 255, 32, 234, 238, 228, 238, 226, 224, 255, 32, 241, 242, 240, 224, 237, 232, 246, 224, 58, 32, 49, 50, 53, 49, 13, 10>>, 10])
    iex:1: (file)

and got the same error, which means that binary is not a valid (or printable) UTF-8 string:

iex(3)> String.valid?(bin)
false
iex(4)> String.printable?(bin)
false

So maybe you have something that tries to print stuff in your deps? Try and search for this binary, or fragments of it inside your codebase or the deps?

OK, at least I know what the string says.

First of all, it’s not UTF-8. It’s CP-1251, very normal for us the Slavs:

iex(1)> :erlyconv.to_unicode(:cp1251, bin)
"Текущая кодовая страница: 1251\r\n"

You’ll need to put that in your mix.exs if you want to play with it:

{:erlyconv, github: "eugenehr/erlyconv"}

So do with that info what you will. But you got a Russian text somewhere that’s not properly encoded.

1 Like

Thank you dimitarvp!
It was a ‘chcp1251’ auto command on startup powershell. I deleted it and everything is working well now.

1 Like

Cool! Glad you fixed your problem.

Mark accepted answers if you don’t mind – helps the forum search function surface such answers to other people in the future.