RVM 在 VS Code Debugger 中无法正常工作 [英] RVM not working properly in VS Code Debugger

查看:23
本文介绍了RVM 在 VS Code Debugger 中无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 RVM 来管理我工作的 Ruby 版本.我们有两个 Rails 存储库,一个桌面版和一个移动版.桌面存储库使用 Ruby 2.2.4,移动存储库使用 2.2.2.

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.

我知道 RVM 具有自动切换 Gemfile 中指定的适当 Ruby 版本的功能(在我们的例子中在两个 Gemfile 中都指定了).

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).

现在,当我使用默认终端并在各个项目根目录中运行 ruby -v 命令时,它会显示相应的版本.但是当我在 VS 终端中执行相同操作时,它显示的是默认版本,即 2.2.4.

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.

现在我的主要问题是 Rails 调试器给了我以下错误:你的 Ruby 版本是 2.2.4,但是你的 Gemfile 指定了 2.2.2 每当我尝试使用移动存储库时VS 调试器.我怀疑这是因为我上面提到的任何事情.

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.

推荐答案

找到版本问题的解决方案.事实证明,如果您通过 GUI 打开 VS Code,那么 VS Code 将使用默认版本的 Ruby.但是,如果您通过进入项目目录并输入 code . 使用 CLI 打开它,它将使用 Gemfile 中指定的版本.

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.

我的猜测是,当您 cd 进入项目目录时,RVM 会执行 Ruby 版本切换,因为 VS Code 使用该切换版本,因为 VS Code 的实例是由相同的进程创建的做了开关.注意:我不太了解 Linux 进程,如果我错了,请随时纠正我.

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.

这篇关于RVM 在 VS Code Debugger 中无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆