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

Visual Studio Code (Ruby) uncaught exception - cannot load such file

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

中将 main.rb 更改为 example.rb

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

打开您的 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}"
}