gpt4 book ai didi

ruby-on-rails-3 - Ruby on Rails + PostgreSQL 应用程序无法在 AWS EC2 上启动。错误是 : "cannot load such file -- pg_ext (LoadError)"

转载 作者:行者123 更新时间:2023-11-29 11:50:45 24 4
gpt4 key购买 nike

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

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,绑定(bind)将无法工作到端口 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 是正确的。任何线索都会有所帮助。

最佳答案

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

gem install pg

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

关于ruby-on-rails-3 - Ruby on Rails + PostgreSQL 应用程序无法在 AWS EC2 上启动。错误是 : "cannot load such file -- pg_ext (LoadError)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12432418/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com