Rails “no such file to load — rubygems (LoadError)”

I recently moved my app from Heroku to a Linux instance using Amazon’s EC2 - my first experience on Linux. I used Amazon’s Elastic Beanstalk service which is support set up the Linux server to run Ruby on Rails. However, when I get into my app’s directory and try to run rake commands, I get the error:

/usr/bin/rake:9:in ‘require’: no such file to load – rubygems (LoadError) from usr/bin/rake:9

  1. I read that it might be multiple installs of Ruby on the server, but when I type, “which -a ruby”, I only get: usr/bin/ruby
  2. “which gem” yields: /usr/bin/gem
  3. “which rake” yields: /usr/bin/rake
  4. My gems install find, when I do ‘bundle install’ it works fine
  5. When I type ‘gem list --local rubygems’ I get a line that says “***LOCAL GEMS ***” and that’s it (not sure if that’s correct or not

I’m not sure how to fix this since I don’t know Linux (ie commands) and have only worked on Heroku before. I’d be grateful for any ideas or help. Thank you!

yellowreign wrote in post #1097357:

I recently moved my app from Heroku to a Linux instance using Amazon's
EC2
- my first experience on Linux. I used Amazon's Elastic Beanstalk
service
which is support set up the Linux server to run Ruby on Rails. However,
when I get into my app's directory and try to run rake commands, I get
the
error:

/usr/bin/rake:9:in 'require': no such file to load -- rubygems
(LoadError)
from usr/bin/rake:9

   1. I read that it might be multiple installs of Ruby on the server,
but
   when I type, "which -a ruby", I only get: usr/bin/ruby
   2. "which gem" yields: /usr/bin/gem
   3. "which rake" yields: /usr/bin/rake
   4. My gems install find, when I do 'bundle install' it works fine
   5. When I type 'gem list --local rubygems' I get a line that says
   "***LOCAL GEMS ***" and that's it (not sure if that's correct or not

Well that would sure explain why it can't load rubygems if 'gem list
--local rubygems' is not listed.

Did you try "gem list" to get a listing of all locally installed gems?
What does that do for you?

Are you using 'bundle exec rake [command]' to run your rake commands?

Are you using one of the Ruby version managers (RVM or rbenv)?

Thanks for your post. I ended up just scrapping the whole instance. I’m not sure what went wrong so I got so frusterated, I killed the instance and pushed my code and it seems ok with the new instance. I’m surprised the first one went bad since it was based on the same template image for Ruby on Rails, but never worked. Thanks!