在VSCode中调试Ruby代码时出错(Mac OS X)

时间:2021-10-23 15:13:27

I'm trying to figure out this new Visual Studio Code (VSCode) Editor while also learning Ruby. Whenever I try to debug a simple ruby program (even Hello World) I receive the following error VSCode

我正在尝试找出这个新的Visual Studio代码(VSCode)编辑器,同时也学习Ruby。每当我尝试调试一个简单的ruby程序(甚至Hello World)时,我收到以下错误VSCode

Error: could not launch 'node' in debug mode

错误:无法在调试模式下启动“node”

And this is what shows up in my Terminal:

这就是我的终端出现的情况:

/Users/Chixco/Documents/RubyProjects/FirstApp/test.rb:1
(function (exports, require, module, __filename, __dirname) { puts "Hello!"
                                                               ^^^^^^^^
SyntaxError: Unexpected string
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.runMain [as _onTimeout] (module.js:501:10)
at Timer.listOnTimeout (timers.js:110:15)

This is how I have my launch.json file is configured:

这就是我配置launch.json文件的方法:

{
"version": "0.1.0",
// List of configurations. Add new configurations or edit existing ones.  
// ONLY "node" and "mono" are supported, change "type" to switch.
"configurations": [
    {
        // Name of configuration; appears in the launch configuration drop down menu.
        "name": "Launch test.rb",
        // Type of configuration. Possible values: "node", "mono".
        "type": "node",
        // Workspace relative or absolute path to the program.
        "program": "test.rb",
        // Automatically stop program after launch.
        "stopOnEntry": true,
        // Command line arguments passed to the program.
        "args": [],
        // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
        "cwd": ".",
        // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
        "runtimeExecutable": null,
        // Environment variables passed to the program.
        "env": { }
    }, 
    {
        "name": "Attach",
        "type": "node",
        // TCP/IP address. Default is "localhost".
        "address": "localhost",
        // Port to attach to.
        "port": 5858
    }
]
}

Does anyone know what could be causing this?

有谁知道是什么原因引起的?

P.S. When I use my Aptana Studio plugin in Eclipse, I don't have any issues.

附:当我在Eclipse中使用我的Aptana Studio插件时,我没有任何问题。

2 个解决方案

#1


2  

Visual Studio Code Preview does not support debugging Ruby. If you would like to see this feature in a future version of VSCode you can vote for it here. In your launch configuration from above you've tried to configure "node" to run your ruby program (which cannot work).

Visual Studio Code Preview不支持调试Ruby。如果您希望在未来版本的VSCode中看到此功能,可以在此处投票。在上面的启动配置中,你试图配置“node”来运行你的ruby程序(这是行不通的)。

Source: I am a member of the Visual Studio Code Team.

来源:我是Visual Studio代码团队的成员。

#2


0  

As VS Code already exposes the debugging API and allow us to customize, we can easily create a ruby debugger ourselves.

由于VS Code已经公开了调试API并允许我们自定义,我们可以自己轻松地创建一个ruby调试器。

Currently I'm working on this VS Code Ruby Debugger, you can download it from marketplace. It's still in progress and of coz, non-official.

目前我正在研究这个VS Code Ruby Debugger,你可以从市场上下载它。它仍然在进行中,非官方的。

#1


2  

Visual Studio Code Preview does not support debugging Ruby. If you would like to see this feature in a future version of VSCode you can vote for it here. In your launch configuration from above you've tried to configure "node" to run your ruby program (which cannot work).

Visual Studio Code Preview不支持调试Ruby。如果您希望在未来版本的VSCode中看到此功能,可以在此处投票。在上面的启动配置中,你试图配置“node”来运行你的ruby程序(这是行不通的)。

Source: I am a member of the Visual Studio Code Team.

来源:我是Visual Studio代码团队的成员。

#2


0  

As VS Code already exposes the debugging API and allow us to customize, we can easily create a ruby debugger ourselves.

由于VS Code已经公开了调试API并允许我们自定义,我们可以自己轻松地创建一个ruby调试器。

Currently I'm working on this VS Code Ruby Debugger, you can download it from marketplace. It's still in progress and of coz, non-official.

目前我正在研究这个VS Code Ruby Debugger,你可以从市场上下载它。它仍然在进行中,非官方的。