I'm trying to get the ExUnit configuration working, but keep getting the following when running it
Could not find Hex, which is needed to build dependency :phoenix
I've tried to run an external tool that does the following before running the tests, to no avail
mix local.hex --force
Ideas?
Did you setup the project using the Import project from external model steps or open it as a simple directory? Opening as a simple directory will often leave the mix path messed up.
I tried both and still got the same result. In the former I even specified an absolute path to mix.
OS
Mac OS 10.12.6
How you installed Elixir
asdf (https://github.com/asdf-vm/asdf-elixir)
How you installed Erlang
asdf (https://github.com/asdf-vm/asdf-erlang)
How you configured the SDK
By manually setting the path to ~/.asdf/installs/elixir/1.5.1.
It could be because of asdf. I don't support it explicitly right now (see #308), so it may be that setting the path manually isn't enough to make it work.
That's unfortunate but understandable. I'm guessing this works if Elixir and Erlang are installed via Homebrew?
On Mac there's currently support for Homebrew and Nix: https://github.com/KronicDeth/intellij-elixir/blob/72ba8fab11e905ba53bc97993dcf3a5e60772fad/src/org/elixir_lang/sdk/ElixirSdkType.java#L395-L398
You could also try launching IntelliJ from a terminal where you have the asdf Elixir and Erlang activated, so that the asdf settings are in your environment variables. IntelliJ launched from a terminal (as long as it's not already running) will inherit the environment variables, but it won't when launched from Spotlight, Launchbar or the Applications folder.
You could also try launching IntelliJ from a terminal where you have the asdf Elixir and Erlang activated
Yeah I've tried that but still no dice. I might take a crack at adding asdf support when I get a chance.
Thanks for an awesome plugin!
[This is slightly long but I found a workaround at the end there]
Adding a few notes here as I'm seeing the same behavior trying to launch ExUnit.
I've installed elixir via brew install asdf && asdf install elixir 1.5.3 && asdf elixir global 1.5.3 (plus erlang 20.1 the same way) and then set up my SDK in IntelliJ as /usr/local/opt/asdf/installs/elixir/1.5.3. Most things are working really well (code completion, navigation, etc).
The line in the repl I'm seeing is:
/usr/local/Cellar/asdf/0.4.0/installs/erlang/20.1/bin/erl -pa /usr/local/Cellar/asdf/0.4.0/installs/elixir/1.5.3/lib/logger/ebin -pa /usr/local/Cellar/asdf/0.4.0/installs/elixir/1.5.3/lib/elixir/ebin -pa /usr/local/Cellar/asdf/0.4.0/installs/elixir/1.5.3/lib/ex_unit/ebin -pa /usr/local/Cellar/asdf/0.4.0/installs/elixir/1.5.3/lib/mix/ebin -pa /usr/local/Cellar/asdf/0.4.0/installs/elixir/1.5.3/lib/eex/ebin -pa /usr/local/Cellar/asdf/0.4.0/installs/elixir/1.5.3/lib/iex/ebin -noshell -s elixir start_cli -extra /usr/local/opt/asdf/installs/elixir/1.5.3/bin/mix
Executing the above from the command-line followed by hex gives me:
** (Mix) The task "hex" could not be found
But if I just run mix from the elixir dir directly via /usr/local/opt/asdf/installs/elixir/1.5.3/bin/mix hex I see the expected output:
% /usr/local/opt/asdf/installs/elixir/1.5.3/bin/mix hex
Hex v0.17.1
Hex is a package manager for the Erlang ecosystem.
[...]
I can reproduce the REPL behavior by running $(asdf where elixir 1.5.3)/bin/elixir -S mix hex. Therefore it seems as though there's something in the asdf startup scripts which is setting up some variables that aren't in the vanilla script. Poking around, I found that I can get the proper CLI setup to find hex via /usr/local/opt/asdf/libexec/private/asdf-exec elixir bin/elixir -S mix hex.
Looking at that script and running it via sh -x, it looks like the relevant things it does are setting these two environment variables:
export MIX_ARCHIVES=/usr/local/opt/asdf/installs/elixir/1.5.3/.mix/archives
export MIX_HOME=/usr/local/opt/asdf/installs/elixir/1.5.3/.mix
When I I added those two environment variables to my build configuration (Run/Debug configurations / Environment variables), I was able to get the ExUnit tests to launch successfully. 馃帀
ASDF support was added ing #1037
@timgilbert Thank you, this workaround helped me with running tests using asdf on Ubuntu.
I still have the same problem when trying to run the debugger with the ExUnit configuration:
Could not find Hex, which is needed to build dependency :httpoison
I can run the tests in debug mode once I make these environment variables availible any other way (system-wide, or by defining them when running IntelliJ from the terminal)
Most helpful comment
[This is slightly long but I found a workaround at the end there]
Adding a few notes here as I'm seeing the same behavior trying to launch ExUnit.
I've installed elixir via
brew install asdf && asdf install elixir 1.5.3 && asdf elixir global 1.5.3(plus erlang 20.1 the same way) and then set up my SDK in IntelliJ as/usr/local/opt/asdf/installs/elixir/1.5.3. Most things are working really well (code completion, navigation, etc).The line in the repl I'm seeing is:
/usr/local/Cellar/asdf/0.4.0/installs/erlang/20.1/bin/erl -pa /usr/local/Cellar/asdf/0.4.0/installs/elixir/1.5.3/lib/logger/ebin -pa /usr/local/Cellar/asdf/0.4.0/installs/elixir/1.5.3/lib/elixir/ebin -pa /usr/local/Cellar/asdf/0.4.0/installs/elixir/1.5.3/lib/ex_unit/ebin -pa /usr/local/Cellar/asdf/0.4.0/installs/elixir/1.5.3/lib/mix/ebin -pa /usr/local/Cellar/asdf/0.4.0/installs/elixir/1.5.3/lib/eex/ebin -pa /usr/local/Cellar/asdf/0.4.0/installs/elixir/1.5.3/lib/iex/ebin -noshell -s elixir start_cli -extra /usr/local/opt/asdf/installs/elixir/1.5.3/bin/mixExecuting the above from the command-line followed by
hexgives me:But if I just run
mixfrom the elixir dir directly via/usr/local/opt/asdf/installs/elixir/1.5.3/bin/mix hexI see the expected output:I can reproduce the REPL behavior by running
$(asdf where elixir 1.5.3)/bin/elixir -S mix hex. Therefore it seems as though there's something in the asdf startup scripts which is setting up some variables that aren't in the vanilla script. Poking around, I found that I can get the proper CLI setup to find hex via/usr/local/opt/asdf/libexec/private/asdf-exec elixir bin/elixir -S mix hex.Looking at that script and running it via
sh -x, it looks like the relevant things it does are setting these two environment variables:When I I added those two environment variables to my build configuration (Run/Debug configurations / Environment variables), I was able to get the ExUnit tests to launch successfully. 馃帀