Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell Visual Studio代码终端外壳与任务外壳缺少rvm_Shell_Visual Studio Code_Rvm - Fatal编程技术网

Shell Visual Studio代码终端外壳与任务外壳缺少rvm

Shell Visual Studio代码终端外壳与任务外壳缺少rvm,shell,visual-studio-code,rvm,Shell,Visual Studio Code,Rvm,我使用RVM在基于Mac的开发环境中更改Ruby版本 在Visual Studio代码中,当我打开一个常规终端选项卡时,根据标准默认配置,我将被放入带有-l选项的bash登录shell中,如下所示: 默认情况下,从VSCode终端手动执行的RVM命令为我提供了该项目预期的ruby版本 $ rvm list ruby-2.0.0-p648 [ x86_64 ] ruby-2.1.10 [ x86_64 ] ruby-2.1.5 [ x86_64 ] ruby-2.2.10 [ x8

我使用RVM在基于Mac的开发环境中更改Ruby版本

在Visual Studio代码中,当我打开一个常规终端选项卡时,根据标准默认配置,我将被放入带有-l选项的bash登录shell中,如下所示:

默认情况下,从VSCode终端手动执行的RVM命令为我提供了该项目预期的ruby版本

$ rvm list
  ruby-2.0.0-p648 [ x86_64 ]
  ruby-2.1.10 [ x86_64 ]
  ruby-2.1.5 [ x86_64 ]
  ruby-2.2.10 [ x86_64 ]
  ruby-2.2.5 [ x86_64 ]
  ruby-2.3.0 [ x86_64 ]
* ruby-2.3.1 [ x86_64 ]
=> ruby-2.3.7 [ x86_64 ]

# => - current
# =* - current && default
#  * - default
但是,当我设置一个
.vscode/tasks.json
文件来执行相同的命令时,Ruby版本不是正确的版本,而是系统上的默认版本。此外,我无法实际使用
rvm use
切换版本(请参阅下面的错误消息)

任务执行的输出,带有关于没有正确登录shell的错误消息

> Executing task: rvm list && rvm use 2.3.7 <

  ruby-2.0.0-p648 [ x86_64 ]
  ruby-2.1.10 [ x86_64 ]
  ruby-2.1.5 [ x86_64 ]
  ruby-2.2.10 [ x86_64 ]
  ruby-2.2.5 [ x86_64 ]
  ruby-2.3.0 [ x86_64 ]
=* ruby-2.3.1 [ x86_64 ]
  ruby-2.3.7 [ x86_64 ]

# => - current
# =* - current && default
#  * - default


RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.


Terminal will be reused by tasks, press any key to close it.

我的理解是,在通读之后,终端shell配置和任务shell配置是相同的,那么终端shell和任务shell之间是否存在我所缺少的其他潜在不一致性?如果没有,那么RVM的哪些方面会阻止它在任务shell中工作?

RVM会覆盖“cd”命令来检测.ruby版本和.ruby gemset文件,并自动设置您的环境。新启动的vscode终端不会触发该事件。它只使用vscode启动时的默认或当前设置,而不是您在.ruby*文件中定义的设置

因此,在vscode中启动新终端时,我通常运行
cd$PWD

在tasks.json中定义rake任务时,我的命令行如下:

    {
        "label": "rake db:migrate",
        "type": "shell",
        "command": "cd $PWD; rake db:migrate",
        "problemMatcher": []
    },
请注意,命令行前面的
cd$PWD
用于挂接rvm

真是糟透了。但到目前为止,它对我有效

我怀疑这种对rvm/.ruby gemset/.ruby版本的不了解也会阻止vscode自动检测ruby插件应该执行的rake任务,如本文所述。因此,我想通过vscode任务运行的任何rake任务都必须通过这种方式手动定义


希望这能有所帮助。

有什么消息吗?也许可以尝试向您的shell选项中添加
“executable”
,并将
“args”
转换为列表?尝试提供RVM的完整路径
> Executing task: rvm list && rvm use 2.3.7 <

  ruby-2.0.0-p648 [ x86_64 ]
  ruby-2.1.10 [ x86_64 ]
  ruby-2.1.5 [ x86_64 ]
  ruby-2.2.10 [ x86_64 ]
  ruby-2.2.5 [ x86_64 ]
  ruby-2.3.0 [ x86_64 ]
=* ruby-2.3.1 [ x86_64 ]
  ruby-2.3.7 [ x86_64 ]

# => - current
# =* - current && default
#  * - default


RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.


Terminal will be reused by tasks, press any key to close it.
  "options": {
    "shell": {
      "args": "-l"
    }
  }
    {
        "label": "rake db:migrate",
        "type": "shell",
        "command": "cd $PWD; rake db:migrate",
        "problemMatcher": []
    },