RVM not working properly in VS Code Debugger

删除回忆录丶 提交于 2020-12-08 13:12:34

问题


I'm using RVM to manage Ruby versions where I work. We have two Rails repos, one Desktop and one Mobile. The Desktop repo uses Ruby 2.2.4 and the Mobile repo uses 2.2.2.

I know that RVM has the functionality of automatically switching the appropriate Ruby version which is specified in the Gemfile (which is specified in our case in both the Gemfiles).

Now, when I use the default terminal, and run the ruby -v command, inside individual project root directories, it displays the appropriate versions. But when I do the same in VS terminal, it displays the default version, which is 2.2.4.

Now my main problem was that the Rails debugger was giving me the following error: Your Ruby version is 2.2.4, but your Gemfile specified 2.2.2 for the Mobile repo whenever I tried to use the VS Debugger. And I suspect that it is because of whatever I've mentioned above.

Is that the case or is it a different issue? Also provide the solution for whatever the issue is.


回答1:


Found the solution for the version issue. Turns out that if you open VS Code through the GUI, then VS Code uses the default version of Ruby. But if you open it with the CLI by going inside the directory of the project and then typing code ., it works with the version specified in the Gemfile.

My guess is that RVM does a Ruby version switch when you cd into the project directory and because of which VS Code uses that switched version because the instance of VS Code was created by the same process which did the switch. Note: I don't know much about Linux processes so feel free to correct me if I'm wrong.




回答2:


There is a setting for the command path of the ruby interpreter that defaults to just "ruby". I'm just getting into vscode, but it may be possible to use a vscode variable interpolation to the rvm command and set the ruby interpreter value to the rvm result.

Has anyone used https://github.com/ngetahun/vscode-rvm?



来源:https://stackoverflow.com/questions/53849628/rvm-not-working-properly-in-vs-code-debugger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!