为什么 Cloud Foundry 无法加载 mongo_mapper?
我已将一个简单的 Ruby 测试应用程序上传到 Cloud Foundry,可以在我的计算机上运行< /em>™,但它在网站上给出以下错误。
====> logs/stderr.log <====
/var/vcap/data/packages/dea_ruby18/3.1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- mongo_mapper (LoadError)
from /var/vcap/data/packages/dea_ruby18/3.1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from recall.rb:2
我注意到您需要有一个位于我的根目录中的 Gemfile,但我不确定服务器是否正在使用它。
source "http://rubygems.org"
gem "mongo_mapper"
gem "bson_ext"
所以我猜测这不起作用有两个可能的原因:
- 我运行的是 Ruby 1.9,Cloud Foundry 运行的是 1.8,有什么不同吗? (我尝试将 'require 'rubygems'' 行添加到我的文件中,但没有区别)
- 我的 Gemfile 格式错误(或者还有一些其他附加要求来指定从何处获取 mongo_mapper gem)。
如何解决这个问题呢?
I've uploaded a simple Ruby test application to Cloud Foundry that works on my machine™, but it gives the following error on the site.
====> logs/stderr.log <====
/var/vcap/data/packages/dea_ruby18/3.1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- mongo_mapper (LoadError)
from /var/vcap/data/packages/dea_ruby18/3.1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from recall.rb:2
I noticed that you need to have a Gemfile which is present in my root directory, but I'm not sure if it's getting used by the server.
source "http://rubygems.org"
gem "mongo_mapper"
gem "bson_ext"
So I'm guessing there are two possible reasons why this isn't working:
- I'm running Ruby 1.9, Cloud Foundry has 1.8 and there is something different? (I tried adding the 'require 'rubygems'' line to my file but no difference)
- My Gemfile is in the wrong format (or there is some other additional requirement for specifying where to get the mongo_mapper gem from).
How can this problem be solved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我和你一样,在 cloudfoundry 上需要“mongo_mapper”时遇到了麻烦。我使用 Bundler 和 Gemfile 解决了我的问题,如 此页面在cloudfoundry告诉我们。
我现在在本地安装了“bundler”gem,并在应用程序树的根部添加了这个 Gemfile:
并且我没有在 .rb 文件中包含 require 行,而是只有这个:
在执行
vmc Push
或update
,你需要执行这个:我也做了一点有关它的博客文章。
I, like you, had trouble requiring 'mongo_mapper' on cloudfoundry. I solved my problems using Bundler and a Gemfile, as this page at cloudfoundry tells us to.
I now have "bundler" gem installed locally, and added this Gemfile at the root of the app tree:
and instead of having the require lines in the .rb file, I only have this:
before doing
vmc push
orupdate
, you need to execute this:I also did a little blog post about it.
这可能是一个问题,但我强烈建议您在开发环境和生产环境上使用相同的 Ruby 版本。为了方便起见,您可以使用 RVM 在您的计算机上安装 Ruby 1.8
您是否在您的应用程序的根目录? “bundle install”会在您的 Gemfile 中查找并安装 gem。请注意,如果您将 gem 分组为“开发”和“测试”等组,这些 gem 将不会安装在生产环境中。
It could be a problem, but I strongly recommend to use the same Ruby version on your development environment and your production envirnoment. To make it easy you can use RVM to install Ruby 1.8 on your machine
Did you do 'bundle install' in the root of your application? 'bundle install' looks in your Gemfile and install the gems. Note that if you group your gems in groups like 'development' and 'test', these gems will not be installed on production.