VSCode 将调试 shell 更改为 Windows 上的 bash [英] VSCode change debug shell to bash on windows

查看:42
本文介绍了VSCode 将调试 shell 更改为 Windows 上的 bash的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文:我最近从 Sublime Text 切换到 Visual Studio Code,以测试 Microsoft 文本编辑器的调试功能.这里的主要问题是我的 Ruby on Rails 环境在 Windows 上的 Ubuntu 中设置为 bash.

Context: I recently switched from Sublime Text to Visual Studio Code to test the debugging functionalities of the Microsoft text editor. The main problem here is that my Ruby on Rails environment is set on bash in Ubuntu on Windows.

我将集成终端 shell 更改为 bash,因此,我可以使用集成终端来启动/调试我的应用程序.但是当使用使用 Ruby 扩展的集成调试工具时 ( https://github.com/rubyide/vscode-ruby ),好像是启动windows cmd来执行配置:

I changed the integrated terminal shell to bash, so, I can use the integrated terminal to launch/debug my application. But when using the integrated debug tool using the Ruby extension ( https://github.com/rubyide/vscode-ruby ), it seems to launch the windows cmd to execute the configuration:

调试器终端错误:进程失败:产生 rdebug-ide.bat ENOENT

Debugger terminal error: Process failed: spawn rdebug-ide.bat ENOENT

问题:我的问题是由 vscode 尝试使用 windows cmd 而不是指定的 bash shell 引起的吗?如果是这样,有没有办法告诉 vscode 使用它而不是 windows cmd?

Question: Is my problem caused by vscode trying to use the windows cmd instead of the specified bash shell? If so, is there a way to tell vscode to use it instead of the windows cmd?

这是我要执行的任务的 launch.json 配置:

Here's my launch.json config for the task I want to execute :

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Rails server",
      "type": "Ruby",
      "request": "launch",
      "cwd": "/mnt/c/Repos/<project_name>",
      "program": "rails",
      "pathToRDebugIDE": 
"~/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/ruby-debug-ide-0.6.0/bin/rdebug-ide",
      "args": ["server"]
    }
}

推荐答案

Visual Studio Code 的 Ruby 扩展只能使用 cmd 来启动调试器.因此,您需要一个 .cmd 包装器来调用 rdebug-ide.

That Ruby extension of Visual Studio Code is only able to use cmd to launch the debugger. Therefore you need a .cmd wrapper to call rdebug-ide.

安装适用于 Windows 的 RubyDevKit 应提供必要的包装器,但您也可以使用以下几行.它基本上是这样的:

Installing the RubyDevKit for Windows should provide the necessary wrappers, but you can also use the lines below. It basically looks like this:

@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
ECHO.This version of Ruby has not been built with support for Windows 95/98/Me.
GOTO :EOF
:WinNT
@ruby.exe "%~dpn0" %*

(这将使用 PATH 中的 ruby​​.exe 来执行名为 .bat 文件的脚本,但没有扩展名.)

(This will use the ruby.exe in your PATH to execute the script named like the .bat file, but without the extension.)

将它放在与 rdebug-ide 相同的位置并命名为 rdebug-ide.bat.调整您的 launch.json,使 pathToRDebugIDE 指向这个 .bat 文件(使用完整的 Windows 路径),并确保 ruby​​ 在您的 PATH 中.

Put this in the same location as rdebug-ide and call it rdebug-ide.bat. Adjust your launch.json so that pathToRDebugIDE points to this .bat file (use the full Windows path), and make sure ruby is in your PATH.

我目前将此设置与 ruby​​、rdebug-ide、rails 等的 cygwin 安装一起使用.

I'm currently using this setup with a cygwin installation of ruby, rdebug-ide, rails etc.

这篇关于VSCode 将调试 shell 更改为 Windows 上的 bash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆