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

bug: The terminal in VS Code cannot find the ruby version installed by asdf #1584

Closed
witcan opened this issue Jun 29, 2023 · 8 comments · Fixed by #1655
Closed

bug: The terminal in VS Code cannot find the ruby version installed by asdf #1584

witcan opened this issue Jun 29, 2023 · 8 comments · Fixed by #1655
Labels

Comments

@witcan
Copy link

witcan commented Jun 29, 2023

Describe the Bug

image

The ruby version in Iterm2 is correct
image

Steps to Reproduce

  1. Open VS Code
  2. 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

@witcan witcan added the bug label Jun 29, 2023
@hyperupcall
Copy link
Contributor

hyperupcall commented Jul 11, 2023

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.

@konung
Copy link

konung commented May 9, 2024

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 - >
Screenshot 2024-05-09 at 18 53 03
( I use fish-shell)

Screenshot 2024-05-09 at 18 50 38

@konung
Copy link

konung commented May 10, 2024

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.

image image

@konung
Copy link

konung commented May 10, 2024

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.

@konung
Copy link

konung commented May 10, 2024

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

@konung
Copy link

konung commented May 10, 2024

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.

@Intrepidd
Copy link

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

@Intrepidd
Copy link

"terminal.integrated.env.osx": {
        "PATH": ""
}

this did the trick for me

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

Successfully merging a pull request may close this issue.

4 participants