0

First time I install RoR app based on PostgreSQL database and after run the command rails new psql_app -d postgresql I get following problem:

      ...
      create  vendor/assets/javascripts/.gitkeep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.gitkeep
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
         run  bundle install
/Users/adam/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/fileutils.rb:243:in `mkdir': Permission denied - /Users/adam/.gem/specs/rubygems.org%443 (Errno::EACCES)
    from /Users/adam/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/fileutils.rb:243:in `fu_mkdir'
    from /Users/adam/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/fileutils.rb:217:in `block (2 levels) in mkdir_p'
    from /Users/adam/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/fileutils.rb:215:in `reverse_each'
    from /Users/adam/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/fileutils.rb:215:in `block in mkdir_p'
    from /Users/adam/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/fileutils.rb:201:in `each'
    from /Users/adam/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/fileutils.rb:201:in `mkdir_p'
    from /Users/adam/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:125:in `fetch_spec'
    from /Users/adam/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/remote_specification.rb:47:in `_remote_specification'
    from /Users/adam/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/remote_specification.rb:53:in `method_missing'
    from /Users/adam/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/resolver.rb:101:in `block in __dependencies'
    ....

I also tried to re-set up the connection to PostgreSQL database, but without success... still getting this error. When I try to create a new app with MySQL database, I don't get this error.

user984621
  • 46,344
  • 73
  • 224
  • 412

1 Answers1

2

This is bundler not being able to write to your rvm folder. I expect that the reason it works with Mysql is that the appropriate gems are already installed and were probably installed using sudo and now you're trying to run rails new as your current user adam.

You could use sudo rails new psql_app -d postgresql or alternatively you could fix the permissions in your ~/.gem directory. To do this you can probably safely type:

sudo chown -R adam ~/.gem

This should let you install gems without using sudo.

Leonard Garvey
  • 1,517
  • 12
  • 8
  • The most vital of vital things here is, if you've installed RVM into your home directory (as you should) then **DON'T** use sudo to install gems. – Gareth Mar 12 '12 at 13:20
  • I would like to solve that without using sudo in the best way. I tried to set up the permissions by the command you mentioned, but I got the error `Operation not permitted` – user984621 Mar 12 '12 at 13:21
  • Since you've installed gems (or possibly rvm) with the sudo command (or as root) then you need to be root to fix the permissions. You're meant to run ```sudo chown -R adam ~/.gem```. I've edited my answer the reflect this. – Leonard Garvey Mar 12 '12 at 13:28
  • gems, with rvm are located under `~/.rvm` so @user984621 should type `sudo chown -R adam ~/.rvm` – nolith Mar 12 '12 at 13:31
  • I have to admit I've switched to rbenv to avoid the gemset madness! – Leonard Garvey Mar 12 '12 at 13:35