castwide / vscode-solargraph

A Visual Studio Code extension for Solargraph.
Other
423 stars 25 forks source link

Solargraph Gem Not Found + Couldn't Start Client Ruby Language Server Errors #191

Open jshinbk opened 4 years ago

jshinbk commented 4 years ago

Hi,

I receive the aforementioned errors when I open a .rb file in Visual Studio Code (VSC), even after running 'gem install solargraph' in the terminal.

Screen Shot 2020-08-20 at 3 33 21 AM

I've reviewed similar issues posted previously and tried a few of the suggestions, including uninstalling solar graph from my main terminal and then reinstalling along with the extension in VSC. Turned I had three separate versions installed, which I'm unsure whether it played a part or not. But to no avail.

Is this fixable and if not, could it be something I can disregard?

I'm just trying to test out some code in ruby while I do some practice problems for the time being (and it seems to work fine).

Thanks!

gh-greg commented 3 years ago

I too, have the same problem:

############################# ProductName: Mac OS X ProductVersion: 10.15.6 BuildVersion: 19G2021 ############################# Visual Studio Code: August 2020 (version 1.49) ############################# Shell session, to try to fix the problem: #############################

MYUID: ~/Documents/MYLOGNAME > sudo gem install solargraph Password:

Fetching solargraph-0.39.15.gem Building native extensions. This could take a while...

ERROR: Error installing solargraph: ERROR: Failed to build gem native extension.

current directory: /Library/Ruby/Gems/2.6.0/gems/jaro_winkler-1.5.4/ext/jaro_winkler

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20200911-7929-16q746q.rb extconf.rb creating Makefile

current directory: /Library/Ruby/Gems/2.6.0/gems/jaro_winkler-1.5.4/ext/jaro_winkler make "DESTDIR=" clean

current directory: /Library/Ruby/Gems/2.6.0/gems/jaro_winkler-1.5.4/ext/jaro_winkler make "DESTDIR=" make: *** No rule to make target /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin19/ruby/config.h', needed byadj_matrix.o'. Stop.

make failed, exit code 2

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/jaro_winkler-1.5.4 for inspection. Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/jaro_winkler-1.5.4/gem_make.out

MYUID: ~/Documents/MYLOGNAME > cat /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/jaro_winkler-1.5.4/gem_make.out

current directory: /Library/Ruby/Gems/2.6.0/gems/jaro_winkler-1.5.4/ext/jaro_winkler /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20200911-7929-16q746q.rb extconf.rb creating Makefile

current directory: /Library/Ruby/Gems/2.6.0/gems/jaro_winkler-1.5.4/ext/jaro_winkler make "DESTDIR=" clean

current directory: /Library/Ruby/Gems/2.6.0/gems/jaro_winkler-1.5.4/ext/jaro_winkler make "DESTDIR=" make: *** No rule to make target /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin19/ruby/config.h', needed byadj_matrix.o'. Stop.

make failed, exit code 2 a436605: ~/Documents/0-gregpf >

bmulholland commented 3 years ago

I ran into the same thing. I fixed it by installing solargraph in the global gemset for ruby 2.7.0; it would not work when I installed it for ruby 2.7.2.

I don't put developer-specific configuration in my Gemfile, because that's project level; other devs shouldn't be exposed to my setup. So I've installed solargraph in my global gemset (I use RVM) and configured the command path to the correct solargraph location. Installing it for ruby 2.7.2, I could run that path just fine from terminal, but when VSCode tries to run it I got:

/Users/bmulholland/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/rubygems.rb:277:in `find_spec_for_exe': can't find gem solargraph (>= 0.a) with executable solargraph (Gem::GemNotFoundException)
    from /Users/bmulholland/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/rubygems.rb:296:in `activate_bin_path'
    from /Users/bmulholland/.rvm/gems/ruby-2.7.2/bin/solargraph:23:in `<main>'

It's not clear if ruby 2.7.2 is unsupported or what, but at least it's working for me now.

spartan-alee commented 3 years ago

I found a bit of a fix. I'm using chruby with solargraph installed in my 2.7.2 version. The problem is that chruby isn't being called or set in the shell instance of the extension before trying to call solargraph, so everything is using global ruby and sad.

The fix is to make dummy wrapper shell script like:

#!/bin/bash

# or wherever you installed chruby into
source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh

chruby 2.7.2 # activate the ruby version/env that you want/have solargraph actually installed in

/home/${USERNAME}/.gem/ruby/2.7.2/bin/solargraph $@  
                           # or wherever solargraph is actually installed
                           # $@ to pass on all parameters

And set this shell script as the solargraph.commandPath parameter.

patrykk21 commented 3 years ago

I'm receiving the same issue, I'm running solargraph inside a container created by remote container vs code plugin.

It was working great until this morning.

Then I made some changes and relaunched vs code and it is not working anymore.

Solargraph is properly recognised in the terminal and works as expected. I'm using an absolute command path

patrykk21 commented 3 years ago

Is there a way to check the extension logs and on which step it fails?

patrykk21 commented 3 years ago

I rolled back to a previous version through git, the version to this morning and got it working again.

The main difference and biggest one, is that I was using alpine, now I'm using debian buster slim version.

Will try to pinpoint the exact issue

patrykk21 commented 3 years ago

I just had to add these lines to break solargraph

RUN apk add --update bash bash-doc bash-completion
RUN sed -i -e "s/bin\/ash/bin\/bash/" /etc/passwd
ENV LC_ALL=en_US.UTF-8

Why this breaks, I have no idea.

But since this is easily reproducible now I believe we can pinpoint the problem

Nicholas0350 commented 3 years ago

Solargraph is not even worth installing

nicklozon commented 2 years ago

Fixed by setting the absolute path to solargraph.

image

AdrianBinDC commented 2 years ago

Fixed by setting the absolute path to solargraph.

image

Can you expound a bit?

nicklozon commented 2 years ago

Can you expound a bit?

Yes - find the full path of bundle and solargraph binaries and set them in the Solargraph settings in VS Code.

You can typically find the location by using the which command if you're on a unix based system:

root:/app# which bundle
/usr/local/bundle/bin/bundle
root:/app# which solargraph
/usr/local/bundle/bin/solargraph

I'm using Remote Container, so VS Code doesn't recognize the binaries even though they are on the $PATH