2

I installed Ruby on Rails on my mac today along with Gems and MYsql. I'm trying to follow the lynda.com tutorial and I've run into a brick wall. When I try to run the rails server it doesnt load WEBrick for some reason. This is the error I get:

/Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/script_rails_loader.rb:11: warning: Insecure world writable dir /usr/local in PATH, mode 040777
/Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:136: warning: Insecure world writable dir /usr/local in PATH, mode 040777
/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
  Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
  Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
    from /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2.rb:7
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
    from /Users/nutanpatel/Sites/simple_cms/config/application.rb:7
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/commands.rb:28:in `require'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/commands.rb:28
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/commands.rb:27:in `tap'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/commands.rb:27
    from script/rails:6:in `require'
    from script/rails:6

Any ideas on what I could do? Please help - I'm stuck!

I did rails -v and I'm on 3.0.5:

rails -v
/Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/script_rails_loader.rb:11: warning: Insecure world writable dir /usr/local in PATH, mode 040777
/Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:136: warning: Insecure world writable dir /usr/local in PATH, mode 040777
Rails 3.0.5

BTW: I tried to go and do this sudo chmod go-w /usr/local/bin but this did not resolve anything. Reason I did this was because of: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777

Community
  • 1
  • 1
newt
  • 21
  • 1
  • 2
  • Try one or all of these: http://freddyandersen.wordpress.com/2010/10/03/mysql-5-5-snow-leopard-and-rails/ and http://stackoverflow.com/questions/4512362/rails-server-fails-to-start-with-mysql2-using-rvm-ruby-1-9-2-p0-on-osx-10-6-5 and http://pinoytech.org/question/5360152/setting-up-mysql-with-the-latest-version-of-ruby-on-rails – Zabba Mar 20 '11 at 12:26
  • Did you ever resolve this? If so, how? – Chance Mar 21 '11 at 16:21

5 Answers5

1

Forget the warning: Insecure world writable dir error, that's just a warning from Bundler and has nothing to do with the error that is keeping Rails from starting.

That error is due to the Mysql2 gem not loading properly. I had the same problem. Basically you need the mysql source files for the gem to compile properly. I solved it by installing Homebrew, then installing mysql with Homebrew, then running Bundle install again.

Try this:

  1. install Homebrew
  2. install mysql with hombrew: brew install mysql in a terminal
  3. delete the Gemfile.lock file inside your Rails app
  4. run 'bundle install` again
  5. try starting Rails with this command: bundle exec rails server

I know I'm a little late to this party, but I'm hoping this might help someone else.

kakubei
  • 5,321
  • 4
  • 44
  • 66
1

I strongly urge you to use rvm to install ruby and try again:

There are a number of issues with the default ruby that ships with OS X. When you install RVM, you can easily get a clean installation of ruby.

Make sure to read the install instructions carefully, especially the last bit about inserting a line into your .bashrc.

bowsersenior
  • 12,524
  • 2
  • 46
  • 52
1

This was answered here

Community
  • 1
  • 1
Kyle Macey
  • 8,074
  • 2
  • 38
  • 78
0

You have to set your Gemfile and run bundle install

Sergey Kishenin
  • 5,099
  • 3
  • 30
  • 50
  • I'm kind of lost on what you mean by set Gemfile. I did run bundle install and this is what it said: "Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed." I tried to run rails server again and got the same error :( – newt Mar 19 '11 at 05:59
  • try to follow this giude http://answerleaks.com/question/it/2170697/bundler-isnt-loading-gems – Sergey Kishenin Mar 19 '11 at 06:33
-1

You do seem to have permissions issues with your gems directory. Try resolving that with:

sudo find /Library/Ruby/Gems/1.8/gems/ -type d -exec chmod 755 '{}' +
nickgrim
  • 5,387
  • 1
  • 22
  • 28
  • i did this but I still get the same error. "Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle" – newt Mar 19 '11 at 17:28