🐈

VS CodeでRubyの型サポートプラグインがエラーになる時

2025/03/21に公開

VS CodeSteepプラグインをインストールすると、メソッドシグニチャーなどを表示して、補完もできるようになります:
メソッドシグニチャーを表示している様子

ただ、ウェブページなどを見ながら設定していたらうまく動かず、こんなエラーログが表示されてしまいました:

Your RubyGems version (3.0.3.1) has a bug that prevents `required_ruby_version` from working for Bundler. Any scripts that use `gem install bundler` will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running `gem update --system 3.2.3`
/Library/Ruby/Gems/2.6.0/gems/bundler-2.4.17/lib/bundler/definition.rb:540:in `materialize': Could not find steep-1.10.0, activesupport-8.0.2, concurrent-ruby-1.3.5, csv-3.3.3, fileutils-1.7.3, json-2.10.2, language_server-protocol-3.17.0.4, listen-3.9.0, logger-1.6.6, mutex_m-0.3.0, parser-3.3.7.2, rainbow-3.1.1, rbs-3.9.0, securerandom-0.4.1, strscan-3.1.2, terminal-table-4.0.0, uri-1.0.3, base64-0.2.0, benchmark-0.4.0, bigdecimal-3.1.9, connection_pool-2.5.0, drb-2.2.1, i18n-1.14.7, minitest-5.25.5, tzinfo-2.0.6, rb-fsevent-0.11.2, rb-inotify-0.11.1, ast-2.4.3, racc-1.8.1, unicode-display_width-3.1.4, ffi-1.17.1-arm64-darwin, unicode-emoji-4.0.4 in locally installed gems (Bundler::GemNotFound)
	from /Library/Ruby/Gems/2.6.0/gems/bundler-2.4.17/lib/bundler/definition.rb:200:in `specs'
	from /Library/Ruby/Gems/2.6.0/gems/bundler-2.4.17/lib/bundler/definition.rb:266:in `specs_for'
	from /Library/Ruby/Gems/2.6.0/gems/bundler-2.4.17/lib/bundler/runtime.rb:18:in `setup'
	from /Library/Ruby/Gems/2.6.0/gems/bundler-2.4.17/lib/bundler.rb:162:in `setup'
	from /Library/Ruby/Gems/2.6.0/gems/bundler-2.4.17/lib/bundler/setup.rb:23:in `block in <top (required)>'
	from /Library/Ruby/Gems/2.6.0/gems/bundler-2.4.17/lib/bundler/ui/shell.rb:159:in `with_level'
	from /Library/Ruby/Gems/2.6.0/gems/bundler-2.4.17/lib/bundler/ui/shell.rb:111:in `silence'
	from /Library/Ruby/Gems/2.6.0/gems/bundler-2.4.17/lib/bundler/setup.rb:23:in `<top (required)>'
	from <internal:/Users/kitaitimakoto/.rubies/ruby-3.1.3/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/Users/kitaitimakoto/.rubies/ruby-3.1.3/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
[Error - 15:32:32] Server process exited with code 1.
[Error - 15:32:32] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 15:32:32] Connection to server got closed. Server will restart.
true
[Error - 15:32:32] Steep client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097

普段はZshchrubyを使って最新のRubyを使ったりバージョンを切り替えて使っているのですが、これはシステムに最初から入っているRubyが使われている……。

VS Codeを起動するラッパースクリプトを作ったり色々試してみたのですがうまくいかず、Steepプラグインのイシューを眺めていたらRecognize RVM installed Rubiesなるイシューがあって、 code コマンドで起動すると解決したとある。これはRVMだけどchrubyでも、codeコマンドによる起動で無事解決しました(VSCodiumでもcodiumコマンドで解決しました)。

Discussion