Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unicode symbols misprinted in compiler messages on mix cmd mix compile #14253

Closed
RaymondLoranger opened this issue Feb 5, 2025 · 6 comments
Closed

Comments

@RaymondLoranger
Copy link

Elixir and Erlang/OTP versions

Instead of printing vertical and horizontal bars, I get â characters as shown in the attached.
I get this incorrect behavior with v1.18.2 but all was fine in v1.17.3 as shown in the attached.

Operating system

Windows 10

Current behavior

v1.18.2.docx

Expected behavior

v1.17.3.docx

@josevalim
Copy link
Member

Thank you for the report! Can you try running this:

mix cmd  erl -eval 'io:put_chars("└─"), halt().'
mix cmd  erl -eval 'io:put_chars(standard_error, "└─"), halt().'

And let me know what it returns? There is no need to paste a screenshot, you should be able to copy and paste the contents here. :)

@RaymondLoranger
Copy link
Author

Both commands return an error as shown here... I am attaching the 2nd crash dump just in case you need it.

erl_crash.dump.dmp

mix cmd  erl -eval 'io:put_chars("└─"), halt().'
Erlang/OTP 27 [erts-15.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Error! Failed to eval: io:put_chars(âÂÂâÂÂ),halt().

Runtime terminating during boot ({{not_character,<<105,111,58,112,117,116,95,99,104,97,114,115,40,226,148,148,226,148,128,41,44>>},[{erl_scan,scan1,5,[{file,"erl_scan.erl"},{line,592}]},{erl_scan,string1,5,[{file,"erl_scan.erl"},{line,537}]},{init,start_it,1,[{file,"init.erl"},{line,1530}]},{init,start_em,1,[{file,"init.erl"},{line,1521}]},{init,do_boot,3,[{file,"init.erl"},{line,1210}]}]})

Crash dump is being written to: erl_crash.dump...done
** (exit) 1
    (mix 1.18.2) lib/mix/tasks/cmd.ex:74: Mix.Tasks.Cmd.run/1
    (mix 1.18.2) lib/mix/task.ex:495: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.18.2) lib/mix/cli.ex:107: Mix.CLI.run_task/2
    c:/Program Files/Elixir/bin/mix:2: (file)
mix cmd  erl -eval 'io:put_chars(standard_error, "└─"), halt().'
Erlang/OTP 27 [erts-15.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Error! Failed to eval: io:put_chars(standard_error,âÂÂâÂÂ),halt().

Runtime terminating during boot ({{not_character,<<"io:put_chars(standard_error,">>},[{erl_scan,scan1,5,[{file,"erl_scan.erl"},{line,592}]},{erl_scan,string1,5,[{file,"erl_scan.erl"},{line,537}]},{init,start_it,1,[{file,"init.erl"},{line,1530}]},{init,start_em,1,[{file,"init.erl"},{line,1521}]},{init,do_boot,3,[{file,"init.erl"},{line,1210}]}]})

Crash dump is being written to: erl_crash.dump...done
** (exit) 1
    (mix 1.18.2) lib/mix/tasks/cmd.ex:74: Mix.Tasks.Cmd.run/1
    (mix 1.18.2) lib/mix/task.ex:495: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.18.2) lib/mix/cli.ex:107: Mix.CLI.run_task/2
    c:/Program Files/Elixir/bin/mix:2: (file)

@josevalim
Copy link
Member

Please try these steps then. Create a file named foo.erl with the following contents:

-module(foo).
-compile(export_all).

stdout() ->
  io:put_chars("└─"), halt().

stderr() ->
  io:put_chars(standard_error, "└─"), halt().

And then run these commands:

$ erlc foo.erl
$ erl -s foo stdout
$ erl -s foo stderr
$ mix cmd erl -s foo stdout
$ mix cmd erl -s foo stderr

And let me know what each of them returns! Thank you!

@RaymondLoranger
Copy link
Author

Here is what happened:

erlc foo.erl
foo.erl:2:2: Warning: export_all flag enabled - all functions will be exported
%    2| -compile(export_all).
%     |  ^
erl -s foo stdout
Erlang/OTP 27 [erts-15.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

└─
mix cmd erl -s foo stdout
Erlang/OTP 27 [erts-15.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

ââ
mix cmd erl -s foo stderr
Erlang/OTP 27 [erts-15.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

ââ

@josevalim
Copy link
Member

Thank you. Let's continue digging, can you please try this? Write the following to foo.erl:

-module(foo).
-compile(export_all).

stdout() ->
  io:put_chars("└─"), halt().

stderr() ->
  io:put_chars(standard_error, "└─"), halt().

run([Device]) ->
  ok = io:setopts(standard_io, [binary]),
  Port = open_port({spawn, "erl -noshell -s foo " ++ atom_to_list(Device)},
                    [binary, use_stdio, stderr_to_stdout, exit_status]),
  handle_port_output(Port),
  halt().

handle_port_output(Port) ->
  receive
    {Port, {data, Data}} ->
      io:format("1: ~s", [Data]),
      io:format("2: ~ts", [Data]),
      io:put_chars("3: "),
      io:put_chars(Data),
      file:write(standard_io, "4: "),
      file:write(standard_io, Data),
      handle_port_output(Port);
    {Port, {exit_status, Status}} ->
      Status
  end.

And then run these commands:

erlc foo.erl
erl -s foo run stdout
erl -s foo run stderr

The above should tell us if we can fully reproduce the problem only with Erlang and if there is a viable solution.

@RaymondLoranger
Copy link
Author

Here are the results:

erlc foo.erl
foo.erl:2:2: Warning: export_all flag enabled - all functions will be exported
%    2| -compile(export_all).
%     |  ^
erl -s foo run stdout
Erlang/OTP 27 [erts-15.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Eshell V15.1 (press Ctrl+G to abort, type help(). for help)
1: ââ2: └─3: └─4: ââ1>
erl -s foo run stderr
Erlang/OTP 27 [erts-15.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Eshell V15.1 (press Ctrl+G to abort, type help(). for help)
1: ââ2: └─3: └─4: ââ1>

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

2 participants