简体   繁体   English

rails中的活动记录postgresql适配器错误

[英]active record postgresql adapter error in rails

Here's my problem. 这是我的问题。 I am trying to create a blog. 我正在尝试创建一个博客。 I run 'rails new blog'. 我运行'rails new blog'。 Everythign is OK until I try 'rake db:create'. Everythign没问题,直到我尝试'rake db:create'。 It returns an error: 它返回一个错误:

rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adap
ter` (pg is not part of the bundle. Add it to Gemfile.)

When I try to install pg adapter I get this: 当我尝试安装pg适配器时,我得到了这个:

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing activerecord-postgresql-adapter:
    ERROR: Failed to build gem native extension.

F:/Ruby200-x64/bin/ruby.exe extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
 checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may

need configuration options. 需要配置选项。

My gemfile: 我的gemfile:

  source 'https://rubygems.org'

gem 'rails', '3.2.12'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem "pg"

# Gems used only for assets and not required
# in production environments by default.
 group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

Got any idea? 知道吗?

Do you have Postgres installed? 你安装了Postgres吗? If so, make sure that pg_config.exe is in the PATH. 如果是这样,请确保pg_config.exe位于PATH中。 Alternatively use either --with-pg-config or –with-pg-dir key: 或者使用--with-pg-config–with-pg-dir键:

gem install pg --with-pg-config=<path>

See details in https://github.com/ged/ruby-pg/blob/master/README-Windows.rdoc 请参阅https://github.com/ged/ruby-pg/blob/master/README-Windows.rdoc中的详细信息

Uninstall pg gem, and install postgres-pr for windows 卸载pg gem,并为windows安装postgres-pr

Remove from Gemfile: 从Gemfile中删除:

gem "pg"

and put: 并把:

gem "postgres-pr"

and run: 并运行:

bundle install or gem install postgres-pr or however you are installing gems bundle installgem install postgres-pr或者你正在安装gem

You are missing the library for postgresql. 你错过了postgresql的库。 You can install it like this: 你可以像这样安装它:

sudo apt-get install libpq-dev sudo apt-get install libpq-dev

Maybe also take a look at this old question . 也许还要看看这个老问题

I got the same error and I solved by setting correct file permissions to postgresql_adapter.rb 我得到了同样的错误,我通过设置postgresql_adapter.rb正确文件权限解决了

cd [YOUR_ACTIVERECORD_GEM_PATH]/lib/active_record/connection_adapters
chmod 644 postgresql_adapter.rb

Somehow the file permissions of postgresql_adapter.rb were corrupted in my computer... 不知何故, postgresql_adapter.rb的文件权限在我的电脑中被破坏了......

在此输入图像描述

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

相关问题 LoadError:加载“mysql2”Active Record 适配器时出错 [rails 5.2.3] - LoadError: Error loading the 'mysql2' Active Record adapter [rails 5.2.3] 加载“sqlite3”Active Record 适配器时出错,Ruby on Rails 错误 Win10 64bit - Error loading the 'sqlite3' Active Record adapter, Ruby on Rails error Win10 64bit Rails 错误:replace_gem 中的块(2 级):加载“sqlite3”Active Record 适配器时出错 - Rails Error: block (2 levels) in replace_gem': Error loading the 'sqlite3' Active Record adapter 加载“mysql2”活动记录适配器时出错 - Error loading the 'mysql2' Active Record adapter 加载“sqlite3”Active Record 适配器时出错 - Error loading the 'sqlite3' Active Record adapter Bootsnap错误运行轨服务,“无法加载&#39;mysql&#39;Active Record适配器。” - Bootsnap error running rails serve, “Could not load the 'mysql' Active Record adapter.” Rails 5 - LoadError:加载“mysql2”Active Record 适配器时出错。 mysql2 不是捆绑包的一部分 - Rails 5 - LoadError: Error loading the 'mysql2' Active Record adapter. mysql2 is not part of the bundle Windows上的Rails错误:无法加载&#39;active_record / connection_adapters / sqlite3_adapter&#39; - Rails on windows error: Could not load 'active_record/connection_adapters/sqlite3_adapter' Ruby on Rails中的活动记录错误 - active record error in Ruby on rails Rails活动记录名称错误 - Rails Active Record Name Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM