LoginSignup
30
20

More than 3 years have passed since last update.

Solargraphをインストールしたにもかかわらず、拡張機能「Ruby Solargraph」が「gem install solargraph」エラーになる

Posted at

Solargraphをgem installしているにもかかわらず、vscodeの拡張機能であるRuby Solargraph
が以下のようなエラーを表示することがあります。

image.png

わたしの環境では、拡張機能側がSolargraphを探せていないことがこの原因でした。 拡張機能Ruby Solargraphは項目Command Pathの設定値をもとにSolargraph Gemを探し、そのデフォルト値はsolargraphとなっています。

image.png

そこでおもむろに以下のようなコマンドを打ち込んでみると、確かにsolargraphが見つかりませんでした。繰り返すようにSolargraphはgem install済みです、gem install時にsolarpathコマンドのPATHが通るはずですが、何らかの事情で通らなかったのでしょう。

$ solargraph help
-bash: solargraph: command not found

  1. solargraphの実体を探して、PATHを通す
  2. solargraphの実体を探して、そのフルパスをCommand Pathに設定する。

この問題の解消法としては以上の2つが思いつきますが、今回、わたしは2を選択しました。まずはgem envコマンドでsolargraphコマンドが設置されているディレクトリを探します。

$ gem env | grep "EXECUTABLE DIRECTORY"
  - EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/2.6.0/bin

つまり/usr/local/lib/ruby/gems/2.6.0/bin/solargraphが目的のコマンドになるはずなので、それを以下の通りに確認します。

$ /usr/local/lib/ruby/gems/2.6.0/bin/solargraph help
Commands:
  solargraph --version, -v            # Print the version
  solargraph available-cores          # List available documentation versions
  solargraph clear-cores              # Clear the cached core documentation
  solargraph config [DIRECTORY]       # Create or overwrite a default configuration file
  solargraph download-core [VERSION]  # Download core documentation
  solargraph help [COMMAND]           # Describe available commands or one specific command
  solargraph list-cores               # List the local documentation versions
  solargraph reporters                # Get a list of diagnostics reporters
  solargraph socket                   # Run a Solargraph socket server
  solargraph stdio                    # Run a Solargraph stdio server

あとは以下のようにCommand Pathsolargraphのフルパスを指定してやるだけで、ポップアップは表示されなくなり、拡張機能が正しく稼働するようになるはず。

image.png

30
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
30
20