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

时间:2015-05-27 03:52:01

标签: ruby node.js macos debugging visual-studio-code

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

  

错误:无法启动'节点'在调试模式下

这就是终端出现的内容:

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

这就是我配置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
    }
]
}

有谁知道造成这种情况的原因是什么?

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

2 个答案:

答案 0 :(得分:2)

Visual Studio Code Preview不支持调试Ruby。 如果您希望在VSCode的未来版本中看到此功能,可以为其投票here。 在上面的启动配置中,您尝试配置“node”来运行ruby程序(这不能正常工作)。

来源:我是Visual Studio Code Team的成员。

答案 1 :(得分:0)

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

目前我正在处理此VS Code Ruby Debugger,您可以从marketplace下载。它还在进行中,非官方的。