8

我是 Ruby 新手(来自 Java 背景),并且可以从 Git 存储库访问 RoR 项目。我能够通过自制软件安装 rbenv 和 Postgres 构建 Ruby,使用正确的标志安装“pg”gem。当我去启动服务器时,我在项目上“捆绑安装”并创建了一个捆绑包的任何方式:...任何帮助都将不胜感激!

$ rails s
/Users//Projects/The /vendor/bundle/gems/pg-0.14.1/lib/pg.rb:4:in require': cannot load such file -- pg_ext (LoadError)

from /Users//Projects/The Usic/vendor/bundle/gems/pg-0.14.1/lib/pg.rb:4:in <top (required)>'

from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:72:in require'

from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:72:in block (2 levels) in require'

from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:70:in each'

from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:70:in block in require'

from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:59:in each'

from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:59:in require'

from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler.rb:132:in require'
4

5 回答 5

7

pg gem 添加到您的Gemfile. 然后运行:

bundle install
bundle update
于 2014-09-19T10:06:16.940 回答
7

问题也出现在 Fedora 17 中。

卸载“pg”gem:

gem uninstall pg

运行包(假设 Gemfile 包含“pg”gem):

bundle
于 2013-03-04T15:37:08.810 回答
2

如果在安装 gem 期间 pq 安装不在路径中,则 gem 无法找到它。比宝石无法正常工作。

  • 检查路径(尝试psql从命令行开始)。
  • 卸载 pg-gem:gem unistall pg
  • 并重新安装它:bundle installgem install pg
于 2016-07-21T07:14:08.157 回答
1

我很好奇您是在通过 brew 安装 postgres 之前还是之后安装了 pg gem?

如果在您通过 brew 安装 Postgres 之前安装了 pg,您可能需要将其删除并重新安装,以便针对您当前版本的 Postgres 进行编译。

旁注:postgresapp 是通过自制软件安装 postgres 的更好选择:http: //postgresapp.com/

于 2013-03-01T07:47:07.197 回答
1

我已经安装了 pg gem list pg

我也遇到了这个问题,并且成功了。首先,运行命令: $ gem install pg --pre
成功安装 pg-0.21.0-x64-mingw32

接下来,更新您的 Gemfile:gem 'pg', '~> 0.21.0'。而已。

我的 ruby​​gems 环境如下:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.6.12
  - RUBY VERSION: 2.3.3 (2016-11-21 patchlevel 222) [x64-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby23-x64/lib/ruby/gems/2.3.0
  - USER INSTALLATION DIRECTORY: C:/Users/armano/.gem/ruby/2.3.0
  - RUBY EXECUTABLE: C:/Ruby23-x64/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/Ruby23-x64/bin
  - SPEC CACHE DIRECTORY: C:/Users/armano/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
  - RUBYGEMS PLATFORMS:
    - ruby
    - x64-mingw32
  - GEM PATHS:
     - C:/Ruby23-x64/lib/ruby/gems/2.3.0
     - C:/Users/armano/.gem/ruby/2.3.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-ri --no-rdoc"
  - REMOTE SOURCES:
     - https://rubygems.org/
于 2017-07-04T14:01:20.570 回答