Mongodb 未初始化常量BSON::ByteBuffer(Heroku)

Mongodb 未初始化常量BSON::ByteBuffer(Heroku),mongodb,heroku,sinatra,mongohq,Mongodb,Heroku,Sinatra,Mongohq,我在Heroku上启动应用程序时出错。在localhost上,一切正常 app.rb Sinatra Gemfile config.ru **Heroku原木** Slug compilation finished 2013-09-16T12:32:07.666778+00:00 heroku[web.1]: State changed from crashed to starting 2013-09-16T12:32:11.011518+00:00 heroku[web.1]: Starti

我在Heroku上启动应用程序时出错。在localhost上,一切正常

app.rb Sinatra

Gemfile

config.ru

**Heroku原木**

 Slug compilation finished
2013-09-16T12:32:07.666778+00:00 heroku[web.1]: State changed from crashed to starting
2013-09-16T12:32:11.011518+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 21566`
2013-09-16T12:32:12.324776+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/cursor.rb:419:in `construct_query_message': uninitialized constant BSON::ByteBuffer (NameError)
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/app.rb:21:in `new'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/cursor.rb:405:in `send_initial_query'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/app.rb:21:in `get_connection'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/cursor.rb:371:in `refresh'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/app.rb:26:in `<top (required)>'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/config.ru:1:in `require'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/cursor.rb:87:in `next_document'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/config.ru:1:in `block in <main>'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/db.rb:498:in `command'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:250:in `start'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bin/rackup:23:in `<main>'
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/connection.rb:704:in `check_is_master'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/connection.rb:656:in `setup'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/config.ru:in `new'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:141:in `start'
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/connection.rb:504:in `connect'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/config.ru:in `<main>'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/bin/rackup:4:in `<top (required)>'
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/connection.rb:101:in `initialize'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bin/rackup:23:in `load'
2013-09-16T12:32:13.530315+00:00 heroku[web.1]: Process exited with status 1
2013-09-16T12:32:13.544931+00:00 heroku[web.1]: State changed from starting to crashed

日志显示这是一个名称错误。我建议您指定正确的范围。Rails有一种非常复杂的查找常量的方法。我建议你看看这个:

还有这个


希望有帮助。

看起来您使用的Mongo是1.3.1,BSON可能是2.0。这些似乎不在一起工作。我会试着把1.9 BSON放在那里,看看是否有效

您可以通过添加以下内容来执行此操作: gembson,~>1.9.2

到你的档案


希望有帮助?

您使用ruby 2.0.0而不是1.9.x有什么原因吗?你试过1.9.x吗?您是否可以在本地检查是否可以找到BSON::ByteBuffer,即ruby-e'require BSON;放BSON::ByteBuffer'?并在heroku控制台的irb中执行类似操作,如本文所述?此外,在app.rb的第21行中,条件为除非db.user.nil?| |db.user.nil?。我想你是想测试db.password.nil?而不是db.user.nil?两次,我试过了。如果我运行ruby-e'requirebson;将BSON::ByteBuffer'放在本地计算机上,我得到未初始化的常量BSON::ByteBuffer。现在使用ruby 1.9.2,我得到了相同的错误。在本地和部署的版本上。我的rails应用程序一直运行良好,直到今天。@asprott你解决了吗?阅读它。我想不出这个案子有什么问题
source 'https://rubygems.org'
ruby '2.0.0'

gem 'mongo'
gem "bson"
gem 'bson_ext'
gem "sinatra"
gem "koala", "~> 1.7.0rc1"
gem "chartkick"
gem 'omniauth-facebook'
require './app'
run Sinatra::Application
 Slug compilation finished
2013-09-16T12:32:07.666778+00:00 heroku[web.1]: State changed from crashed to starting
2013-09-16T12:32:11.011518+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 21566`
2013-09-16T12:32:12.324776+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/cursor.rb:419:in `construct_query_message': uninitialized constant BSON::ByteBuffer (NameError)
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/app.rb:21:in `new'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/cursor.rb:405:in `send_initial_query'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/app.rb:21:in `get_connection'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/cursor.rb:371:in `refresh'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/app.rb:26:in `<top (required)>'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/config.ru:1:in `require'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/cursor.rb:87:in `next_document'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/config.ru:1:in `block in <main>'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/db.rb:498:in `command'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:250:in `start'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bin/rackup:23:in `<main>'
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/connection.rb:704:in `check_is_master'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/connection.rb:656:in `setup'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/config.ru:in `new'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:141:in `start'
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/connection.rb:504:in `connect'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/config.ru:in `<main>'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/bin/rackup:4:in `<top (required)>'
2013-09-16T12:32:12.324776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/mongo-1.3.1/lib/mongo/connection.rb:101:in `initialize'
2013-09-16T12:32:12.325003+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
2013-09-16T12:32:12.325160+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bin/rackup:23:in `load'
2013-09-16T12:32:13.530315+00:00 heroku[web.1]: Process exited with status 1
2013-09-16T12:32:13.544931+00:00 heroku[web.1]: State changed from starting to crashed