我正在尝试更新到Rails 5.我已经在我的gem文件中成功将Ruby更新为'2.3.1',并运行了bundle install。
然后我去了Rails 5.0,它告诉我:
Make sure that gem install pg -v '0.18.2' succeeds before bundling.
我把rails放回4.2就像现在一样,我尝试通过运行gem install pg -v '0.18.2'
来更新终端中的pg,并更新gem文件并运行bundle install
并且两次都得到此错误:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/w*****n/.rvm/rubies/ruby-2.1.2/bin/ruby 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=/Users/w******n/.rvm/rubies/ruby-2.1.2/bin/ruby
--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
extconf failed, exit code 1
Gem files will remain installed in /Users/w******n/.rvm/gems/ruby-2.1.2/gems/pg-0.18.2 for inspection.
Results logged to /Users/w*******n/.rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/pg-0.18.2/gem_make.out
我发现this post这是一个类似的错误,但是当我尝试他们的解决方案时,它不起作用。
我的问题有1.5个部分: 1.我怎样才能获得升级到最新版本的pg .5为什么我得到这个,我该如何解释这个错误?
更新:
重新安装了pg并收到了这个:
==> Pouring postgresql-9.6.1.yosemite.bottle.tar.gz
==> /usr/local/Cellar/postgresql/9.6.1/bin/initdb /usr/local/var/postgres
==> Caveats
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/Homebrew/homebrew/issues/2510
To migrate existing data from a previous major version (pre-9.0) of PostgreSQL, see:
https://www.postgresql.org/docs/9.6/static/upgrading.html
To migrate existing data from a previous minor version (9.0-9.5) of PostgreSQL, see:
https://www.postgresql.org/docs/9.6/static/pgupgrade.html
You will need your previous PostgreSQL installation from brew to perform `pg_upgrade`.
Do not run `brew cleanup postgresql` until you have performed the migration.
To have launchd start postgresql now and restart at login:
brew services start postgresql
Or, if you don't want/need a background service you can just run:
pg_ctl -D /usr/local/var/postgres start
==> Summary
/usr/local/Cellar/postgresql/9.6.1: 3,242 files, 36.5M
运行psql -V:psql (PostgreSQL) 9.6.1
现在重新安装pg并尝试bundle update rails
后,我收到此错误:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/w*******n/.rvm/gems/ruby-2.3.1/gems/pg-0.18.2/ext
/Users/w******n/.rvm/rubies/ruby-2.3.1/bin/ruby -r ./siteconf20170103-82113-1miw542.rb extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/Versions/0.18.2/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/Versions/0.18.2/bin/pg_config
sh: /Applications/Postgres.app/Contents/Versions/0.18.2/bin/pg_config: No such file or directory
sh: /Applications/Postgres.app/Contents/Versions/0.18.2/bin/pg_config: No such file or directory
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()... yes
checking for PQconninfo()... yes
checking for rb_encdb_alias()... yes
checking for rb_enc_alias()... no
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 rb_str_modify_expand()... yes
checking for rb_hash_dup()... yes
checking for PGRES_COPY_BOTH in libpq-fe.h... yes
checking for PGRES_SINGLE_TUPLE in libpq-fe.h... yes
checking for PG_DIAG_TABLE_NAME in libpq-fe.h... yes
checking for struct pgNotify.extra in libpq-fe.h... yes
checking for unistd.h... yes
checking for ruby/st.h... yes
checking for C99 variable length arrays... yes
creating extconf.h
creating Makefile
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/w******n/.rvm/gems/ruby-2.3.1/extensions/x86_64-darwin-14/2.3.0/pg-0.18.2/mkmf.log
current directory: /Users/w*******n/.rvm/gems/ruby-2.3.1/gems/pg-0.18.2/ext
make "DESTDIR=" clean
current directory: /Users/w*******n/.rvm/gems/ruby-2.3.1/gems/pg-0.18.2/ext
make "DESTDIR="
compiling gvl_wrappers.c
compiling pg.c
compiling pg_binary_decoder.c
compiling pg_binary_encoder.c
compiling pg_coder.c
pg_coder.c:188:34: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
res = this->dec_func(this, val, RSTRING_LEN(argv[0]), tuple, field, ENCODING_GET(argv[0]));
~~~~ ^~~~~~~~~~~~~~~~~~~~
/Users/w*******n/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/ruby.h:998:6: note: expanded from macro 'RSTRING_LEN'
RSTRING_EMBED_LEN(str) : \
^~~~~~~~~~~~~~~~~~~~~~
/Users/w********n/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/ruby.h:994:6: note: expanded from macro 'RSTRING_EMBED_LEN'
(long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pg_coder.c:188:34: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
res = this->dec_func(this, val, RSTRING_LEN(argv[0]), tuple, field, ENCODING_GET(argv[0]));
~~~~ ^~~~~~~~~~~~~~~~~~~~
/Users/w******n/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/ruby.h:999:28: note: expanded from macro 'RSTRING_LEN'
RSTRING(str)->as.heap.len)
~~~~~~~~~~~~~~~~~~~~~~^~~
pg_coder.c:188:56: warning: implicit conversion loses integer precision: 'VALUE' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
res = this->dec_func(this, val, RSTRING_LEN(argv[0]), tuple, field, ENCODING_GET(argv[0]));
~~~~ ^~~~~
pg_coder.c:188:63: warning: implicit conversion loses integer precision: 'VALUE' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
res = this->dec_func(this, val, RSTRING_LEN(argv[0]), tuple, field, ENCODING_GET(argv[0]));
~~~~ ^~~~~
4 warnings generated.
compiling pg_connection.c
pg_connection.c:2394:3: warning: implicit declaration of function 'gettimeofday' is invalid in C99 [-Wimplicit-function-declaration]
gettimeofday(&currtime, NULL);
^
1 warning generated.
compiling pg_copy_coder.c
pg_copy_coder.c:218:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
strlen = RSTRING_LEN(subint);
~ ^~~~~~~~~~~~~~~~~~~
/Users/w*******n/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/ruby.h:998:6: note: expanded from macro 'RSTRING_LEN'
RSTRING_EMBED_LEN(str) : \
^~~~~~~~~~~~~~~~~~~~~~
/Users/w******n/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/ruby.h:994:6: note: expanded from macro 'RSTRING_EMBED_LEN'
(long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pg_copy_coder.c:218:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
strlen = RSTRING_LEN(subint);
~ ^~~~~~~~~~~~~~~~~~~
/Users/w*******n/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/ruby.h:999:28: note: expanded from macro 'RSTRING_LEN'
RSTRING(str)->as.heap.len)
~~~~~~~~~~~~~~~~~~~~~~^~~
pg_copy_coder.c:501:23: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
input_len = end_ptr - start_ptr;
~ ~~~~~~~~^~~~~~~~~~~
3 warnings generated.
compiling pg_errors.c
compiling pg_result.c
compiling pg_text_decoder.c
compiling pg_text_encoder.c
pg_text_encoder.c:162:14: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
len = out - start;
~ ~~~~^~~~~~~
pg_text_encoder.c:281:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
return optr - out;
~~~~~~ ~~~~~^~~~~
pg_text_encoder.c:285:12: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
return 2 + RSTRING_LEN(*intermediate) * 2;
~~~~~~ ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pg_text_encoder.c:491:13: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
nr_elems = RARRAY_LEN(value);
~ ^~~~~~~~~~~~~~~~~
/Users/w********n/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/ruby.h:1044:23: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN(a) rb_array_len(a)
^~~~~~~~~~~~~~~
4 warnings generated.
compiling pg_type_map.c
compiling pg_type_map_all_strings.c
compiling pg_type_map_by_class.c
compiling pg_type_map_by_column.c
pg_type_map_by_column.c:161:52: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
return dec_func( p_coder, RSTRING_PTR(field_str), RSTRING_LEN(field_str), 0, fieldno, enc_idx );
~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~
/Users/w********n/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/ruby.h:998:6: note: expanded from macro 'RSTRING_LEN'
RSTRING_EMBED_LEN(str) : \
^~~~~~~~~~~~~~~~~~~~~~
/Users/w********n/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/ruby.h:994:6: note: expanded from macro 'RSTRING_EMBED_LEN'
(long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pg_type_map_by_column.c:161:52: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
return dec_func( p_coder, RSTRING_PTR(field_str), RSTRING_LEN(field_str), 0, fieldno, enc_idx );
~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~
/Users/w*********n/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/ruby.h:999:28: note: expanded from macro 'RSTRING_LEN'
RSTRING(str)->as.heap.len)
~~~~~~~~~~~~~~~~~~~~~~^~~
pg_type_map_by_column.c:230:17: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
conv_ary_len = RARRAY_LEN(conv_ary);
~ ^~~~~~~~~~~~~~~~~~~~
/Users/w********n/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/ruby.h:1044:23: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN(a) rb_array_len(a)
^~~~~~~~~~~~~~~
3 warnings generated.
compiling pg_type_map_by_mri_type.c
compiling pg_type_map_by_oid.c
compiling pg_type_map_in_ruby.c
compiling util.c
util.c:119:24: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
return (char*)out_ptr - out;
~~~~~~ ~~~~~~~~~~~~~~~^~~~~
1 warning generated.
linking shared-object pg_ext.bundle
ld: file not found: dynamic_lookup
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [pg_ext.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/w********n/.rvm/gems/ruby-2.3.1/gems/pg-0.18.2 for inspection.
Results logged to /Users/w*******n/.rvm/gems/ruby-2.3.1/extensions/x86_64-darwin-14/2.3.0/pg-0.18.2/gem_make.out
An error occurred while installing pg (0.18.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.2'` succeeds before bundling.
答案 0 :(得分:0)
我没有找到我想要的完整答案,但是直到有人能解释发生了什么,这就是我为安装Rails 5所做的工作:
我卸载并重新安装了pg。
然后运行bundle update rails
并收到上面发布的最后一个错误日志。
为了解决这个问题,我运行了sudo gem install rails
然后我收到了这个错误:Warning: You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run
gem pristine --all for better startup performance.
并通过运行gem update --system
来解决
现在我可以成功运行gem install pg -v '0.18.2'
,最后在上面发布的第一个日志中找到原始错误。
它没有结束......尝试启动rails服务器,并收到此错误:
Array values in the parameter to
Gem.paths = are deprecated.
Please use a String or nil.
Sorry, you can't use byebug without Readline. To solve this, you need to
rebuild Ruby with Readline support. If using Ubuntu, try
sudo apt-get
安装libreadline-dev and then reinstall your Ruby.
我拿出了byebug gem,不得不再次运行gem install pg -v '0.18.2'
,然后bundle update
在所有这些之后,rails最终被更新(已经在我的gem文件中声明了5.0)并且服务器将启动。服务器启动时会出现警告:
Array values in the parameter to
Gem.paths = are deprecated.
Please use a String or nil.
An Array ({"GEM_PATH"=>["/Users/walshcostigan/.rvm/gems/ruby-2.3.1", "/Users/walshcostigan/.rvm/gems/ruby-2.3.1@global"]}) was passed in from bin/rails:3:in
负载'
`
但它是Rails 5,并且它正在运行,所以现在这就是我解决这个问题的方法。希望这有助于其他人,并且对此问题的任何见解表示赞赏!