简体   繁体   中英

RVM's auto-detect Ruby version via repo files feature is not working in VSCode login shell terminal

RVM has a feature to detect and use the correct Ruby version based on eg a .ruby-version file in the repo. This requires a login shell which I have enabled in VSCode via:

"terminal.integrated.shell.linux": "bash",
"terminal.integrated.shellArgs.linux": ["--login"],

However the feature isn't working by default, I have to cd . every time I open the terminal as if it is not a login shell.

There's a similar issue about new tabs in a gnome shell: https://github.com/rvm/rvm/issues/2519

I wonder if anyone else ran into this and whether this might be an issue with VSCode or RVM?

This may be a workaround..

Add this in vs "terminal.integrated.shellArgs.linux": [ "cd ."],

The reason this doesn't work by default is because rvm hooks the cd command in the shell to setup the ruby/gem paths for your project and there's no cd issued to the shell by the VS Code terminal opening.

I was able to resolve this issue on my Linux system by adding the login setup as suggested in the question and then adding a simple cd . at the end of my ~/.bash_profile after the section where RVM is actually set up.

Doing this results in rvm properly adjusting the paths in the VS Code terminal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM