'Solargraph not working in Visual Studio Code

I have the following error in my VS Code:

[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>'

I currently use rbenv and have as global and only Ruby version 2.6.3 What seems to be the problem here? why do I see a ruby/2.6.0/ above if the version is 2.6.3?

Thanks for the help!



Solution 1:[1]

If all else fails, you can try setting solargraph.commandPath to the executable's absolute path. Running which solargraph should give you the path to use.

Solution 2:[2]

I found the solution you should gem install solargraph. If not work and get this error

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

Try to execute by administrator in CMD

chcp 1252

Then try to install gem again

Enjoy!

Solution 3:[3]

Try executing solargraph -v from the VS Code terminal.
If that gives an error try gem install bundler:1.17.3

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 castwide
Solution 2 Jeroen Heier
Solution 3 Abhishek Agrawal