【问题标题】:VSCode solargraph provider failed on Ruby 2.2.2VSCode solargraph 提供程序在 Ruby 2.2.2 上失败
【发布时间】:2020-11-30 23:26:15
【问题描述】:

我可以让 Ruby 代码导航与 VSCode 和 Ruby 2.2.2 一起使用吗?我已经安装了最新的 VSCode (1.51.1),但我正在尝试在仍然使用 Ruby 2.2.2 的项目中编辑代码。我能够让代码完成和文档适用于 String 等内置类,但我无法让它适用于项目中的代码。

要诊断问题,我键入 Ctrl+Shift+P 并选择 Developer: Show Logs...,然后选择 Extension Host。然后,当我将鼠标悬停在一个项目方法上时,我在输出窗口中看到这重复了几次:

[2020-11-30 15:08:33.198] [exthost] [error] [castwide.solargraph] provider FAILED
[2020-11-30 15:08:33.198] [exthost] [error] undefined

我已经安装了三个 VSCode 扩展:

  1. Ruby 0.27.0 by Peng Lv
  2. Ruby Solargraph 0.12.0 by Castwide
  3. Stafford Brunk 开发的 VSCode Ruby 0.27.0

我尝试安装较新版本的 Solargraph,但它们的依赖项在 Ruby 2.2.2 上不起作用。

作为一个实验,我尝试创建一个最小的项目来浏览。当我打开 myproject.rb 并将鼠标悬停在第 5 行对 get_other_name() 的调用上时,我看到了上述错误。

myproject.rb

require 'sinatra'
require_relative 'helper'

get '/' do
    'Hello, ' + get_other_name()
end

def get_name()
    return 'Bob'
end

helper.rb

def get_other_name()
    return 'Alice'
end

宝石文件

source 'https://rubygems.org'
ruby '2.2.2'

# To install all these gems, run "gem install bundler", then "bundle install".

gem 'thin', '1.7.2'
gem 'sinatra', '2.0.1'

group :devtools, optional: true do
    gem 'rubocop', '~> 0.52'
    gem 'solargraph', '0.12.2'
end

.vscode/settings.json

{
    "solargraph.useBundler": true
}

我在 Ubuntu 20.04 上运行,我使用 rvm 安装 Ruby 2.2.2。我还尝试在 solargraph 设置中关闭 bundler 并将命令路径设置为 solargraph,但我得到了同样的错误。

【问题讨论】:

  • 你检查过this GitHub issue吗?
  • 感谢@J.M.Arnold 的建议,但我在那里没有找到任何帮助。似乎不再支持solargraph -v。它说,Could not find command "_v".

标签: ruby visual-studio-code installation


【解决方案1】:

查看日照版本

当您从命令行运行 solargraph -v 时会发生什么?

确保您从 VS Code 中运行的相同 Ruby 版本进行 gem install solargraph。例如,如果您的项目有一个 .ruby-version 文件,则该版本需要安装 Solargraph。

【讨论】:

  • 当我运行solargraph -v,我得到Could not find command "_v".
猜你喜欢
  • 2020-06-14
  • 2016-01-21
  • 1970-01-01
  • 1970-01-01
  • 2016-08-24
  • 1970-01-01
  • 1970-01-01
  • 2022-08-13
  • 1970-01-01
相关资源
最近更新 更多