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?
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 pushorupdate, you need to execute this:I also did a little blog post about it.