Solargraph: Error when running "solargraph bundle"

Created on 25 Jun 2019  路  11Comments  路  Source: castwide/solargraph

~
$ solargraph bundle
Traceback (most recent call last):
16: from /my/repo/.bundle/bin/solargraph:29:in <main>' 15: from /my/repo/.bundle/bin/solargraph:29:inload'
14: from /my/repo/vendor/ruby/2.5.0/gems/solargraph-0.34.0/bin/solargraph:5:in <top (required)>' 13: from /my/repo/vendor/ruby/2.5.0/gems/thor-0.20.3/lib/thor/base.rb:466:instart'
12: from /my/repo/vendor/ruby/2.5.0/gems/thor-0.20.3/lib/thor.rb:387:in dispatch' 11: from /my/repo/vendor/ruby/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:ininvoke_command'
10: from /my/repo/vendor/ruby/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:27:in run' 9: from /my/repo/vendor/ruby/2.5.0/gems/solargraph-0.34.0/lib/solargraph/shell.rb:186:inbundle'
8: from /my/repo/vendor/ruby/2.5.0/gems/solargraph-0.34.0/lib/solargraph/documentor.rb:18:in document' 7: from /my/repo/vendor/ruby/2.5.0/gems/solargraph-0.34.0/lib/solargraph/documentor.rb:18:inchdir'
6: from /my/repo/vendor/ruby/2.5.0/gems/solargraph-0.34.0/lib/solargraph/documentor.rb:19:in block in document' 5: from /Users/taylor/.anyenv/envs/rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/bundler-2.0.1/lib/bundler.rb:313:inwith_clean_env'
4: from /Users/taylor/.anyenv/envs/rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/bundler-2.0.1/lib/bundler.rb:562:in with_env' 3: from /Users/taylor/.anyenv/envs/rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/bundler-2.0.1/lib/bundler.rb:313:inblock in with_clean_env'
2: from /my/repo/vendor/ruby/2.5.0/gems/solargraph-0.34.0/lib/solargraph/documentor.rb:23:in block (2 levels) in document' 1: from /my/repo/vendor/ruby/2.5.0/gems/solargraph-0.34.0/lib/solargraph/documentor.rb:23:ineach'
/my/repo/vendor/ruby/2.5.0/gems/solargraph-0.34.0/lib/solargraph/documentor.rb:25:in block (3 levels) in document': undefined methodname' for nil:NilClass (NoMethodError)
~

In my case it looks like it finds the spec but spec.__materialize__ returns nil.

All 11 comments

I think you're right. In those cases, it should probably skip the spec with a warning. I'll work on that for a patch release.

A couple other things that might help:

  • You might need to run bundle install to make sure your bundle is up to date.
  • If you added solargraph to your Gemfile, you can try running bundle exec solargraph bundle instead.

My bundle is up-to-date, and I was running it with bundle exec. I added a catch for the issue and out of 182 gems in my bundle, it fails to initialize all but 2 of them. One of the gems it succeeds on is rufo 0.7.0, and the other is an internal gem I cannot share.

Thanks for the info. I'll test against Rufo and see what happens.

Are those gems installed in a diferent location than the others in your Gemfile, like with a path or git argument?

Nope, both of those are included in the Gemfile the same as the others that are failing.

Okay, thanks.

The master branch includes a change that will skip and warn for unmaterialized specs. It's slated for the next release.

Ah I spoke too soon. I forgot that I had added a path option to the internal gem. I removed it and now it's failing - so using a local path does solve the issue. That said, rufo is still working without any extra parameters.

Fix pushed in v0.34.1.

I did some more thinking and I might know what the problem is, and why Rufo was an exception - I always provide a --path argument to my bundle installs, installing gems per-project locally to a /vendor directory. Rufo worked because I always install it in the global gemset so I can use it wherever. I'll test this theory and report back.

EDIT: Yep, I removed the call to Bundler.reset! in documentor.rb and everything ran as expected. I'm sure you had your reasons for calling it but it does break custom bundle paths.

Thanks for tracking it down. There was a similar issue in a function that's been moved to ApiMap::BundlerMethods, and I should be able to fix Documentor the same way.

Version 0.34.2 changes Documentor to use an external process with a clean environment to detect bundle dependencies. Modifying and resetting the running environment is no longer necessary.

All good to go now! Thanks!

Was this page helpful?
0 / 5 - 0 ratings