【发布时间】:2022-06-24 07:11:37
【问题描述】:
在我的launch.json 文件中,我有这个简单的配置:
{
"name": "Run RSpec - all",
"type": "Ruby",
"request": "launch",
"program": "/Users/timregan/.asdf/shims/rspec",
},
(注:/Users/timregan/.asdf/shims/rspec 是在 zsh 终端运行 which rspec 的结果。)
当我运行它时,我得到了错误
Uncaught exception: /Users/timregan/.asdf/shims/rspec:3: unknown regexp options - hbrw.
exec /opt/homebrew/opt/asdf/libexec/bin/asdf ex...
^~~~~~~~~
/Users/timregan/.asdf/shims/rspec:3: syntax error, unexpected local variable or method, expecting `do' or '{' or '('
.../opt/asdf/libexec/bin/asdf exec "rspec" "$@"
... ^~~~
/Users/timregan/.asdf/installs/ruby/3.0.1/bin/rdebug-ide:23:in `load'
/Users/timregan/.asdf/installs/ruby/3.0.1/bin/rdebug-ide:23:in `<main>'
在 VSCode 外部的终端上运行 rspec 会按预期运行测试而不会出错。
注意在配置中添加"cwd": "${workspaceRoot}",不会影响报错。
我安装了各种 Ruby VSCode 扩展:
我的配置是this VSCode recipe 中配置的精简版。保持不变(例如,将参数添加到配置中)该配方给了我同样的错误。
发生了什么,我该如何解决?
【问题讨论】:
-
这更像是一种解决方法,而不是解释出了什么问题,但是 Connor Shea 的 VSCode 扩展 Ruby Test Explorer 使我能够从 VSCode 运行和调试我的 Ruby 代码的 RSpec 测试