English 中文(简体)
Why can t Cloud Foundry load mongo_mapper?
原标题:

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?

最佳回答

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.

问题回答
  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.





相关问题
Ruby net-dns reverse lookups

I am trying to get reverse DNS lookups working with the net-dns gem for ruby. From the rdoc res = Net::DNS::Resolver.new ip = IPAddr.new("172.16.100.2") packet = res.search(ip) packet = res.search("...

How can I show updates with gem?

I want on my webserver a script that checks automatical over cron if there are gem updates without installing updates. I don t find anything about this task in the gem docs.

missing rake tasks?

I have ran gem install rails and am running 2.3.4 but i am missing some rake tasks like db and gems if i run rake -T i get the following tasks. How can i get all the others ? rake apache2 # ...

Ruby Daemons Gem

I installed the ruby gem Daemons. To make sure it was working I created a script that would print to a file every 5 seconds. I then created another file to run the script using the trivial example ...

Ruby gems repository

I m trying to set a gem repository on one of our local servers. Here are the steps I m running, that I ve followed from several guides. 1) I create the BASEDIR folder /var/www/html/gems 2) sudo cp -...

Search logic functionality

The functionality I m looking for: I have a form that will search my Proposal model. I want the form to contain a select box and display the categories I have. Now, category is merely a column in ...

Ruby Geolocation Gem/Plugins [closed]

What are the available (best) ruby IP-based geolocation gem/plugins? How do they compare to one another in terms of functionality, performance and ease of use (e.g. do they interact with a web ...

How do I find gems that depend on a given gem?

Is it possible to search for all gems that rely on a certain rubygem? For example, I d like to ask for all gems in gemcutter that rely on the test-unit gem. Background: I m looking to see how other ...

热门标签