【问题标题】:Error when debugging Ruby code in VSCode (Mac OS X)在 VSCode (Mac OS X) 中调试 Ruby 代码时出错
【发布时间】:2015-08-08 23:18:37
【问题描述】:

我正在尝试找出这个新的 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
    }
]
}

有人知道是什么原因造成的吗?

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

【问题讨论】:

  • Node 是一个 JavaScript 引擎 - 列出 JavaScript 文件时出现错误(因此 .js 而不是 .rb)。您希望 JavaScript 引擎执行 Ruby 代码吗?
  • VSCode中调试的配置说明仅参考launch.json配置。我需要知道与 VSCode 编辑器相关的具体操作,以使其调试 ruby​​
  • 我的理解(非常基本,因为我没有在 VSCode 上花费大量时间)是它适用于使用 Node.js 进行 Web 开发,所以我冒险它不支持调试 ruby​​ 代码.

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


【解决方案1】:

Visual Studio Code Preview 不支持调试 Ruby。 如果你想在未来版本的 VSCode 中看到这个功能,你可以投票给它here。 在上面的启动配置中,您尝试配置“节点”来运行您的 ruby​​ 程序(无法运行)。

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

【讨论】:

    【解决方案2】:

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

    目前我正在处理这个VS Code Ruby Debugger,你可以从marketplace 下载它。它仍在进行中,因为它是非官方的。

    【讨论】:

      猜你喜欢
      • 2012-01-09
      • 1970-01-01
      • 1970-01-01
      • 2020-05-11
      • 1970-01-01
      • 1970-01-01
      • 2014-12-30
      • 1970-01-01
      • 2012-11-05
      相关资源
      最近更新 更多