elixir-ls
elixir-ls copied to clipboard
ElixirLS can't find asdf.sh
Precheck
- [x] Do a quick search and make sure the issue has not yet been reported
- [x] Do not use the issues tracker for guidance, questions or support (try Elixir Forum, Stack Overflow, Slack, etc. instead)
- [x] If using a client other than VS Code, please try VSCode's "ElixirLS: Elixir support and debugger" extension. Does it reproduce your failure?
Environment
- Elixir & Erlang versions (elixir --version): 1.13.2-otp-24 (but that's irrelevant)
- Elixir Language Server version: default included in VS Code plugin
- Operating system: macOS 12.1
- Editor or IDE name (e.g. Emacs/VSCode): VS Code
- Editor Plugin/LSP Client name and version: v0.9.0
Current behavior
ElixirLS VS Code plugin can't find the Elixir binary installed with asdf.
Looking at the code, the plugin expects ~/.asdf/adsf.sh to exist, which is not the case on macOS (anymore?).
On macOS with Homebrew, according to asdf documentation, it is installed in /opt/homebrew/opt/asdf/libexec/asdf.sh. I tried symlinking, and in that case, the script is indeed loaded by VS Code, but breaks later.
Here are the (uninteresting) logs in VS Code Elixir Output panel:
/Users/xxx/.vscode/extensions/jakebecker.elixir-ls-0.9.0/elixir-ls-release/launch.sh: line 73: exec: elixir: not found
[Info - 9:11:26 AM] Connection to server got closed. Server will restart.
Of course, if I install Elixir directly with Homebrew, the plugin works fine on my environment. It is related to Elixir being installed with asdf.
Expected behavior
According to the documentation, asdf is a supported installation method, so I expect ElixirLS to find the Elixir program installed in ~/.asdf/installs/elixir/1.13.2-otp-24/bin/elixir, and ideally, use the one specified in .tool-versions in the current project.
Note that this could perfectly be a bug in asdf or in its Homebrew recipe.
Note that this could perfectly be a bug in asdf or in its Homebrew recipe.
I have the same problem, I installed asdf using Linuxbrew. I checked ls "${ASDF_DIR}/asdf.sh" and the env is set. So I'm not sure what's wrong with that script.
PS I'm new to elixir and asdf as well
asdf working on my machine (macos 11.6.2, zsh)
ls "${ASDF_DIR}/asdf.sh"
/usr/local/Cellar/asdf/0.9.0/libexec/asdf.sh
Yes, asdf also works on my machine.
The problem is that VS Code doesn't load my .zprofile (and that's expected!) so it's not aware of the $ASDF_DIR environment variable.
Have you found a way around this problem? I am also struggling with this issue.
Yes, don't install asdf from Homebrew. Install it using the Git method.
I was getting this error when I started VS Code from the applications menu on macOS instead of the terminal, which is not something I often do but I was annoyed by the error. I already had the ~/.tool-versions set up.
I solved it by adding the following line to ~/.profile and fully quitting VS Code then starting it:
. $ASDF_DIR/asdf.sh