:env option in 1.18.8
harmon25 opened this issue · 2 comments
Since upgrading from 1.17 -> 1.18 have noticed what might be a regression - or maybe I am doing something wrong, and a fix in 1.18 has surfaced this miss use.
EDIT:
So I just tested this:
:exec.run_link("env", [stdout: "/tmp/output", stderr: "/tmp/errout", env: [{"TEST", "helloo"}]])
The output looks like this:
SHELL=SHELL=/bin/bash
COLORTERM=COLORTERM=truecolor
LIBGL_ALWAYS_INDIRECT=LIBGL_ALWAYS_INDIRECT=1
USES_VSCODE_SERVER_SPAWN=USES_VSCODE_SERVER_SPAWN=true
TERM_PROGRAM_VERSION=TERM_PROGRAM_VERSION=1.52.1
WSL_DISTRO_NAME=WSL_DISTRO_NAME=Ubuntu-20.04
ROOTDIR=ROOTDIR=/home/doug/.asdf/installs/erlang/23.1.5
TEST=helloo
...
My injected variable TEST
looks OK - but the others have all been broken.
I am trying to launch a nodejs script via :exec:run_link/2
.
I have nodejs installed via ASDF, running node
in bash works fine.
In 1.17.6, the following works as expected, node is launched with the script, and environment variables are merged
script = "#{File.cwd!}/priv/script.js" # path to a js script file
opts = [stdout: "/tmp/output", stderr: "/tmp/errout", env: [{"TEST", "some_env_var"}]]
:exec.run_link("node #{script}", opts)
When attempting the same in the most recent 1.18.8 release, the following is logged to the stderr out file,
Unknown command: `asdf exec node /home/doug/projects/exec_test/priv/test.js`
/home/doug/.asdf/bin/asdf: line 82: ASDF_DIR=/home/doug/.asdf/lib/commands/command-help.bash: No such file or directory
The above ASDF_DIR
file does in fact exist...
and I get the following error in IEX ** (EXIT from #PID<0.225.0>) shell process exited with reason: {:exit_status, 32512}
as can be gleaned the stderr log, the shell command did not execute properly
I have a hunch this has something to with environment variables. If I remove the the :env option, the following works in 1.18.8.
script = "#{File.cwd!}/priv/script.js" # path to a js script file
opts = [stdout: "/tmp/output", stderr: "/tmp/errout"]
:exec.run_link("node #{script}", opts)
I tried setting the SHELL
environment variable, but it seems that has the same result - as the environment variables, even without the :clear
option seem to be getting cleared?
Instead of the :env option, running the following works, and might suffice as a temporary workaround
:exec.run_link("TEST=some_env_var node #{script}", opts)
I am running Ubuntu 20.04 in WSL2, Erlang 23.1.5 and Elixir 1.11.2-otp-23.
Let me know if you need any more information.
Thanks for the help!
I believe it's fixed in the latest master branch.
Thanks for the quick fix, it is working on master!