Cannot install Rails

Hi

I just ran the Thoughtbot Laptop script on my new iMac (Yosemeti)

However, when I tried to install Rails, I got the suggestion to use the command

sudo gem install rails

so I did that.

however, when I try to create a new rails project, I get this error message:

Errno::EACCES: Permission denied @ dir_s_mkdir -     /Users/acandael/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/json-1.8.2
An error occurred while installing debug_inspector (0.0.2), and Bundler cannot
continue.
Make sure that `gem install debug_inspector -v '0.0.2'` succeeds before
bundling.
     run  bundle exec spring binstub --all
/Users/acandael/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.8.3/lib/bundler/resolver.rb:369:in    `resolve': Could not find gem 'rails (= 4.2.0) ruby' in the gems available on this machine. (Bundler::GemNotFound)
from /Users/acandael/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.8.3/lib/bundler/resolver.rb:167:in    `start'
from /Users/acandael/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.8.3/lib/bundler/resolver.rb:129:in `resolve'
from /Users/acandael/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.8.3/lib/bundler/definition.rb:193:in `resolve'
from /Users/acandael/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.8.3/lib/bundler/definition.rb:132:in `specs'
from /Users/acandael/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.8.3/lib/bundler/definition.rb:177:in `specs_for'
from /Users/acandael/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.8.3/lib/bundler/definition.rb:166:in `requested_specs'
from /Users/acandael/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.8.3/lib/bundler/environment.rb:18:in `requested_specs'
from /Users/acandael/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.8.3/lib/bundler/runtime.rb:13:in `setup'
from /Users/acandael/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.8.3/lib/bundler.rb:122:in `setup'
from /Users/acandael/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.8.3/lib/bundler/setup.rb:18:in `<top (required)>'
from /Users/acandael/.rbenv/versions/2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/acandael/.rbenv/versions/2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'

does anyone encountered the same issue? How can I solve this?

thanks,

Anthony

The Laptop script includes rbenv so you shouldn’t need the sudo prefix. Can you show what the output of gem install rails is?

You did? I’m afraid that was not great advice. Was that from us?

no Ben, the suggestion was in the error message when I tried to generate a new Rails project

greetings,

Anthony

Hi Andy,

I can’t show the output right now, it’s the new iMac at my office. I’ll post the output on Monday.

greetings,

Anthony

Did you try this? It’s happened to me sometimes that I get an error because some gem fails to build, run the individual gem installation, and then things work as expected.

Hi Carles,

I ran the command

gem install debug_inspector -v '0.0.2'

but that gives the error:

Anthonys-iMac% gem install debug_inspector -v '0.0.2'
Building native extensions.  This could take a while...
ERROR:  While executing gem ... (Errno::EACCES)
Permission denied @ dir_s_mkdir - /Users/acandael/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/extensions/x86_64-   darwin-14/2.2.0-static/debug_inspector-0.0.2

Hi Andy,

The output of

gem install rails

is

Anthonys-iMac% gem install rails
ERROR:  While executing gem ... (Errno::EACCES)
Permission denied @ rb_sysopen - /Users/acandael/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rails-4.2.0/README.md

Yes, this is a permissions error, and hence probably why you were suggested to use sudo. I can recall this happened to me the very first time I tried to setup a Ruby environment.

I’d wait for othere people’s suggestions, but if this is your very first time setting up a Ruby env, or unless you can tell exactly what the Laptop Script is doing, I’d clean up everything and start from scratch, but doing everything yourself and one step at a time. It’ll might take a little bit longer than just run a script, but it’ll also help you have a clear knowdlege of everything that had to be done to get it running.

I found a solution on Stack Overflow: ruby - Permission Error When Trying To Install Rails (OSX) - Stack Overflow

sudo chown -R acandael ~/.rbenv

fixed the issue.

greetings,

Anthony