3

我首先安装所有这些依赖项:

sudo yum install ruby19 ruby19-devel gem rubygems19-devel make gcc postgresql9 postgresql9-devel postgresql9-server

然后我切换到root用户并运行

bundle install

我收到绿色成功消息:

Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

但是,当我 cd 到目录并运行时

rails s -p80

我得到了所有这些并且它无法启动(我仍然是 root,因为如果我不是 root,绑定将无法工作到端口 80):

/usr/local/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- pg_ext (LoadError)
    from /usr/local/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
    from /usr/local/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /usr/local/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from /usr/local/share/gems/gems/pg-0.14.0/lib/pg.rb:4:in `<top (required)>'
    from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:68:in `require'
    from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:66:in `each'
    from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:66:in `block in require'
    from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:55:in `each'
    from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:55:in `require'
    from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler.rb:128:in `require'
    from /home/user/TransForm/config/application.rb:7:in `<top (required)>'
    from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
    from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:53:in `block in <top (required)>'
    from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
    from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

也许有一种简单的方法可以从一开始就正确部署它,而不是搞乱错误的废话?我需要 PostgreSQL。除了这个 AWS EC2 实例之外,这个应用程序在任何地方都可以使用,所以我知道我的 Gemfile 是正确的。任何线索都会有所帮助。

4

2 回答 2

1

打开irb并输入require "pg"它是否有效?如果没有,则检查目录pg_ext中是否存在/usr/local/share/gems/gems/pg-0.14.0/lib/。您可以手动安装 postgresql gem,使用

gem install pg

如果这仍然不起作用,请确保您使用的是最新版本的 ruby​​ 和最新版本的 ruby​​gems 使用gem environment命令。如果是旧版本,您可以使用rvm安装最新版本

于 2012-09-20T02:43:17.377 回答
0
        use gem pg 
            than 
             bundle install
             bundle update
               please not use any version of pg 
       I face this error and solved by this
于 2014-09-19T09:39:45.053 回答