0

Completely new to Rails. I spent hours yesterday banging my head against a brick wall trying to install everything properly on my Mac. Finally, I thought I'd got it working, so I started trying to work through this tutorial: http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/

All goes well until about the 4-minute mark, when I type in the given instruction at the command line and get this error message.

> rails g
/Library/Ruby/Gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:199: warning: Insecure world writable dir /Library/Ruby/Gems/1.8 in PATH, mode 040777
gem install minitest
/Library/Ruby/Gems/1.8/gems/turn-0.9.6/lib/turn/minitest.rb:9:in `require': no such file to load -- minitest/unit (LoadError)
    from /Library/Ruby/Gems/1.8/gems/turn-0.9.6/lib/turn/minitest.rb:9
    from /Library/Ruby/Gems/1.8/gems/turn-0.9.6/lib/turn.rb:13:in `require'
    from /Library/Ruby/Gems/1.8/gems/turn-0.9.6/lib/turn.rb:13
    from /Library/Ruby/Gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `each'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `each'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.2.1/lib/bundler.rb:128:in `require'
    from /Applications/MAMP/htdocs/railstest/tasks/config/application.rb:13
    from /Library/Ruby/Gems/1.8/gems/railties-3.2.8/lib/rails/commands.rb:24:in `require'
    from /Library/Ruby/Gems/1.8/gems/railties-3.2.8/lib/rails/commands.rb:24
    from script/rails:6:in `require'
    from script/rails:6

I've seen some other posts on here with similar problems, which suggest that this has something to do with file permisisons. I still can't get it to work though even after fiddling with the permissions. The permissions are:

/Library:               rwxr-xr-x
/Library/Ruby:          rwxr-xr-x 
/Library/Ruby/Gems:     rwxr-xr-x
/Library/Ruby/Gems/1.8: rwxrwxrwx

Trying to chmod on Gems/1.8 gives me an error message: "Unable to change file mode on /Library/Ruby/Gems/1.8: Operation not permitted"

So what do I need to do?

I'm running Mac OS 10.7.5, and I have XCode 4.5.1, with the command line tools installed too, if any of that matters.

GMA
  • 5,816
  • 6
  • 51
  • 80

2 Answers2

1

I can't admit to being a Rails expert, but strictly from the UNIX side of things, the 1.8 directory is globally writeable. The rwxrwxrwx portion means that the owner, group, and others can read (r), write (w), and execute (x) any file in that directory. So, I can't guarantee this will work, as there could be a more deeply-rooted issue at play here, but try entering sudo chmod og-w /Library/Ruby/Gems/1.8. This will take away the ability for the "group" and "others" users to write to the directory; accordingly, it will no longer be "world writable", and the permissions should thus show rwxr-xr-x. Also, if you didn't enter sudo before trying chmod previously, that's likely what gave you the error about not being able to change the permissions, since you're trying to change permissions for a system directory. Sorry if I'm coming across as pedantic; I just want to make sure that others who may come across this with possibly less background will understand as well.

If this doesn't work, there are some other solutions that may work from this question. If nothing else, per one of the answers given there, I do recommend using rvm, as it leaves your system copy that comes with OS X intact, which will also prevent any possible breakage from a system update.

Lastly, check out this site if you already haven't. It's the full text of this book made available for free by the author himself. I'm not much past the installation phase myself, but by following those instructions I found it pretty painless.

Community
  • 1
  • 1
  • Thanks! To cut a long story short, I opened up my laptop this morning to find that the steps are described were giving me a completely different set of error messages. Probably something I did, but I've completely lost track of all the tweaks and install/uninstall/reinstalls I've made. Eventually to fix it I uninstalled everything with `rvm implode`, then followed the steps in that book you linked (which looks very good by the way) and it seems to all be working now. Finally!! Cheers – GMA Oct 28 '12 at 13:30
0

I don't think that warning actually has anything to do with the problem you're having. The rails executable doesn't recognize the command generator, because the correct command is generate.

You could also type rails g as a shortcut.

Brandan
  • 14,735
  • 3
  • 56
  • 71
  • Oops, I realise what I've done here. I tried rails g and rails generate originally but they didn't work. Then I typed the wrong thing before copying and pasting in here! rails g gives me: /Library/Ruby/Gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:199: warning: Insecure world writable dir /Library/Ruby/Gems/1.8 in PATH, mode 040777 gem install minitest /Library/Ruby/Gems/1.8/gems/turn-0.9.6/lib/turn/minitest.rb:9:in `require': no such file to load -- minitest/unit (LoadError). Have edited the original question. – GMA Oct 27 '12 at 13:23