简体   繁体   English

Rails start上的Ruby / PgSQL错误:无法加载此类文件-pg_ext(LoadError)

[英]Ruby/PgSQL error on Rails start : cannot load such file — pg_ext (LoadError)

I'm new to Ruby (coming from a Java background) and was given access to a RoR project from a Git repository. 我是Ruby的新手(来自Java背景),可以从Git存储库访问RoR项目。 I was able to get Ruby built with rbenv and Postgres installed via homebrew, installed the "pg" gem using the correct flags. 我能够通过自制软件安装使用rbenv和Postgres构建的Ruby,并使用正确的标志安装“ pg” gem。 Any ways I did "bundle install" on the project and it created a bundle, when I went to start the server:... any help will be definitely appreciated! 当我启动服务器时,以任何方式在项目上“捆绑安装”并创建了捆绑:...任何帮助将不胜感激!

$ 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'

Issue also appears in Fedora 17. 问题也出现在Fedora 17中。

Uninstall "pg" gem: 卸载“ pg” gem:

gem uninstall pg

Run bundle (assuming Gemfile contains "pg" gem): 运行包(假设Gemfile包含“ pg” gem):

bundle

Add the pg gem to your Gemfile . pg gem添加到您的Gemfile Then run: 然后运行:

bundle install
bundle update

I'm curious if you installed the pg gem before or after installing postgres via brew? 我很好奇您是在通过brew安装postgres之前还是之后安装了pg gem?

If pg was installed before you installed Postgres via brew, you may need to remove it and install it again so that it's compiled against your current version of Postgres. 如果pg是在通过brew安装Postgres之前安装的,则可能需要将其删除并重新安装,以便针对您当前的Postgres版本进行编译。

Side note: postgresapp is a much better alternative to installing postgres via homebrew: http://postgresapp.com/ 旁注:postgresapp是通过自制程序安装postgres的更好替代方法: http : //postgresapp.com/

I've already installed the pg gem list pg 我已经安装了pg gem list pg

I also encountered this problem and I made it work. 我也遇到了这个问题,并使它起作用。 First, you run the command: $ gem install pg --pre 首先,运行命令:$ gem install pg --pre
Successfully installed pg-0.21.0-x64-mingw32 成功安装pg-0.21.0-x64-mingw32

Next, you update your Gemfile: gem 'pg', '~> 0.21.0'. 接下来,您更新Gemfile:gem'pg','〜> 0.21.0'。 That's it. 而已。

My rubygems environment are as follow: 我的rubygems环境如下:

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/

If during the installation of the gem the pq installation is not in path so it could not be found by the gem. 如果在gem的安装过程中pq安装不在路径中,则gem找不到它。 Than the gem would not work correct. 比宝石无法正常工作。

  • Check the path (try to start psql from commandline). 检查路径(尝试psql启动psql )。
  • uninstall the pg-gem: gem unistall pg 卸载pg-gem: gem unistall pg
  • and reinstall it: bundle install or gem install pg 并重新安装: bundle installgem install pg

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

相关问题 Rails/Ruby/Postgres - LoadError 无法加载此类文件 -- pg_ext - Rails/Ruby/Postgres - LoadError cannot load such file -- pg_ext Redmine / Ruby / Rails / Postgresql - 无法加载此类文件 - pg_ext - Redmine/Ruby/Rails/Postgresql - cannot load such file — pg_ext 在Ruby on Rails上配置时出错-Windows上的pg_ext(LoadError) - Error while configuring Ruby on Rails - pg_ext (LoadError) on Windows 无法加载pg_ext文件 - Cannot load pg_ext file kernel_require.rb:15:in `require': 无法加载此类文件 -- 3.0/pg_ext (LoadError) - kernel_require.rb:15:in `require': cannot load such file -- 3.0/pg_ext (LoadError) Active_support / dependencies.rb:247`require':无法加载此类文件 - 2.1 / pg_ext(LoadError) - Active_support/dependencies.rb:247 `require': cannot load such file — 2.1/pg_ext (LoadError) Ruby错误&#39;require&#39;:无法加载此类文件-bcrypt_ext(LoadError) - Ruby Error `require': cannot load such file — bcrypt_ext (LoadError) Ruby on Rails:错误“require”:无法加载此类文件——bundler/setup (LoadError) - Ruby on Rails: Error `require': cannot load such file -- bundler/setup (LoadError) Ruby错误:无法加载此类文件--wdm(LoadError) - Ruby error: cannot load such file — wdm (LoadError) heroku pg:psql错误:无法加载此类文件-dl / import(LoadError) - heroku pg:psql error: cannot load such file — dl/import (LoadError)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM