Solargraph 在 Visual Studio Code 中不起作用

nol*_*man 6 ruby visual-studio-code

我的 VS 代码中有以下错误:

[Error - 3:51:12 PM] Starting client failed
/usr/local/Cellar/ruby/2.6.3/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem solargraph (>= 0.a) with executable solargraph (Gem::GemNotFoundException)
    from /usr/local/Cellar/ruby/2.6.3/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
    from /usr/local/bin/solargraph:23:in `<main>'
Run Code Online (Sandbox Code Playgroud)

我目前使用rbenv并拥有全局且只有 Ruby 版本 2.6.3 这里似乎有什么问题?ruby/2.6.0/如果版本是 2.6.3,为什么我会看到上面的内容?

谢谢您的帮助!

cas*_*ide 7

如果一切都失败了,您可以尝试设置solargraph.commandPath为可执行文件的绝对路径。运行which solargraph应该给你使用的路径。

  • `solargraph.commandPath` 是 VS Code 中的一个配置选项。在 Mac 上,它位于代码 -&gt; 首选项 -&gt; 设置下的菜单中。 (4认同)

小智 5

我找到了您应该使用 gem install solargraph 的解决方案。如果不起作用并收到此错误

ERROR: Loading command: install (ArgumentError) unknown encoding name - CP720 ERROR: While executing gem ... (NoMethodError) undefined method "invoke_with_build_args" for nil:NilClass

尝试在 CMD 中由管理员执行

chcp 1252

然后再次尝试安装 gem

享受!