views:

55

answers:

3

I'm using Ubuntu 10.04. In the terminal, when I go to my app and type (without using the "ruby" in front):

script/generate controller recipes

I get a "Permission denied" error. When I use this however:

ruby script/generate controller recipes

everything works as expected. Is there something I have to do to Ubuntu to make the prepended "ruby" unnecessary when I'm trying to generate controllers (i.e. just using "script/generate controller recipes" should just work)?

+6  A: 

chmod 755 script/generate

petraszd
Thank you petra!
sjsc
To clarify why this works: Permission is denied when you try to execute script/generate because the user does not have the execute permission set on the file. Running `chmod 755 script/generate` enables the user's execute permission on the file. In the case of `ruby script/generate ...` there needs to be only read permission, as the file is being parsed, instead of executed.
Jamie Wong
any idea why the problem happens in the first place? I can only guess that sjsc installed rails from a local version of the gem, or from a USB stick
stephenmurdoch
+2  A: 

wow, that's strange,

congrats on switching to linux.

how did you install Ruby? Did you do it from the synaptic package manager? Did you run sudo aptitude install ruby or something like that?

whatever you have done, you might be best installing RubyVersionManager (RVM) - it's really easy - there's a railscast on how it works here: http://railscasts.com/episodes/200-rails-3-beta-and-rvm

I've never had or heard of the problem you've got there

stephenmurdoch
Thanks for the tip stephen! I might've missed some steps. Thank you so much.
sjsc
no problem, it looks like the other answers explain why it's happening, i.e. a lack of permissions on the script command. Hopefully you will not have too much trouble installing RVM, if you do decide to go that way - I find that it makes me way more productive and so do a lot of other *nix ruby developers. I think there is something similar on windows called Pik. But you won't need that now that you are on Ubuntu. Good luck
stephenmurdoch
+4  A: 

Type

ls -la

in the script folder to see the permissions of the generated script.

It probably doesn't have the execute permission (x).

I recommend reinstalling rails.

robertokl
thank you robertokl!
sjsc