Skip to content

Instantly share code, notes, and snippets.

@geoffroymontel
Last active December 20, 2015 03:09
Show Gist options
  • Save geoffroymontel/6061524 to your computer and use it in GitHub Desktop.
Save geoffroymontel/6061524 to your computer and use it in GitHub Desktop.
Problem running Ruby 2 + Rails 4 on Ubuntu 12.04 TLS

Hello

I'm trying to use Ruby 2 and Rails 4 on production but there seems to be a problem with the version of Rubygems that comes with Ruby 2.0.0-p247.

I installed Ruby 2.0.0-p247 and Rails 4.0.0 on a fresh Ubuntu 12.04 TLS server VM

vagrant@dev:~$ gem -v
2.0.3
vagrant@dev:~$ bundle -v
Bundler version 1.3.5
vagrant@dev:~$ rails -v
Rails 4.0.0
vagrant@dev:~$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]

When I do a simple

rails new testapp

I get the following error

Installing rake (10.1.0) 
Errno::EACCES: Permission denied - /usr/local/lib/ruby/gems/2.0.0/build_info/rake-10.1.0.info
An error occurred while installing rake (10.1.0), and Bundler cannot continue.
Make sure that `gem install rake -v '10.1.0'` succeeds before bundling.

And

vagrant@dev:~$ gem install rake -v '10.1.0'
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/local/lib/ruby/gems/2.0.0 directory.

Permissions seem broken indeed

vagrant@dev:~$ ls -la /usr/local/lib/ruby/gems/2.0.0/
total 28
drwxr-xr-x  7 root root 4096 Jul  8 14:16 .
drwxr-xr-x  3 root root 4096 Jul  8 14:16 ..
drwxr-xr-x  2 root root 4096 Jul  8 14:16 build_info
drwxr-xr-x  2 root root 4096 Jul  9 07:50 cache
drwxr-xr-x  2 root root 4096 Jul  8 14:16 doc
drwxr-xr-x 33 root root 4096 Jul  9 07:50 gems
drwxr-xr-x  3 root root 4096 Jul  9 07:50 specifications

I tried again with a fresh Ubuntu 12.04 TLS VM with Ruby 1.9.3 and Rails 4, and it's working out of the box.

vagrant@dev:~$ ruby -v
ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-linux]
vagrant@dev:~$ gem -v
1.8.23
vagrant@dev:~$ bundle -v
Bundler version 1.3.5
vagrant@dev:~$ rails -v
Rails 4.0.0
vagrant@dev:~$ gem env gemdir
/usr/local/lib/ruby/gems/1.9.1
vagrant@dev:~$ ls -la /usr/local/lib/ruby/gems/1.9.1/
total 24
drwxrwxr-x  6 root root 4096 May 15 14:48 .
drwxrwxr-x  3 root root 4096 May 15 14:48 ..
drwxrwxr-x  2 root root 4096 Jul  9 18:24 cache
drwxrwxr-x  2 root root 4096 May 15 14:48 doc
drwxrwxr-x 48 root root 4096 Jul  9 18:24 gems
drwxrwxr-x  2 root root 4096 Jul  9 18:24 specifications

There must be definitely something wrong with ruby 2.0, bundler 1.3.5, rubygems 2.0.3 and Rails 4 on Ubuntu.

Best regards

Geoffroy

@kramerdog
Copy link

As far as I can see, this is all still the case as of 25/02/14 with:
rubygems 2.2.2
bundler 1.6.0.rc (not sure why I have rc version?)
Rails 4.0.3
ruby 2.0.0p353

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment