简体   繁体   English

Ruby on Rails-尝试启动Rails Server时发生Postgres错误

[英]Ruby on Rails - Postgres error when trying to start Rails Server

I am using: 我在用:

  • ruby 2.2.1 红宝石2.2.1
  • rails 4.6.2 栏杆4.6.2
  • homebrew for postgres installation 自制Postgres安装
  • rbenv 班本
  • osx el capitan 10.11.5 osx el capitan 10.11.5

Here is the error I receive when running: rails s 这是我在运行时收到的错误:rails

/usr/local/lib/ruby/gems/2.2.0/gems/pg-0.18.4/lib/pg.rb:4:in `require': dlopen(/usr/local/lib/ruby/gems/2.2.0/gems/pg-0.18.4/lib/pg_ext.bundle, 9): Library not loaded: /usr/local/lib/libruby.2.2.0.dylib (LoadError)
  Referenced from: /usr/local/lib/ruby/gems/2.2.0/gems/pg-0.18.4/lib/pg_ext.bundle
  Reason: image not found - /usr/local/lib/ruby/gems/2.2.0/gems/pg-0.18.4/lib/pg_ext.bundle
    from /usr/local/lib/ruby/gems/2.2.0/gems/pg-0.18.4/lib/pg.rb:4:in `<top (required)>'
    from /usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:86:in `require'
    from /usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:86:in `block (2 levels) in require'
    from /usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:81:in `each'
    from /usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:81:in `block in require'
    from /usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:70:in `each'
    from /usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:70:in `require'
    from /usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler.rb:102:in `require'
    from /Users/jeffr/Dropbox/DevelopmentPC/rails4/myapp/config/application.rb:7:in `<top (required)>'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:78:in `require'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:78:in `block in server'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in `server'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
    from /Users/jeffr/Dropbox/DevelopmentPC/rails4/myapp/bin/rails:9:in `require'
    from /Users/jeffr/Dropbox/DevelopmentPC/rails4/myapp/bin/rails:9:in `<top (required)>'
    from /usr/local/lib/ruby/gems/2.2.0/gems/spring-1.7.1/lib/spring/client/rails.rb:28:in `load'
    from /usr/local/lib/ruby/gems/2.2.0/gems/spring-1.7.1/lib/spring/client/rails.rb:28:in `call'
    from /usr/local/lib/ruby/gems/2.2.0/gems/spring-1.7.1/lib/spring/client/command.rb:7:in `call'
    from /usr/local/lib/ruby/gems/2.2.0/gems/spring-1.7.1/lib/spring/client.rb:30:in `run'
    from /usr/local/lib/ruby/gems/2.2.0/gems/spring-1.7.1/bin/spring:49:in `<top (required)>'
    from /usr/local/lib/ruby/gems/2.2.0/gems/spring-1.7.1/lib/spring/binstub.rb:11:in `load'
    from /usr/local/lib/ruby/gems/2.2.0/gems/spring-1.7.1/lib/spring/binstub.rb:11:in `<top (required)>'
    from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/jeffr/Dropbox/DevelopmentPC/rails4/myapp/bin/spring:13:in `<top (required)>'
    from bin/rails:3:in `load'
    from bin/rails:3:in `<main>'

I ended up starting over with the entire rbenv, ruby and rails installation. 我最后开始了整个rbenv,ruby和rails的安装。

brew update

brew uninstall --force ruby

brew uninstall --force openssl

brew install openssl

brew link openssl --force

brew uninstall --force ruby-build

Then I followed this guide and it worked: https://gorails.com/setup/osx/10.11-el-capitan 然后,我按照该指南进行了操作: https : //gorails.com/setup/osx/10.11-el-capitan

Except for the libxml2 error while installing rails: 除安装rails时出现libxml2错误外:

libxml2 is missing.  Please locate mkmf.log to investigate how it is failing.

I fixed that by running 我通过跑步解决了

$  gem install nokogiri -- --use-system-libraries  [--with-xml2-config=/path/to/xml2-config]  [--with-xslt-config=/path/to/xslt-config]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM