asdf-elixir
asdf-elixir copied to clipboard
unknown command: mix. Perhaps you have to reshim?
Describe the Bug
I got an error unknown command: mix. Perhaps you have to reshim? after installing elixir and erlang, and running mix.
I have added asdf reshim and the absolute path of mix (/home/user/.asdf/shims/mix), and it didn't solve the issue.
Steps to Reproduce
run the following shell script on ubuntu 18.04:
#!/bin/bash
set -e
export DEBIAN_FRONTEND=noninteractive
cd /tmp
# Install asdf - language/tools version manager
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.2
. $HOME/.asdf/asdf.sh
. $HOME/.asdf/completions/asdf.bash
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc
asdf plugin add erlang
asdf plugin add elixir
asdf install erlang 21.3.2
asdf global erlang 21.3.2
asdf install elixir 1.8.1
asdf global elixir 1.8.1
asdf reshim
# Get the application code
git clone ...
cd /tmp/app
# Install dependencies
export HOME=/tmp/app
mix local.hex --force
mix local.rebar --force
mix deps.get --force
....
Expected Behaviour
be able to use mix without any errors
Actual Behaviour
I got an error: unknown command: mix. Perhaps you have to reshim?
Environment
ASDF VERSION:
v0.10.2-7e7a1fa
ASDF ENVIRONMENT VARIABLES:
ASDF_DIR=/home/ssm-user/.asdf
ASDF INSTALLED PLUGINS:
elixir https://github.com/asdf-vm/asdf-elixir.git master f43f34e
erlang https://github.com/asdf-vm/asdf-erlang.git master 0463971
asdf plugins affected (if relevant)
elixir and erlang
Manually downloading kerl as you are doing should not be necessary. Can you explain why you are doing that?
Also, overriding $HOME as you are doing and not setting $ASDF_DIR is likely causing the problem. I'd suggest not changing $HOME unless necessary.
Moved to the elixir plugin as this doesn't seem to an issue with asdf core.
Manually downloading kerl as you are doing should not be necessary. Can you explain why you are doing that?
Also, overriding
$HOMEas you are doing and not setting$ASDF_DIRis likely causing the problem. I'd suggest not changing$HOMEunless necessary.
I am manually downloading kerl because I had an error once where kerl wasn't found. I will remove that.
I really need to override $HOME as it fixes an issue with elixir.
I tried to set all these env vars ASDF_CONFIG_FILE, ASDF_DATA_DIR, and ASDF_DIR as this:
export ASDF_CONFIG_FILE=~/.asdf
export ASDF_DATA_DIR=~/.asdf
export ASDF_DIR=~/.asdf
And now I am getting another error after I run mix: No version is set for command mix.
What else should I try?
Did you verify elixir is installed with asdf current? And if so, what does type -a mix print?
Did you verify elixir is installed with
asdf current? And if so, what doestype -a mixprint?
@Stratus3D Yes, elixir is installed, and type -a mix returns mix is /root/.asdf/shims/mix.
I have added these 2 lines (again) before running any mix command and after overriding the $HOME and it worked:
asdf global erlang 21.3.2
asdf global elixir 1.8.1
@Stratus3D As soon as I override the HOME env var, asdf tries to find the .tool-versions at HOME instead of using the ASDF_DIR. How do I change the .tool-versions path?
I've the same problem, it's actually kind of interesting.
`mix is /Users/keremozdemir/.asdf/shims/mix ~ ❯ asdf info OS: Darwin 192.168.1.101 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:37 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6031 arm64
SHELL: fish, version 3.7.1
BASH VERSION: 3.2.57(1)-release
ASDF VERSION: v0.14.0-ccdd47d
ASDF INTERNAL VARIABLES: ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions ASDF_DATA_DIR=/Users/keremozdemir/.asdf ASDF_DIR=/Users/keremozdemir/.asdf ASDF_CONFIG_FILE=/Users/keremozdemir/.asdfrc
ASDF INSTALLED PLUGINS: elixir https://github.com/asdf-vm/asdf-elixir.git master a4c42e1 erlang https://github.com/asdf-vm/asdf-erlang.git master 8c5dacf nodejs https://github.com/asdf-vm/asdf-nodejs.git master c5b7c40
~ ❯ asdf list elixir *1.16.2 erlang *25.3.2.12 nodejs *18.20.2`
config.fish:
`set -x LANG en_US.UTF-8
set -x JAVA_HOME /Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home
set -gx GSAP_TOKEN "XXXXXXX"
set -gx CFLAGS "-O2 -g -fno-stack-check" set -gx KERL_CONFIGURE_OPTIONS "--disable-hipe --without-javac --enable-wx --with-wx-config=/opt/homebrew/bin//wx-config --with-ssl=$(brew --prefix openssl)" set -xU KERL_BUILD_DOCS yes set -xU KERL_INSTALL_HTMLDOCS yes set -xU KERL_INSTALL_MANPAGES yes
if status is-interactive # Commands to run in interactive sessions can go here end
source ~/.iterm2_shell_integration.fish source ~/.asdf/asdf.fish
pnpm
set -gx PNPM_HOME "/Users/keremozdemir/Library/pnpm" if not string match -q -- $PNPM_HOME $PATH set -gx PATH "$PNPM_HOME" $PATH end
pnpm end`
I believe this has been fixed in asdf version 0.16.x.