Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am a new Mac user who is starting to learn Ruby on Rails. I have found that I need to use the sudo statement when running commands like

$ sudo rails generate controller home index

But when I do, the files which it generates appear as read-only when I try to edit them in Coda.

I did a Get Info on the file and it appears that the owner is root and the group is staff. alt text

Does my user jesse need to belong to the group staff?

I really just want to be able to edit my files and not screw anything up. If anyone has any guidance for a noob, that would be appreciated.

share|improve this question
I don't think sudo is required for scaffolding and generating, tried w/o sudo ? – Sathya Sep 7 '10 at 2:21
You're observing normal behavior from using sudo. The solution is probably to properly fix whatever problem led you to use sudo. – Gilles Sep 7 '10 at 6:44
@Sathya, I did try running the command without it, it was throwing some permission denied errors – jessegavin Sep 7 '10 at 12:26
up vote 3 down vote accepted

When you create files with sudo, those files are owned by root. You can either:

  1. Use the inspector window (the one in your screenshot) to change the file owner to yourself, or

  2. Run chown -R jesse myProjectDir on the directory you create to change its owner (and its contents' owner) to yourself.

share|improve this answer
Thank you very much that explains it nicely. – jessegavin Sep 7 '10 at 12:25

The group (staff) doesnt have write access either. Youll have to do:

$ sudo chmod a+w {files}

where {files} is a list of the files that you cant write. Note that if you run rails generate again, theres a good chance youll lose +w and have repeat this. Note also that this makes {files} writeable by all users, so if if you let anyone else use your computer, they'll by able to modify {files}.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .