elixir-lang/elixir

Mix cmd regression

Closed this issue · 2 comments

Elixir and Erlang/OTP versions

Erlang/OTP 28 [erts-16.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit:ns]

Elixir 1.19.0-rc.0 (compiled with Erlang/OTP 28)

Operating system

Ubuntu 22.04

Current behavior

According to Mix documentation, it should be possible run a relative script with mix cmd, for example mix cmd priv/world.sh in an alias. See:

elixir/lib/mix/lib/mix.ex

Lines 273 to 291 in f089571

Another use case of aliases is to run Elixir scripts and shell
commands, for example:
# priv/hello1.exs
IO.puts("Hello One")
# priv/hello2.exs
IO.puts("Hello Two")
# priv/world.sh
#!/bin/sh
echo "world!"
# mix.exs
defp aliases do
[
some_alias: ["hex.info", "run priv/hello1.exs", "cmd priv/world.sh"]
]
end

We use this in some of our repositories in aliases, and the fix is simple enough for that use case
"cmd #{Path.absname("./priv/world.sh")}"

Expected behavior

I would expect mix cmd to be able to run relative scripts in line with the documentation.

If this is not to be fixed, I would expect the documentation to be updated and for this to be logged as a deprecation in the 1.19 release changelog.

I am quite certain this was introduced by #13751 even though I have not confirmed it, but I can see in the System.cmd code that relative paths are not allowed which throws the enoent error that I am seeing.

The PR you linked changes only Rebar, But I have identified the root cause and submitted a PR. Thanks for the report.

Thanks for the quick triage!

I don't think the PR I linked only changes Rebar. It makes changes to Mix.Shell.cmd, swapping System.shell for System.cmd, which behave differently and potentially affecting everything that calls Mix.shell().cmd(). Or am I misunderstanding?

https://github.com/elixir-lang/elixir/pull/13751/files#diff-eebd051a7df756d115cbc7a76ef43ef6a461182c0485dfeda426ff7bb79bd16eR134-R139

Edit: Ok nevermind, I see what you mean. Accepting the tuple form was added in that PR, and another one then uses that one for the mix cmd.