Closed swrobel closed 2 weeks ago
I have the same issue, but haven't set RUBIES
, I'm using plain chruby
.
The latest version exposes the setting to configure RUBIES
. I reached out to the rubygems team to verify if they had settled on the specification for the .ruby-version
file. Indeed omitting the patch should be supported, so I'll try to put a PR up for that.
@vinistock, I tested the latest, and noticed that the behavior of the new config doesn't exactly match the description provided, since:
$ echo $RUBIES
/opt/homebrew/Cellar/ruby/3.3.1 /opt/homebrew/Cellar/ruby@3.2/3.2.4
But I needed to set the following in my settings.json
, omitting the version numbers:
"chrubyRubies": ["/opt/homebrew/Cellar/ruby","/opt/homebrew/Cellar/ruby@3.2"]
After adjusting that, it seems like an improvement, but it's now generating a different set of errors:
Failed to setup the bundle: Command failed: gem install ruby-lsp
ERROR: Error installing ruby-lsp:
ERROR: Failed to build gem native extension.
current directory: /Users/swrobel/.gem/ruby/3.3.1/gems/prism-0.27.0/ext/prism
/opt/homebrew/opt/ruby/bin/ruby extconf.rb
checking for prism.h in /Users/swrobel/.gem/ruby/3.3.1/gems/prism-0.27.0/include... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include=${opt-dir}/include
--without-opt-include
--with-opt-lib=${opt-dir}/lib
--without-opt-lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/homebrew/Cellar/ruby/3.3.1/bin/$(RUBY_BASE_NAME)
extconf.rb:94:in `<main>': prism.h is required (RuntimeError)
extconf failed, exit code 1
Gem files will remain installed in /Users/swrobel/.gem/ruby/3.3.1/gems/prism-0.27.0 for inspection.
Results logged to /Users/swrobel/.gem/ruby/3.3.1/extensions/arm64-darwin-23/3.3.0/prism-0.27.0/gem_make.out
. See [Troubleshooting](https://github.com/Shopify/ruby-lsp/blob/main/TROUBLESHOOTING.md) for help
Failed to setup the bundle: Command failed: gem install ruby-lsp
ERROR: Error installing ruby-lsp:
ERROR: Failed to build gem native extension.
current directory: /Users/swrobel/.gem/ruby/3.3.1/gems/prism-0.27.0/ext/prism
/opt/homebrew/opt/ruby/bin/ruby extconf.rb
checking for prism.h in /Users/swrobel/.gem/ruby/3.3.1/gems/prism-0.27.0/include... yes
checking for prism/extension.h in /Users/swrobel/.gem/ruby/3.3.1/gems/prism-0.27.0/ext... yes
checking for whether -fvisibility=hidden is accepted as CFLAGS... yes
Running make build/libprism.a with {"SOEXT"=>"dylib", "AR"=>"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar", "ARFLAGS"=>"rcu ", "MAKEDIRS"=>"mkdir -p", "RMALL"=>"rm -fr"}
make: getcwd: No such file or directory
make: *** No rule to make target `build/libprism.a'. Stop.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include=${opt-dir}/include
--without-opt-include
--with-opt-lib=${opt-dir}/lib
--without-opt-lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/homebrew/Cellar/ruby/3.3.1/bin/$(RUBY_BASE_NAME)
--enable-build-debug
--disable-build-debug
--enable-build-minimal
--disable-build-minimal
extconf.rb:69:in `system': Command failed with exit 2: make (RuntimeError)
from extconf.rb:69:in `block in make'
from extconf.rb:68:in `chdir'
from extconf.rb:68:in `make'
from extconf.rb:132:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/swrobel/.gem/ruby/3.3.1/extensions/arm64-darwin-23/3.3.0/prism-0.27.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/swrobel/.gem/ruby/3.3.1/gems/prism-0.27.0 for inspection.
Results logged to /Users/swrobel/.gem/ruby/3.3.1/extensions/arm64-darwin-23/3.3.0/prism-0.27.0/gem_make.out
. See [Troubleshooting](https://github.com/Shopify/ruby-lsp/blob/main/TROUBLESHOOTING.md) for help
Interesting. Maybe the rubies installed via Homebrew have a different gem home than what I expect. Can you share what does gem env path
print for you for both rubies? Also, if you run gem install ruby-lsp
, does that successfully compile Prism or does that fail too?
Can you share what does
gem env path
print for you for both rubies? Also, if you rungem install ruby-lsp
, does that successfully compile Prism or does that fail too?
3.3.1
$ gem env path
/Users/swrobel/.gem/ruby/3.3.1:/opt/homebrew/lib/ruby/gems/3.3.0
$ gem install ruby-lsp
Successfully installed ruby-lsp-0.16.6
1 gem installed
It seems prism was already installed on 3.3.1. With ruby-lsp
installed, I no longer get any errors in VSCode when launching my Ruby 3.3.1 project.
3.2.4
$ gem env path
/Users/swrobel/.gem/ruby/3.2.4:/opt/homebrew/lib/ruby/gems/3.2.0
$ gem install ruby-lsp
Fetching language_server-protocol-3.17.0.3.gem
Fetching ruby-lsp-0.16.6.gem
Fetching prism-0.27.0.gem
Fetching sorbet-runtime-0.5.11367.gem
Successfully installed sorbet-runtime-0.5.11367
Building native extensions. This could take a while...
Successfully installed prism-0.27.0
Successfully installed language_server-protocol-3.17.0.3
Successfully installed ruby-lsp-0.16.6
4 gems installed
However, my Ruby 3.2.4 project still throws errors when opening in VSCode. Here's a gist of the ruby-lsp Output tab from VSCode.
@vinistock realizing perhaps this doesn't notify you since the issue is closed. @ing you just in case...
It does actually, unless I explicitly unsubscribe. I'm not sure what's going on for the older Ruby. It's breaking when running bundle install
, but inside Bundler's own code. And it's the Bundler version that is vendored inside the Ruby installation.
I assume you can successfully run bundle install in your terminal, so I wonder if we're not finding the wrong Bundler executable. If you run bundle -v
in your terminal for the old Ruby, which version is printed?
You're correct that there was something wrong with my Ruby 3.2.4 bundler setup. After resolving that, everything seems to be working as expected with ruby-lsp.
I suppose it's just the gem home issue outstanding at this point. Thanks so much for your help! 🚀
I suppose it's just the gem home issue outstanding at this point
Sorry, which gem home problem?
And my pleasure, thanks for reporting it!
Sorry, which gem home problem?
You previously said:
Interesting. Maybe the rubies installed via Homebrew have a different gem home than what I expect. Can you share what does gem env path print for you for both rubies?
and I provided those in the comment above
Oh, I see what you mean. Yeah, it doesn't seem like there are any issues there. Looking at the output you shared, we did find the correct gem home and gem path. So all should be good 👍.
So all should be good
If that's the case, then why did auto installation of the gem fail? It only worked after I manually installed it globally
Description
Reproduction steps
The only output that I see in the VSCode output tab for Ruby LSP is:
I don't see an activation command that I can attempt to replicate, as suggested in the troubleshooting steps, but running
chruby 3.3.1
in the VSCode terminal works without error.Versions / Environment
Ruby LSP: Update language server gem
commandVSCode settings.json
.ruby-version file contents:
A perhaps unique aspect of my setup is that I install rubies via Homebrew, and make them available in chruby by setting the
RUBIES
env var in my.zprofile
. This seems to be picked up properly by VSCode, regardless of whether it's launched from the dock icon or a terminal command.Another bug?
As an aside, this extension produces a confusing/inaccurate error message if using a .ruby-version file that doesn't specify a patch version, even though that should be acceptable for
chruby
, ex:The error shown is: