我正在尝试在heroku 上部署一个使用mongodb 和mongoid 的rails 应用程序。一切都在本地运行良好,但是当我部署它时(heroku 服务器启动正常),我收到一个错误,即找不到“bson”gem:
/app/vendor/bundle/ruby/1.9.1/gems/mongo-1.3.1/lib/mongo.rb:56:in `require': no such file to load -- bson (LoadError)
奇怪的是我明确地将它包含在我的 gemfile 中。当我在本地运行 'bundle install' 时,Bundler 会安装 bson gem,但是当我使用 'git push heroku master' 来初始化应用程序时,heroku 的 bundler 会完全忽略 bson gem——它会安装 mongo、mongoid 以及除 bson 之外的所有内容。
这是我的 Gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.11'
gem 'mongo'
gem 'bson'
gem 'mongoid'
group :development do
gem 'therubyrhino'
end
group :assets do
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "twitter-bootstrap-rails"
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'devise'
gem 'omniauth'
gem 'omniauth-facebook'
当我运行“heroku run bundle install”时:
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.0.3)
Using i18n (0.6.1)
Using multi_json (1.5.0)
Using activesupport (3.2.11)
Using builder (3.0.4)
Using activemodel (3.2.11)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.4)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.2.2)
Using actionpack (3.2.11)
Using mime-types (1.19)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.4.4)
Using actionmailer (3.2.11)
Using arel (3.0.2)
Using tzinfo (0.3.35)
Using activerecord (3.2.11)
Using activeresource (3.2.11)
Using bcrypt-ruby (3.0.1)
Using coffee-script-source (1.4.0)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.7.6)
Using rdoc (3.12)
Using thor (0.16.0)
Using railties (3.2.11)
Using coffee-rails (3.2.2)
Using commonjs (0.2.6)
Using orm_adapter (0.4.0)
Using warden (1.2.1)
Using devise (2.2.1)
Using multipart-post (1.1.5)
Using faraday (0.8.4)
Using hashie (1.2.0)
Using httpauth (0.2.0)
Using jquery-rails (2.1.4)
Using jwt (0.1.5)
Using less (2.2.2)
Using less-rails (2.2.6)
Using mongo (1.3.1)
Using moped (1.3.2)
Using origin (1.0.11)
Using mongoid (3.0.17)
Using oauth2 (0.8.0)
Using omniauth (1.1.1)
Using omniauth-oauth2 (1.1.1)
Using omniauth-facebook (1.4.1)
Using bundler (1.3.0.pre.5)
Using rails (3.2.11)
Using sass (3.2.5)
Using sass-rails (3.2.5)
Using twitter-bootstrap-rails (2.2.0)
Using uglifier (1.3.0)
Cannot write a changed lockfile while frozen.
Your bundle is complete! It was installed into ./vendor/bundle
请注意,它不像我在本地运行 bundle install 时那样“使用 bson (1.3.1)”:
Using rake (10.0.3)
Using i18n (0.6.1)
Using multi_json (1.5.0)
Using activesupport (3.2.11)
Using builder (3.0.4)
Using activemodel (3.2.11)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.4)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.2.2)
Using actionpack (3.2.11)
Using mime-types (1.19)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.4.4)
Using actionmailer (3.2.11)
Using arel (3.0.2)
Using tzinfo (0.3.35)
Using activerecord (3.2.11)
Using activeresource (3.2.11)
Using bcrypt-ruby (3.0.1)
Using bson (1.3.1)
Using coffee-script-source (1.4.0)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.7.6)
Using rdoc (3.12)
Using thor (0.16.0)
Using railties (3.2.11)
Using coffee-rails (3.2.2)
Using commonjs (0.2.6)
Using orm_adapter (0.4.0)
Using warden (1.2.1)
Using devise (2.2.1)
Using multipart-post (1.1.5)
Using faraday (0.8.4)
Using hashie (1.2.0)
Using httpauth (0.2.0)
Using jquery-rails (2.1.4)
Using jwt (0.1.5)
Using less (2.2.2)
Using less-rails (2.2.6)
Using mongo (1.3.1)
Using moped (1.3.2)
Using origin (1.0.11)
Using mongoid (3.0.17)
Using oauth2 (0.8.0)
Using omniauth (1.1.1)
Using omniauth-oauth2 (1.1.1)
Using omniauth-facebook (1.4.1)
Using bundler (1.2.3)
Using rails (3.2.11)
Using sass (3.2.5)
Using sass-rails (3.2.5)
Using therubyrhino_jar (1.7.4)
Using therubyrhino (2.0.2)
Using twitter-bootstrap-rails (2.2.0)
Using uglifier (1.3.0)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
heroku 的捆绑器上有一些疯狂的过滤器吗?一切似乎都运行良好,只是它完全忽略了 Gemfile 和 Gemfile.lock 中 bson 的存在。
注意:我在本地使用 jruby,就像 heroku 一样。