bug: The terminal in VS Code cannot find the ruby version installed by asdf
witcan opened this issue ยท 8 comments
Describe the Bug
The ruby version in Iterm2 is correct
Steps to Reproduce
- Open VS Code
- Exec
ruby -v
Expected Behaviour
The terminal in VS Code can use the ruby installed by asdf normally.
Actual Behaviour
The terminal in VS Code uses the ruby version that comes with mac.
Environment
OS:
Darwin aiyuhangdeMacBook-Pro.local 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:22 PDT 2023; root:xnu-8796.121.3~7/RELEASE_X86_64 x86_64
SHELL:
zsh 5.9 (x86_64-apple-darwin22.0)
BASH VERSION:
3.2.57(1)-release
ASDF VERSION:
v0.11.3-2f55f93
ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/Users/aiyuhang/.asdf
ASDF_DIR=/Users/aiyuhang/.asdf
ASDF_CONFIG_FILE=/Users/aiyuhang/.asdfrc
ASDF INSTALLED PLUGINS:
nodejs https://github.com/asdf-vm/asdf-nodejs.git master 4f8aa3d
ruby https://github.com/asdf-vm/asdf-ruby.git master bc6e7c3
asdf plugins affected (if relevant)
No response
Does opening and closing VSCode or logging in and out fix the issue? I suspect this is an issue with your terminal session not receiving the updated environment variables.
It might also be worth looking into the terminal.integrated.inheritEnv
VSCode setting. I am assuming that other terminal emulators like Terminal.app and iTerm2 "see" the correct Ruby version.
I'm also seeing this issue:
Using VS Code latest version.
terminal.integrated.inheritEnv = set to true
I'm trying to use asdf and various ruby versions. I have legacy projects using Ruby 2.3.8, 2.5, 2.7, 3.0, 3.1
VS Code in terminal or tasks , is trying to exectue everything using system Ruby which 2.6 on Mac
In terminal & iTerm2 everything works fine - >
( I use fish-shell)
Trying to debug using steps in asdf-vm/asdf-ruby#103
Notice the order in which ruby is listed in terminal, and then inside terminal in vscode. I'm not sure (yet) what and where determines loading orders, but it might have something to do with it.
A bit more debuggin info:
if I use fish, bash or zsh in Terminal VS Code session - I have this problem, but if I load pwsh ( PowerShell for OSX) , then asdf / ruby is recodnized.
So it definitely has something to do with the load order. I unset and then set $PATH in my integrated terminal ( just making sure asdf shims are loaded first) , and it works .
SO just need to figure out where the $PATH is getting changed by VSCODE, and why
So the solution for me finally was to make sure that asdf is loaded before anything else in my ~/.config/fish/config.fish
At the very top - BEFORE ANYTHING ELSE
set -gx PATH /Users/konung/.asdf/shims $PATH
Still not sure what the root cause of it ( will need to investigate later) - my fish config is fairly big, with many customizations. Just wanted to report back a solution.
Seeing the same issue.
Interestingly, when ruby asdf list ruby
, the good one is selected :
*3.2.2
3.2.4
3.3.0
3.3.1
But ruby -v
points to the wrong one
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin23]
When comparing $PATH on both integrated and external terminals, the value are different
I don't think it's an asdf issue but rather something to do with vscode handling of the PATH
"terminal.integrated.env.osx": {
"PATH": ""
}
this did the trick for me