本文介绍了Gem :: LoadError在Gemfile中使用git repo时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我分叉了sinbook gem并将git repo添加到了我的Gemfile中。但是依赖于sinbook的 gem会抛出Gem :: LoadError。
为什么不使用正在使用的宝石的
Gemfile
添加要求bundler / setup到app.rb.它需要加载捆绑的环境。更多信息可以在中找到。
由于您使用的是Sinatra,因此您可能还想查看。
I forked the sinbook gem and added the git repo to my Gemfile. But the sinatra-authentication gem, which depends on sinbook, throws Gem::LoadError.
Why isn't my version of the gem being used?
Gemfile
source :rubygems gem 'sinatra' gem 'sinatra-contrib' gem 'sequel' gem 'jruby-openssl' gem 'rack-flash' gem 'sinbook', git: 'https://github.com/JamesGecko/sinbook' gem 'sinatra-authentication' gem 'json-jruby' gem 'coffee-script' gem 'therubyrhino'error
PS C:\users\james\code\portal> jruby -S bundle Fetching gem metadata from http://rubygems.org/........ Fetching gem metadata from http://rubygems.org/.. Fetching https://github.com/JamesGecko/sinbook Installing addressable (2.2.8) Installing backports (2.5.1) Installing bouncy-castle-java (1.5.0146.1) Installing coffee-script-source (1.3.1) Installing multi_json (1.2.0) Installing execjs (1.3.0) Installing coffee-script (2.2.0) Installing dm-core (1.2.0) Installing dm-migrations (1.2.0) Installing dm-timestamps (1.2.0) Installing dm-validations (1.2.0) Installing eventmachine (0.12.10) Installing jruby-openssl (0.7.7) Installing json (1.5.0) Installing json-jruby (1.5.0) Installing rack (1.4.1) Installing rack-flash (0.1.2) Installing rack-protection (1.2.0) Installing rack-test (0.6.1) Installing rufus-tokyo (1.0.7) Installing sequel (3.34.1) Installing tilt (1.3.3) Installing sinatra (1.3.2) Using sinbook (0.1.9.jamesgecko) from https://github.com/JamesGecko/sinbook (at master) Installing sinatra-authentication (0.4.1) Installing sinatra-contrib (1.3.1) Installing therubyrhino (1.73.2) Using bundler (1.1.4) Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. PS C:\users\james\code\portal> jruby .\app.rb Gem::LoadError: Could not find sinbook (>= 0) amongst [addressable-2.2.8, backports-2.5.1, bouncy-castle-java-1.5.0146.1, bundler-1.1.4, coffee-script-2.2.0, coffee-script-source-1.3.1, dm-core-1.2.0, dm-migrations-1.2.0, dm-timestamps-1.2.0, dm-validations-1.2.0, eventmachine-0.12.10-java, execjs-1.3.0, jruby-openssl-0.7.7, jruby-win32ole-0.8.5, json-1.5.0-java, json-jruby-1.5.0-java, multi_json-1.2.0, rack-1.4.1, rack-flash-0.1.2, rack-protection-1.2.0, rack-test-0.6.1, rake-0.9.2.2, rufus-tokyo-1.0.7, sequel-3.34.1, sinatra-1.3.2, sinatra-authentication-0.4.1, sinatra-contrib-1.3.1, therubyrhino-1.73.2, tilt-1.3.3] to_specs at c:/dev/jruby-1.7.0.preview1/lib/ruby/shared/rubygems/dependency.rb:247 activate_dependencies at c:/dev/jruby-1.7.0.preview1/lib/ruby/shared/rubygems/specification.rb:777 each at org/jruby/RubyArray.java:1611 activate_dependencies at c:/dev/jruby-1.7.0.preview1/lib/ruby/shared/rubygems/specification.rb:766 activate at c:/dev/jruby-1.7.0.preview1/lib/ruby/shared/rubygems/specification.rb:750 try_activate at c:/dev/jruby-1.7.0.preview1/lib/ruby/shared/rubygems.rb:212 require at c:/dev/jruby-1.7.0.preview1/lib/ruby/shared/rubygems/custom_require.rb:59 require at c:/dev/jruby-1.7.0.preview1/lib/ruby/shared/rubygems/custom_require.rb:55 (root) at .\app.rb:7app.rb
require 'sinatra' require 'sinatra/reloader' require 'json' require 'digest/sha1' require 'rack-flash' require 'sinatra-authentication' use Rack::Session::Cookie, secret: 'foobar' use Rack::Flash # ...解决方案Add require "bundler/setup" to app.rb. It it needed to load the bundled environment. More info may be found in the bundler documentation.
Since you're using Sinatra, you may also want to look into using config.ru.
这篇关于Gem :: LoadError在Gemfile中使用git repo时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!