Todd
Todd

Reputation: 1822

Project folders and gems for Rails 3

I am new to Rails and have been trying to setup up my Mac to handle some development. I am currently in a project folder and trying to install a Gem and get this error:

*bash-3.2$ gem install pg                             
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.*

It appears its trying to install this to the 1.8 directory. I would like all gems to be installed only for this project and not for everything.

Here is my folder structure for Rails projects.

Rails Projects:
 Project 1:
 Project 2:

How do I correct the issue with the gem installation so it only goes into a specific folder. This goes for the ruby version as well.

Thanks for the help.

Upvotes: 0

Views: 237

Answers (2)

Sean Hill
Sean Hill

Reputation: 15056

Without installing RVM, which you should be doing anyway, you just need to use sudo to install the gems. By default, your user account does not have write permissions to the default gem installation directory.

sudo gem install pg

Upvotes: 1

pduey
pduey

Reputation: 3786

You need to be using RVM, the Ruby Version Manager, found at http://beginrescueend.com/

I assume you already have installed XCode and Macports (or something like it).

  1. Install rails using "gem install rails"
  2. Use "rails new new-project" to setup your new rails project
  3. Use bundler to add any new gems to your project http://gembundler.com/

Finally, if you want to use MySQL, there is a trick to getting the mysql2 gem configured properly on Mac. That is covered in this stackoverflow post.

Upvotes: 1

Related Questions