安装了 Ruby on Rails,但是当我尝试运行 Rails Sever 时,它没有加载 WEBrick? [英] Installed Ruby on Rails but when I try to run Rails Sever it doesn't load WEBrick?
问题描述
我今天在我的 Mac 上安装了 Ruby on Rails 以及 Gems 和 MYsql.我正在尝试按照 lynda.com 教程进行操作,但遇到了砖墙.当我尝试运行 rails 服务器时,由于某种原因它不会加载 WEBrick.这是我得到的错误:
<前>/Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/script_rails_loader.rb:11: 警告:不安全的世界可写目录/usr/local in PATH,模式 040777/Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:136: 警告:不安全的世界可写目录/usr/local in PATH,模式 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): 库未加载: libmysqlclient.18.dylib (LoadError)引用自:/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle原因:找不到图像 -/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle来自/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2.rb:7来自/Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'来自/Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'来自/Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'来自/Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `require'来自/Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'来自/Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'来自/Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'来自/Users/nutanpatel/Sites/simple_cms/config/application.rb:7来自/Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/commands.rb:28:in `require'来自/Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/commands.rb:28来自/Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/commands.rb:27:in `tap'来自/Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/commands.rb:27来自 script/rails:6:in `require'来自脚本/导轨:6对我能做什么有什么想法吗?请帮忙 - 我被卡住了!
我做了 rails -v 并且我在 3.0.5 上:
<前>导轨 -v/Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/script_rails_loader.rb:11: 警告:不安全的世界可写目录/usr/local in PATH,模式 040777/Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:136: 警告:不安全的世界可写目录/usr/local in PATH,模式 040777导轨 3.0.5顺便说一句:我试着去做这个 sudo chmod go-w/usr/local/bin
但这并没有解决任何问题.我这样做的原因是:警告:不安全的世界可写目录/usr/local/bin in PATH, 模式 040777
忘记 warning: Insecure world writable dir
错误,这只是来自 Bundler 的警告,与错误无关阻止 Rails 启动.
该错误是由于 Mysql2 gem 未正确加载所致.我有同样的问题.基本上,您需要 gem 的 mysql 源文件才能正确编译.我通过安装 Homebrew,然后用 Homebrew 安装 mysql,然后再次运行 Bundle install
来解决它.
试试这个:
- 安装自制软件
- 使用 hombrew 安装 mysql:
brew install mysql
在终端中 - 删除 Rails 应用中的
Gemfile.lock
文件 - 再次运行捆绑安装"
- 尝试使用以下命令启动 Rails:
bundle exec rails server
我知道我参加这个聚会有点晚了,但我希望这可以帮助其他人.
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
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:
- install Homebrew
- install mysql with hombrew:
brew install mysql
in a terminal - delete the
Gemfile.lock
file inside your Rails app - run 'bundle install` again
- 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.
这篇关于安装了 Ruby on Rails,但是当我尝试运行 Rails Sever 时,它没有加载 WEBrick?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!