title: rails s throws an error extconf failed, exit code 1
body: <p>I run 'rails s' in a rails app folder and get the following</p>
  
  <pre><code>extconf failed, exit code 1
  
  Gem files will remain installed in /usr/local/rvm/gems/ruby-2.1.2/gems/debugger-1.6.8 for inspection.
  Results logged to /usr/local/rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/debugger-1.6.8/gem_make.out
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/ext_conf_builder.rb:38:in `block in build'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tempfile.rb:324:in `open'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/ext_conf_builder.rb:17:in `build'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:161:in `block (2 levels) in build_extension'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:160:in `chdir'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:160:in `block in build_extension'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:159:in `synchronize'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:159:in `build_extension'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:198:in `block in build_extensions'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:195:in `each'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:195:in `build_extensions'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:1436:in `block in build_extensions'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/user_interaction.rb:45:in `use_ui'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:1434:in `build_extensions'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/stub_specification.rb:60:in `build_extensions'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/basic_specification.rb:56:in `contains_requirable_file?'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:925:in `block in find_inactive_by_path'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:924:in `each'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:924:in `find'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:924:in `find_inactive_by_path'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems.rb:185:in `try_activate'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:132:in `rescue in require'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
      from /usr/local/rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:9:in `&lt;main&gt;'
  </code></pre>
  
  <p>I am not sure how to fix this?</p>
  
  <p>EDIT:
  so before I made a mistake and installed some gems with sudo </p>
  
  <p>I had this error before </p>
  
  <pre><code>/Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:212:in `initialize': Permission denied @ rb_sysopen - /usr/local/rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/debugger-1.6.8/gem_make.out (Errno::EACCES)
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:212:in `open'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:212:in `write_gem_make_out'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:132:in `build_error'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:171:in `rescue in build_extension'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:156:in `build_extension'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:198:in `block in build_extensions'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:195:in `each'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:195:in `build_extensions'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:1436:in `block in build_extensions'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/user_interaction.rb:45:in `use_ui'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:1434:in `build_extensions'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/stub_specification.rb:60:in `build_extensions'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/basic_specification.rb:56:in `contains_requirable_file?'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:925:in `block in find_inactive_by_path'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:924:in `each'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:924:in `find'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:924:in `find_inactive_by_path'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems.rb:185:in `try_activate'
      from /Users/at/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:132:in `rescue in require'
      from /Users/a/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
      from /usr/local/rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:9:in `&lt;main&gt;'
  </code></pre>
  
  <p>so I ran</p>
  
  <pre><code>sudo chown -R `whoami`:staff /usr/local/rvm/gems/ruby-2.1.2
  </code></pre>
  
  <p>then I tried to fix it by using rbenv and followed the instructions to install rbenv from online</p>
  
  <pre><code>ruby -v 
  ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
  </code></pre>
  
  <p>Running rails -v and bundle exec rails gives exactly same error as rails</p>
  
  <pre><code> extconf failed, exit code 1
  .....
  </code></pre>
  
  <p>Gemfile</p>
  
  <pre><code>source 'https://rubygems.org'
  ruby '2.1.2'
  
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
  gem 'rails', '4.1.1'
  gem 'bcrypt',               '3.1.7'
  gem 'faker',                '1.4.2'
  gem 'will_paginate',           '3.0.7'
  gem 'bootstrap-will_paginate', '0.0.10'
  
  # Use SCSS for stylesheets
  gem 'sass-rails', '~&gt; 4.0.3'
  
  # Use bootstrap sass
  gem 'bootstrap-sass',       '3.2.0.0'
  
  gem 'uglifier',             '2.5.3'
  gem 'coffee-rails',         '4.0.1'
  gem 'jquery-rails',         '3.1.2'
  gem 'turbolinks',           '2.3.0'
  gem 'jbuilder',             '2.1.3'
  gem 'rails-html-sanitizer', '1.0.1'
  gem 'sdoc',                 '0.4.0', group: :doc
  
  group :development, :test do
    gem 'sqlite3',     '1.3.9'
    gem 'byebug',      '3.4.0'
    gem 'web-console', '2.0.0.beta3'
    gem 'spring',      '1.1.3'
  end
  
  group :test do
    gem 'minitest-reporters', '1.0.5'
    gem 'mini_backtrace',     '0.1.3'
    gem 'guard-minitest',     '2.3.1'
  end
  
  group :production do
    gem 'pg',             '0.17.1'
    gem 'rails_12factor', '0.0.2'
    gem 'unicorn',        '4.8.3'
  end
  </code></pre>