紙一重の積み重ね

アラフォーのエンジニアがなれる最高の自分を目指して、学んだことをこつこつ情報発信するブログです。

【VS Code】Failed to start Solargraph: Unable to load the EventMachine C extensionのエラーが出たときの対処方法 #Solargraph

f:id:yokoyantech:20181001130424p:plain

はじめに

Visual StudioでSolargraphが動かなくなったので、解決するまでをメモ。

実行環境

  • Windows10 64bit Pro
  • Vivual Studio Code 1.27.2
  • Ruby 2.4.4

発生したエラー

Failed to start Solargraph: Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby' Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby' 
C:/Ruby24/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- 2.4/rubyeventmachine (LoadError) from C:/Ruby24/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require' from
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7-x86-mingw32/lib/rubyeventmachine.rb:2:in `<top (required)>' from C:/Ruby24/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `require' from
C:/Ruby24/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require' from C:/Ruby24/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:39:in `require' from C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7-x86-mingw32/lib/eventmachine.rb:8:in `<top (required)>' from C:/Ruby24/lib/ruby/2.4.0/rubygems/core_ext/ke...

事象の確認

solargraph helpが動かない。

$ solargraph help
Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'
Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'
C:/Ruby24/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- 2.4/rubyeventmachine (LoadError)
        from C:/Ruby24/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'

このブログ記事と同じ状況。

unirt.hatenablog.com

解決方法

  • eventmachineのアンインストール
$ gem uninstall eventmachine
  • 再インストール
$ gem install eventmachine --platform ruby
  • VSCodeを再起動
  • SolargraphをUpdateする

動作確認

image