为什么 Cloud Foundry 无法加载 mongo_mapper?

发布于 2024-11-13 07:35:42 字数 893 浏览 2 评论 0原文

我已将一个简单的 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"

所以我猜测这不起作用有两个可能的原因:

  1. 我运行的是 Ruby 1.9,Cloud Foundry 运行的是 1.8,有什么不同吗? (我尝试将 'require 'rubygems'' 行添加到我的文件中,但没有区别)
  2. 我的 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:

  1. 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)
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

零度℉ 2024-11-20 07:35:42

我和你一样,在 cloudfoundry 上需要“mongo_mapper”时遇到了麻烦。我使用 Bundler 和 Gemfile 解决了我的问题,如 此页面在cloudfoundry告诉我们。

我现在在本地安装了“bundler”gem,并在应用程序树的根部添加了这个 Gemfile:

source "http://rubygems.org"
gem 'sinatra'
gem 'json'
gem 'mongo'
gem 'mongo_mapper'

并且我没有在 .rb 文件中包含 require 行,而是只有这个:

Bundler.require

在执行 vmc Pushupdate,你需要执行这个:

bundle package
bundle install

我也做了一点有关它的博客文章

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:

source "http://rubygems.org"
gem 'sinatra'
gem 'json'
gem 'mongo'
gem 'mongo_mapper'

and instead of having the require lines in the .rb file, I only have this:

Bundler.require

before doing vmc push or update, you need to execute this:

bundle package
bundle install

I also did a little blog post about it.

高速公鹿 2024-11-20 07:35:42
  1. 这可能是一个问题,但我强烈建议您在开发环境和生产环境上使用相同的 Ruby 版本。为了方便起见,您可以使用 RVM 在您的计算机上安装 Ruby 1.8

  2. 您是否在您的应用程序的根目录? “bundle install”会在您的 Gemfile 中查找并安装 gem。请注意,如果您将 gem 分组为“开发”和“测试”等组,这些 gem 将不会安装在生产环境中。

  1. 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

  2. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文