gpt4 book ai didi

ruby-on-rails - pg gem 无法使用 bundle install 安装或根本无法安装

转载 作者:数据小太阳 更新时间:2023-10-29 08:38:42 27 4
gpt4 key购买 nike

我正在尝试安装 pg gem。我完全是 ruby​​ on rails 和编程的初学者。我从昨天开始就试图找出这个错误,并且已经在很多地方寻找解决方案。希望您能够帮助我。谢谢使用 mac 山狮 ruby 2.0.0p247(2013-06-27 修订版 41674)[x86_64-darwin12.3.0]并用于使用 rails 4.0Marcs-MacBook-Pro:smartforce marcboehle$ rails -v在任何来源中都找不到 pg-0.16.0运行 bundle install 以安装缺少的 gem。

我已经试过了:

Marcs-MacBook-Pro:smartforce marcboehle$ bundle install
Fetching gem metadata from http://rubygems.org/..........
Fetching gem metadata from http://rubygems.org/..
Resolving dependencies...
Enter your password to install the bundled RubyGems to your system:
Using rake (10.1.0)
Using i18n (0.6.5)
Using minitest (4.7.5)
Using multi_json (1.7.9)
Using atomic (1.1.13)
Using thread_safe (0.1.2)
Using tzinfo (0.3.37)
Using activesupport (4.0.0)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.0)
Using mime-types (1.24)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.0)
Using activemodel (4.0.0)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.0)
Using activerecord (4.0.0)
Using bundler (1.3.5)
Installing coffee-script-source (1.6.3)
Installing execjs (2.0.0)
Installing coffee-script (2.2.0)
Using thor (0.18.1)
Using railties (4.0.0)
Installing coffee-rails (4.0.0)
Using hike (1.2.3)
Installing jbuilder (1.5.0)
Installing jquery-rails (3.0.4)
Installing json (1.8.0)
Installing pg (0.16.0)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/usr/local/rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconnectionUsedPassword()... yes
checking for PQisthreadsafe()... yes
checking for PQprepare()... yes
checking for PQexecParams()... yes
checking for PQescapeString()... yes
checking for PQescapeStringConn()... yes
checking for PQescapeLiteral()... yes
checking for PQescapeIdentifier()... yes
checking for PQgetCancel()... yes
checking for lo_create()... yes
checking for pg_encoding_to_char()... yes
checking for pg_char_to_encoding()... yes
checking for PQsetClientEncoding()... yes
checking for PQlibVersion()... yes
checking for PQping()... yes
checking for PQsetSingleRowMode()... no
checking for rb_encdb_alias()... yes
checking for rb_enc_alias()... yes
checking for rb_thread_call_without_gvl()... yes
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_fd_select()... yes
checking for rb_w32_wrap_io_handle()... no
checking for PGRES_COPY_BOTH in libpq-fe.h... no
checking for PGRES_SINGLE_TUPLE in libpq-fe.h... no
checking for PG_DIAG_TABLE_NAME in libpq-fe.h... no
checking for struct pgNotify.extra in libpq-fe.h... yes
checking for unistd.h... yes
checking for ruby/st.h... yes
creating extconf.h
creating Makefile

make "DESTDIR="
compiling gvl_wrappers.c
compiling pg.c
pg.c:272:9: warning: implicit declaration of function 'PQlibVersion' is invalid in C99 [-Wimplicit-function-declaration]
return INT2NUM(PQlibVersion());
^
In file included from pg.c:48:
In file included from ./pg.h:17:
In file included from /usr/local/rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby.h:33:
/usr/local/rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/ruby.h:1167:21: note: instantiated from:
# define INT2NUM(v) INT2FIX((int)(v))
^
pg.c:272:9: note: instantiated from:
return INT2NUM(PQlibVersion());
^
pg.c:272:17: note: instantiated from:
return INT2NUM(PQlibVersion());
^
pg.c:375:48: error: use of undeclared identifier 'PQPING_OK'
rb_define_const(rb_mPGconstants, "PQPING_OK", INT2FIX(PQPING_OK));
^
pg.c:375:56: note: instantiated from:
rb_define_const(rb_mPGconstants, "PQPING_OK", INT2FIX(PQPING_OK));
^
pg.c:377:52: error: use of undeclared identifier 'PQPING_REJECT'
rb_define_const(rb_mPGconstants, "PQPING_REJECT", INT2FIX(PQPING_REJECT));
^
pg.c:377:60: note: instantiated from:
rb_define_const(rb_mPGconstants, "PQPING_REJECT", INT2FIX(PQPING_REJECT));
^
pg.c:379:57: error: use of undeclared identifier 'PQPING_NO_RESPONSE'
rb_define_const(rb_mPGconstants, "PQPING_NO_RESPONSE", INT2FIX(PQPING_NO_RESPONSE));
^
pg.c:379:65: note: instantiated from:
rb_define_const(rb_mPGconstants, "PQPING_NO_RESPONSE", INT2FIX(PQPING_NO_RESPONSE));
^
pg.c:381:56: error: use of undeclared identifier 'PQPING_NO_ATTEMPT'
rb_define_const(rb_mPGconstants, "PQPING_NO_ATTEMPT", INT2FIX(PQPING_NO_ATTEMPT));
^
pg.c:381:64: note: instantiated from:
rb_define_const(rb_mPGconstants, "PQPING_NO_ATTEMPT", INT2FIX(PQPING_NO_ATTEMPT));
^
1 warning and 4 errors generated.
make: *** [pg.o] Error 1


Gem files will remain installed in /Users/marcboehle/.bundler/tmp/25873/gems/pg-0.16.0 for inspection.
Results logged to /Users/marcboehle/.bundler/tmp/25873/gems/pg-0.16.0/ext/gem_make.out

An error occurred while installing pg (0.16.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.16.0'` succeeds before bundling.

接下来我尝试了:

Marcs-MacBook-Pro:smartforce marcboehle$ sudo gem install pg
Password:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.

/usr/local/rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconnectionUsedPassword()... yes
checking for PQisthreadsafe()... yes
checking for PQprepare()... yes
checking for PQexecParams()... yes
checking for PQescapeString()... yes
checking for PQescapeStringConn()... yes
checking for PQescapeLiteral()... yes
checking for PQescapeIdentifier()... yes
checking for PQgetCancel()... yes
checking for lo_create()... yes
checking for pg_encoding_to_char()... yes
checking for pg_char_to_encoding()... yes
checking for PQsetClientEncoding()... yes
checking for PQlibVersion()... yes
checking for PQping()... yes
checking for PQsetSingleRowMode()... no
checking for rb_encdb_alias()... yes
checking for rb_enc_alias()... yes
checking for rb_thread_call_without_gvl()... yes
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_fd_select()... yes
checking for rb_w32_wrap_io_handle()... no
checking for PGRES_COPY_BOTH in libpq-fe.h... no
checking for PGRES_SINGLE_TUPLE in libpq-fe.h... no
checking for PG_DIAG_TABLE_NAME in libpq-fe.h... no
checking for struct pgNotify.extra in libpq-fe.h... yes
checking for unistd.h... yes
checking for ruby/st.h... yes
creating extconf.h
creating Makefile

make "DESTDIR="
compiling gvl_wrappers.c
compiling pg.c
pg.c:272:9: warning: implicit declaration of function 'PQlibVersion' is invalid in C99 [-Wimplicit-function-declaration]
return INT2NUM(PQlibVersion());
^
In file included from pg.c:48:
In file included from ./pg.h:17:
In file included from /usr/local/rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby.h:33:
/usr/local/rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/ruby.h:1167:21: note: instantiated from:
# define INT2NUM(v) INT2FIX((int)(v))
^
pg.c:272:9: note: instantiated from:
return INT2NUM(PQlibVersion());
^
pg.c:272:17: note: instantiated from:
return INT2NUM(PQlibVersion());
^
pg.c:375:48: error: use of undeclared identifier 'PQPING_OK'
rb_define_const(rb_mPGconstants, "PQPING_OK", INT2FIX(PQPING_OK));
^
pg.c:375:56: note: instantiated from:
rb_define_const(rb_mPGconstants, "PQPING_OK", INT2FIX(PQPING_OK));
^
pg.c:377:52: error: use of undeclared identifier 'PQPING_REJECT'
rb_define_const(rb_mPGconstants, "PQPING_REJECT", INT2FIX(PQPING_REJECT));
^
pg.c:377:60: note: instantiated from:
rb_define_const(rb_mPGconstants, "PQPING_REJECT", INT2FIX(PQPING_REJECT));
^
pg.c:379:57: error: use of undeclared identifier 'PQPING_NO_RESPONSE'
rb_define_const(rb_mPGconstants, "PQPING_NO_RESPONSE", INT2FIX(PQPING_NO_RESPONSE));
^
pg.c:379:65: note: instantiated from:
rb_define_const(rb_mPGconstants, "PQPING_NO_RESPONSE", INT2FIX(PQPING_NO_RESPONSE));
^
pg.c:381:56: error: use of undeclared identifier 'PQPING_NO_ATTEMPT'
rb_define_const(rb_mPGconstants, "PQPING_NO_ATTEMPT", INT2FIX(PQPING_NO_ATTEMPT));
^
pg.c:381:64: note: instantiated from:
rb_define_const(rb_mPGconstants, "PQPING_NO_ATTEMPT", INT2FIX(PQPING_NO_ATTEMPT));
^
1 warning and 4 errors generated.
make: *** [pg.o] Error 1


Gem files will remain installed in /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/pg-0.16.0 for inspection.
Results logged to /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/pg-0.16.0/ext/gem_make.out

然后我尝试了以下内容:

Marcs-MacBook-Pro:smartforce marcboehle$ which pg_config
/usr/bin/pg_config
Marcs-MacBook-Pro:smartforce marcboehle$ gem install pg -- --with-pg-config= '/usr/bin/pg_config'
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /usr/local/rvm/gems/ruby-2.0.0-p247/gems/pg-0.16.0/.gemtest
Marcs-MacBook-Pro:smartforce marcboehle$ sudo apt-get install libpq-dev
Password:
sudo: apt-get: command not found
Marcs-MacBook-Pro:smartforce marcboehle$ sudo install libpq-dev
usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 file2
install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 ... fileN directory
install -d [-v] [-g group] [-m mode] [-o owner] directory ...
Marcs-MacBook-Pro:smartforce marcboehle$ sudo apt-get install postgresql-client libpq5 libpq-dev
sudo: apt-get: command not found
Marcs-MacBook-Pro:smartforce marcboehle$ sudo gem install pg
ERROR: Could not find a valid gem 'pg' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server session ticket A (https://rubygems.org/latest_specs.4.8.gz)
ERROR: Possible alternatives: pg
Marcs-MacBook-Pro:smartforce marcboehle$ rails -v
Could not find pg-0.16.0 in any of the sources
Run `bundle install` to install missing gems.
Marcs-MacBook-Pro:smartforce marcboehle$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0]
Marcs-MacBook-Pro:smartforce marcboehle$ rails -v
Could not find pg-0.16.0 in any of the sources
Run `bundle install` to install missing gems.

编辑

感谢您的评论,我尝试安装导致以下问题的 postgres。任何建议,或者你能推荐一个教程,我如何删除连接到整个 ruby​​ on rails、rvm、homebrew 和我安装的任何东西的所有东西。然后我很乐意从头开始重新安装所有干净的东西。否则你能帮我解释一下我需要用我需要做的任何事情的“路径”做什么吗?我是个菜鸟。

An error occurred while installing pg (0.16.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.16.0'` succeeds before bundling.
Marcs-MacBook-Pro:smartforce marcboehle$ brew update
Updated Homebrew from 424c84c5 to 9e01e61d.
==> New Formulae
clojurescript libgsm snzip voltdb
dmalloc libresample stlviewer
dtrx randomize-lines tlassemble
juju reaver tractorgen
==> Updated Formulae
abcl isl
ace iso-codes
aircrack-ng ispc
appledoc ispell
aspell jenkins
autoconf jsvc
automake klavaro
bash kytea
boost lcdf-typetools
botan ldid
bullet leiningen
calc lesstif
camlp5 libcouchbase
cantera libdiscid
casperjs libdlna
chruby libfreenect
classads libmagic
cpanminus libquvi
cppcheck llvm
css-crush logentries
csync lpc21isp
cyassl mackup
denominator macvim
djvulibre madplay
drush mariadb
dub matlab2tikz
duti mksh
eet mlton
eina mongodb
ejabberd monotone
elixir mr
embryo mspdebug
eprover mysql
exiftool mysql-cluster
fb-client mysql-connector-odbc
fdk-aac nasm
findbugs netcdf
flac netpbm
fontforge nexus
fox node
fwknop open-scene-graph
gdal openssl
gearman parrot
geos passenger
getmail pcre++
gettext percona-server
gfortran perl-build
git pgbadger
gle pgtap
glm pngquant
gnupg2 poppler
go postgis
gobject-introspection postgresql
gpg-agent proguard
grass py2cairo
gst-libav pypy
gst-plugins-bad python
gst-plugins-base python3
gst-plugins-good qemu
gst-plugins-ugly quantlib
gstreamer rabbitmq
hevea rabbitmq-c
hiredis reattach-to-user-namespace
hydra redis
icu4c rethinkdb
ircd-hybrid riak
rpm tiger-vnc
rrdtool transmission
rtmpdump uwsgi
ruby vifm
saxon vimpc
sbcl voldemort
sdl2 watchman
ser2net wine
serf wkhtmltopdf
silk wxmac
smartmontools xmlto
socat xpa
sonar xrootd
sonar-runner yarp
sqsh yaws
ssdeep ydict
storm youtube-dl
subversion zabbix
svtplay-dl zookeeper
swi-prolog zsh-completions
tbb zsh-syntax-highlighting
terminal-notifier
==> Deleted Formulae
clojure
Marcs-MacBook-Pro:smartforce marcboehle$ brew doctor
Warning: Some directories in /usr/local/share/man aren't writable.
This can happen if you "sudo make install" software that isn't managed
by Homebrew. If a brew tries to add locale information to one of these
directories, then the install will fail during the link step.
You should probably `chown` them:

/usr/local/share/man/man7

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:

/opt/sm/pkg/active/bin/curl-config
/opt/sm/pkg/active/bin/ncurses5-config
/opt/sm/pkg/active/bin/ncursesw5-config
/opt/sm/pkg/active/bin/pkg-config
/opt/sm/pkg/active/bin/xml2-config
/opt/sm/pkg/active/bin/xslt-config

Warning: An outdated version of Git was detected in your PATH.
Git 1.7.10 or newer is required to perform checkouts over HTTPS from GitHub.
Please upgrade: brew upgrade git

Warning: You have MacPorts or Fink installed:
/opt/local/bin/port

This can cause trouble. You don't have to uninstall them, but you may want to
temporarily move them out of the way, e.g.

sudo mv /opt/local ~/macports

Warning: Your compilers are different from the standard versions for your Xcode.
If you have Xcode 4.3 or newer, you should install the Command Line Tools for
Xcode from within Xcode's Download preferences.
Otherwise, you should reinstall Xcode.

Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:

git
git-cvsserver
git-receive-pack
git-shell
git-upload-archive
git-upload-pack

Consider amending your PATH so that /usr/local/bin
occurs before /usr/bin in your PATH.
Marcs-MacBook-Pro:smartforce marcboehle$ brew upgrade git
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
Error: git not installed
Marcs-MacBook-Pro:smartforce marcboehle$ sudo mv /opt/local ~/macports
Marcs-MacBook-Pro:smartforce marcboehle$ brew upgrade git
Error: git not installed
Marcs-MacBook-Pro:smartforce marcboehle$ brew install git
==> Downloading http://git-core.googlecode.com/files/git-1.8.3.4.tar.gz
######################################################################## 100,0%
==> make prefix=/usr/local/Cellar/git/1.8.3.4 sysconfdir=/usr/local/etc CC=cc CF
==> make CC=cc CFLAGS= LDFLAGS=
git-credential-osxkeychain.c:131: error: ‘protocol’ undeclared (first use in this function)
git-credential-osxkeychain.c:131: error: ‘kSecProtocolTypeHTTPS’ undeclared (first use in this function)
git-credential-osxkeychain.c:133: error: ‘kSecProtocolTypeHTTP’ undeclared (first use in this function)
git-credential-osxkeychain.c:141: error: ‘port’ undeclared (first use in this function)
make: *** [git-credential-osxkeychain.o] Error 1

READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting

These open issues may also help:
https://github.com/mxcl/homebrew/issues/21998
https://github.com/mxcl/homebrew/issues/21530
https://github.com/mxcl/homebrew/pull/17713
https://github.com/mxcl/homebrew/pull/20260
Marcs-MacBook-Pro:smartforce marcboehle$ brew upgrade git
Error: git not installed
Marcs-MacBook-Pro:smartforce marcboehle$

最佳答案

尝试安装包 libpq-dev

关于ruby-on-rails - pg gem 无法使用 bundle install 安装或根本无法安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18384993/

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