"How to fix When installing bundle I receive errors in Gemfile pg "

"How to fix When installing bundle I receive errors in Gemfile pg "

我正在尝试通过 Debian

为我的 rails 应用程序做 bundle install

尝试使用 gem install pg --forcegem install pg -v '1.1.4' --source 'https://rubygems.org/'

尝试使用 sudo apt-get install libpq-dev

Err:1 http://deb.debian.org/debian stretch/main amd64 libpq5 amd64 9.6.11-0+deb9u1404 未找到 [IP: 2a04:4e42:1::204 80] Err:2 http://deb.debian.org/debian stretch/main amd64 libpq-dev amd64 9.6.11-0+deb9u1 404 未找到 [IP: 2a04:4e42:1::204 80] E: 无法获取 http://deb.debian.org/debian/pool/main/p/postgresql-9.6/libpq5_9.6.11-0+deb9u1_amd64.deb 404 未找到 [IP: 2a04:4e42:1::204 80] E: 获取失败 http://deb.debian.org/debian/pool/main/p/postgresql-9.6/libpq-dev_9.6.11-0+deb9u1_amd64.deb 404 未找到 [IP: 2a04:4e42:1::204 80] E: 无法获取一些档案,也许 运行 apt-get update 或尝试 --fix-missing?

saishbhende24@DESKTOP-ELUO53H:/mnt/c/saishrails/r35.1/r5.1$ gem install pg -v '1.1.4' --source 'https://rubygems.org/' 构建本机扩展。这可能需要一段时间... /home/saishbhende24/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/rubygems/ext/builder.rb:76:警告:不安全的世界可写目录 /home/saishbhende24/.[=43= .6.1/bin 在路径中,模式 040777 错误:安装 pg 时出错: 错误:无法构建 gem 本机扩展。

saishbhende24@DESKTOP-ELUO53H:/mnt/c/saishrails/r35.1/r5.1$ gem install pg Building native extensions. This could take a while...

/home/saishbhende24/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/rubygems/ext/builder.rb:76: warning: Insecure world writable dir /home/saishbhende24/.rvm/gems/ruby-2.6.1/bin in PATH, mode 040777 ERROR: Error installing pg: ERROR: Failed to build gem native extension.

current directory: /home/saishbhende24/.rvm/gems/ruby-2.6.1/gems/pg-1.1.4/ext

/home/saishbhende24/.rvm/rubies/ruby-2.6.1/bin/ruby -I /home/saishbhende24/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0 -r ./siteconf20190805-760-x2yfpd.rb 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.

Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/home/saishbhende24/.rvm/rubies/ruby-2.6.1/bin/$(RUBY_BASE_NAME) --with-pg --without-pg --enable-windows-cross --disable-windows-cross --with-pg-config --without-pg-config --with-pg_config --without-pg_config --with-pg-dir --without-pg-dir --with-pg-include --without-pg-include=${pg-dir}/include --with-pg-lib --without-pg-lib=${pg-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/home/saishbhende24/.rvm/gems/ruby-2.6.1/extensions/x86_64-linux/2.6.0/pg-1.1.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/saishbhende24/.rvm/gems/ruby-2.6.1/gems/pg-1.1.4 for inspection. Results logged to /home/saishbhende24/.rvm/gems/ruby-2.6.1/extensions/x86_64-linux/2.6.0/pg-1.1.4/gem_make.out

预期结果是安装包成功。

您丢失了一个包裹。 pg gem 取决于 libpq-dev

尝试

sudo apt-get update

然后

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

pg 已安装,出于某种原因我有

./channels

必须//= require tree才能抓取js文件夹中的所有文件。

这个命令解决了我的问题: sudo apt-get install postgresql postgresql-contrib libpq-dev 然后 bundle