安装Ruby on Rails但是当我尝试运行Rails Sever时它不加载WEBr​​ick?

时间:2011-03-19 05:30:37

标签: ruby-on-rails webrick

我今天在Mac上安装了Ruby on Rails以及Gems和MYsql。我正在尝试按照lynda.com教程,我遇到了一堵砖墙。当我尝试运行rails服务器时,由于某种原因它不会加载WEBr​​ick。这是我得到的错误:

/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

关于我能做什么的任何想法?请帮忙 - 我被卡住了!

我做了rails -v,我在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

顺便说一句:我试图去做sudo chmod go-w /usr/local/bin,但这并没有解决任何问题。 我这样做的原因是因为:warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777

5 个答案:

答案 0 :(得分:1)

我强烈建议您使用rvm安装ruby并再试一次:

OS X附带的默认ruby存在许多问题。当您安装RVM时,您可以轻松地安装ruby。

请务必仔细阅读安装说明,尤其是有关在.bashrc中插入一行的最后一点。

答案 1 :(得分:1)

已回答here

答案 2 :(得分:1)

忘记warning: Insecure world writable dir错误,这只是来自Bundler的警告,与阻止Rails启动的错误无关。

该错误是由于Mysql2 gem无法正确加载。我有同样的问题。基本上你需要gem的mysql源文件才能正确编译。我通过安装Homebrew,然后使用Homebrew安装mysql,然后再次运行Bundle install解决了这个问题。

试试这个:

  1. 安装Homebrew
  2. 在终端中使用hombrew:brew install mysql安装mysql
  3. 删除Rails应用内的Gemfile.lock文件
  4. 再次运行'bundle install`
  5. 尝试使用此命令启动Rails:bundle exec rails server
  6. 我知道我参加这个派对有点晚了,但我希望这可以帮助别人。

答案 3 :(得分:0)

您必须设置Gemfile并运行bundle install

答案 4 :(得分:-1)

您的gems目录似乎存在权限问题。尝试用以下方法解决这个问题:

sudo find /Library/Ruby/Gems/1.8/gems/ -type d -exec chmod 755 '{}' +