solargraph
solargraph copied to clipboard
Solargraph fails to start with NoMethodError when Gem::Specification is extended
I'm trying to use Solargraph for a Rails project in which a method that has been added to Gem::Specification with class_eval is called in a gemspec file. Solargraph fails to start with a NoMethodError for the added method.
I've tried using the require field in solargraph.yaml to ensure that the file containing the Gem::Specification extension is loaded, to no effect. Any pointers you can provide would be much appreciated.
Stack trace:
❯ solargraph scan
Traceback (most recent call last):
23: from /Users/angus/.rbenv/versions/2.6.6/bin/solargraph:23:in `<main>'
22: from /Users/angus/.rbenv/versions/2.6.6/bin/solargraph:23:in `load'
21: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.17/bin/solargraph:5:in `<top (required)>'
20: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
19: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
18: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
17: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
16: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.17/lib/solargraph/shell.rb:172:in `scan'
15: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/benchmark-0.1.0/lib/benchmark.rb:293:in `measure'
14: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.17/lib/solargraph/shell.rb:173:in `block in scan'
13: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.17/lib/solargraph/api_map.rb:169:in `load'
12: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.17/lib/solargraph/api_map.rb:169:in `new'
11: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.17/lib/solargraph/workspace.rb:29:in `initialize'
10: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.17/lib/solargraph/workspace.rb:165:in `generate_require_paths'
9: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.17/lib/solargraph/workspace.rb:165:in `each'
8: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.17/lib/solargraph/workspace.rb:170:in `block in generate_require_paths'
7: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.17/lib/solargraph/workspace.rb:170:in `chdir'
6: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.17/lib/solargraph/workspace.rb:173:in `block (2 levels) in generate_require_paths'
5: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/solargraph-0.39.17/lib/solargraph/workspace.rb:173:in `eval'
4: from /Users/angus/code/gh/bambooengineering/umbrella/banco-broker-gateway/banco-broker-gateway.gemspec:8:in `<main>'
3: from /Users/angus/code/gh/bambooengineering/umbrella/banco-broker-gateway/banco-broker-gateway.gemspec:8:in `new'
2: from /Users/angus/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/specification.rb:2067:in `initialize'
1: from /Users/angus/code/gh/bambooengineering/umbrella/banco-broker-gateway/banco-broker-gateway.gemspec:18:in `block in <main>'
/Users/angus/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/specification.rb:2176:in `method_missing': undefined method `global_version_add_dependency' for #<Gem::Specification:0x00007fa06a8d6168> (NoMethodError)
The offending lines in banco-broker-gateway/banco-broker-gateway.gemspec:
Gem::Specification.new do |s|
# ...
s.global_version_add_dependency "rails"
s.global_version_add_dependency "rest-client"
end
The definition of global_version_add_dependency in banco-shared/lib/gem_helper.rb:
Gem::Specification.class_eval do
def global_version_add_dependency(gem_name)
add_dependency gem_name, Banco::Versions.global_gem_version(gem_name)
end
end