Visual Studio Code(Ruby)未捕获异常 - 无法加载此类文件

Mic*_*res 5 ruby json launch visual-studio-code

我开始在visual studio代码中使用ruby进行编码,但是在加载文件时遇到了问题.当我的文件名命名为main.rb时,我在launch.json中找到配置"program":"$ {workspaceRoot} /main.rb"它加载得很好,但是当我将文件名更改为example.rb时,唯一的方法如果我将launch.rb更改为launch.json中的example.rb,我能够运行代码

我确信我做错了,但我很难在互联网上找到任何答案来解决这个问题.

小智 5

打开你的launch.json文件并像这样改变它(只有键“program”的值在改变):

之前:
{
"name": "Debug Local File",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/ main.rb"
}

之后:
{
"name": "Debug Local File",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${file}"
}