FYI, fixing Permission denied – /root/.gems (rails/passenger error)

software development

#1

I thought I’d save some other people some hassle.

Something changed at dreamhost and my rails sites stopped loading correctly. Instead of getting my website, I was getting a passenger error:

Permission denied – /root/.gems

The problem is easy to fix:

Add:

Gem.clear_paths

To the top of your config/boot.rb file.

So my config/boot.rb now looks like this:

Gem.clear_paths
require 'rubygems'
gem 'bundler' #koz added http://stackoverflow.com/questions/2282969/rails3-server-and-bundler-error-uninitialized-constant-bundler-nameerror
# Set up gems listed in the Gemfile.
gemfile = File.expand_path('../../Gemfile', __FILE__)
begin
  ENV['BUNDLE_GEMFILE'] = gemfile
  require 'bundler'
  Bundler.setup
rescue Bundler::GemNotFound => e
  STDERR.puts e.message
  STDERR.puts "Try running `bundle install`."
  exit!
end if File.exist?(gemfile)

Hope this helps someone else avoid having to figure it out.


#2

Works for me. Many thanks! Still curious what has change (default gem paths?)


#3

Honestly I have no idea, I know just enough rails to hack together a site for my wedding. The ins and outs of the details are still a mystery to me.


#4

Thanks a lot - saved me hours I’m sure :slight_smile:


#5

Thanks dude - absolutely panicked when I saw that and I started mucking around with DNS settings to a back up server under my control, but then I found this post - phew! :slight_smile:


#6

This fixed my pages, but I had problems with running rails commands after applying the fix. It seems to work if you flip the order of the first two:

require 'rubygems'
Gem.clear_paths
...

#7

Thanks a lot! This finally solves the issue for me, too.


#8

Many Thanks!!!
Saved me hours!!

I confirm that the order should be:

require 'rubygems’
Gem.clear_paths


#9

Happened to me and that fixed it for me also - thanks!