Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

unknown command: mix. Perhaps you have to reshim? #120

Open
soltex1 opened this issue Nov 17, 2022 · 7 comments
Open

unknown command: mix. Perhaps you have to reshim? #120

soltex1 opened this issue Nov 17, 2022 · 7 comments
Labels

Comments

@soltex1
Copy link

soltex1 commented Nov 17, 2022

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

@soltex1 soltex1 added the bug label Nov 17, 2022
@Stratus3D
Copy link
Member

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.

@Stratus3D Stratus3D transferred this issue from asdf-vm/asdf Nov 18, 2022
@Stratus3D
Copy link
Member

Moved to the elixir plugin as this doesn't seem to an issue with asdf core.

@soltex1
Copy link
Author

soltex1 commented Nov 18, 2022

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.

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?

@Stratus3D
Copy link
Member

Did you verify elixir is installed with asdf current? And if so, what does type -a mix print?

@soltex1
Copy link
Author

soltex1 commented Nov 18, 2022

Did you verify elixir is installed with asdf current? And if so, what does type -a mix print?

@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

@soltex1
Copy link
Author

soltex1 commented Nov 23, 2022

@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?

@offwork
Copy link

offwork commented May 12, 2024

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`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants