'Errno::EACCESS: Permission denied @ dir_s_mkdir

I am pretty new to Ruby.. was following the instructions on TeamTreehouse installing Ruby Development Environment on OSX (Yosemite).

When I got to the step to create my test app. It's failing at the end. With Permission Denied. :( Not sure what I am doing wrong, I did try running gem install debug inspector and the bundle exec spring binstubb all and they both fail.

[]rails new testapp
      create  
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/assets/images/.keep
      create  app/mailers/.keep
      create  app/models/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/bundle
      create  bin/rails
      create  bin/rake
      create  bin/setup
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/secrets.yml
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/assets.rb
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/cookies_serializer.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  lib
      create  lib/tasks
      create  lib/tasks/.keep
      create  lib/assets
      create  lib/assets/.keep
      create  log
      create  log/.keep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/robots.txt
      create  test/fixtures
      create  test/fixtures/.keep
      create  test/controllers
      create  test/controllers/.keep
      create  test/mailers
      create  test/mailers/.keep
      create  test/models
      create  test/models/.keep
      create  test/helpers
      create  test/helpers/.keep
      create  test/integration
      create  test/integration/.keep
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.keep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.keep
         run  bundle install
Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.2
Installing minitest 5.6.1
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.1
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile 0.6.2
Using nokogiri 1.6.6.2
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.6
Using loofah 2.0.2
Using rails-html-sanitizer 1.0.2
Using actionview 4.2.1
Using rack 1.6.1
Using rack-test 0.6.3
Using actionpack 4.2.1
Using globalid 0.3.5
Using activejob 4.2.1
Using mime-types 2.5
Using mail 2.6.3
Using actionmailer 4.2.1
Using activemodel 4.2.1
Using arel 6.0.0
Using activerecord 4.2.1

Errno::EACCES: Permission denied @ dir_s_mkdir - /Users/jeremy/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/debug_inspector-0.0.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
rbenv: spring: command not found

The `spring' command exists in these Ruby versions:
  2.2.2


Solution 1:[1]

Try sudo chown -R jeremy $HOME/.rbenv -- it looks like you have a permissions issue. In the future, only run rbenv as yourself, e.g. no sudo.

Solution 2:[2]

refer to this github issue, https://github.com/bundler/bundler/issues/4590, you might need to remove the ~/.bundle sudo mv ~/.bundle /tmp then try to create the application again

Solution 3:[3]

I was having a similar issue. I couldn't even get the rails new to run. In that case you should use $ ~/ chmod -R 0755 tpm to give the permission necessary to create a file in the folder, which worked fine for me.

I found this solution on a comment over here by @Abhi. I'm putting here because gives more visibility, since the original comment could pass unnotice by its size (which happened to me) and this question popped more to me when I was researching.

Solution 4:[4]

If you looked here and the answer above didn't help you, then maybe you just forgot to add

sudo

before your

gem install

Solution 5:[5]

I know for most of us this above solution must have worked but for me non of them worked as I did not have .rbenv or .asdf file in my PC due to restricted internet access.

So I have installed pods as

sudo pod install --allow-root

and after that once the workspace is created I have went to Get Info and added my user there with read and write permissions and repeated same steps for pod project file.enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 hd1
Solution 2 Mohamed Gaber
Solution 3 Gabriel
Solution 4 IlyaKokorev
Solution 5 Iva