1

我分叉了 sinbook gem 并将 git repo 添加到我的 Gemfile 中。但是依赖于 sinbook的sinatra-authentication gem 会抛出 Gem::LoadError。

为什么没有使用的 gem 版本?

宝石文件

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'

错误

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:7

应用程序.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

# ...
4

1 回答 1

1

添加require "bundler/setup"到 app.rb。它需要加载捆绑的环境。更多信息可以在捆绑器文档中找到。

由于您使用的是 Sinatra,因此您可能还想研究使用 config.ru

于 2012-06-08T13:26:53.073 回答