我正在创建一个以httparty为依赖的Ruby Gem。
memair.gemspec
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |s|
s.name = 'memair'
s.version = '0.0.20'
s.date = '2018-09-24'
s.summary = 'An SDK for Memair'
s.description = 'An SDK for Memair allowing easy querying of the GraphQL API'
s.authors = ['Greg Clarke']
s.email = 'greg@memair.com'
s.files = ['lib/memair.rb']
s.homepage = 'https://github.com/memair/memair-ruby-sdk'
s.license = 'MIT'
s.add_dependency 'httparty', '~> 0.16'
s.require_paths = ["lib"]
end
lib / memair.rb
require 'httparty'
class Memair
def initialize(access_token)
#do stuff
end
end
当我在本地或通过rubygems.org安装gem时,它将安装依赖项并按预期工作。
$ gem uninstall memair
Successfully uninstalled memair-0.0.22
$ gem uninstall httparty
Remove executables:
httparty
in addition to the gem? [Yn] y
Removing httparty
Successfully uninstalled httparty-0.16.2
$ gem install memair
Fetching: httparty-0.16.2.gem (100%)
When you HTTParty, you must party hard!
Successfully installed httparty-0.16.2
Successfully installed memair-0.0.22
2 gems installed
$ irb
irb(main):001:0> require 'memair'
=> true
但是,当我在rails项目的Gemfile中推送宝石时,它失败并显示...
'require': cannot load such file -- httparty (LoadError)
完整追溯
Traceback (most recent call last):
53: from bin/rails:3:in `<main>'
52: from bin/rails:3:in `load'
51: from /Users/greg/Code/memair/memfit/bin/spring:15:in `<top (required)>'
50: from /Users/greg/Code/memair/memfit/bin/spring:15:in `require'
49: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
48: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
47: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
46: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
45: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
44: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
43: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
42: from /Users/greg/Code/memair/memfit/bin/rails:9:in `<top (required)>'
41: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require'
40: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
39: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
38: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
37: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
36: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
35: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
34: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
33: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/commands.rb:18:in `<main>'
32: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/command.rb:46:in `invoke'
31: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/command/base.rb:65:in `perform'
30: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
29: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
28: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
27: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/commands/server/server_command.rb:142:in `perform'
26: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/commands/server/server_command.rb:142:in `tap'
25: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/commands/server/server_command.rb:145:in `block in perform'
24: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require'
23: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
22: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
21: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
20: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
19: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
18: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
17: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
16: from /Users/greg/Code/memair/memfit/config/application.rb:7:in `<main>'
15: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.5/lib/bundler.rb:114:in `require'
14: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.5/lib/bundler/runtime.rb:65:in `require'
13: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.5/lib/bundler/runtime.rb:65:in `each'
12: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.5/lib/bundler/runtime.rb:76:in `block in require'
11: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.5/lib/bundler/runtime.rb:76:in `each'
10: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.5/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
9: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
8: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
7: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
6: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
5: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
4: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/memair-0.0.20/lib/memair.rb:1:in `<main>'
3: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require'
2: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
1: from /Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
/Users/greg/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require': cannot load such file -- httparty (LoadError)
我也曾尝试在我的Rails项目的Gemfile中包含httparty,我认为这是一种反模式,无论如何也无法解决问题。我还尝试了卸载我的gem和httparty并重建并上传到rubygems.org,结果相同。