导轨/后文:警告:隐式转换会丢失整数精度:'long'到'int'



我无法让 postgres-gem 运行。

macOS 10.15.4 邮政-应用程序 2.3.5 (https://postgresapp.com/downloads.html( PostgreSQL -v12 导轨-6.0.2 宝石 'PG' v1.2.3

然后,我做到了:bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/12/bin/pg_configbundle install

我得到这个:

Fetching pg 1.2.3 (was 1.1.4)
Installing pg 1.2.3 (was 1.1.4) with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/dev/.rvm/gems/ruby-2.5.7/gems/pg-1.2.3/ext
/Users/dev/.rvm/rubies/ruby-2.5.7/bin/ruby -r ./siteconf20200615-30711-d59mnj.rb extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/Versions/12/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/Versions/12/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 PQsetSingleRowMode()... yes
checking for PQconninfo()... yes
checking for PQsslAttribute()... yes
checking for PQresultVerboseErrorMessage()... yes
checking for PQencryptPasswordConn()... yes
checking for PQresultMemorySize()... yes
checking for timegm()... yes
checking for rb_gc_adjust_memory_usage()... yes
checking for unistd.h... yes
checking for inttypes.h... yes
checking for C99 variable length arrays... yes
creating extconf.h
creating Makefile
current directory: /Users/dev/.rvm/gems/ruby-2.5.7/gems/pg-1.2.3/ext
make "DESTDIR=" clean
current directory: /Users/dev/.rvm/gems/ruby-2.5.7/gems/pg-1.2.3/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:216: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/dev/.rvm/rubies/ruby-2.5.7/include/ruby-2.5.0/ruby/ruby.h:975:6: note: expanded from macro 'RSTRING_LEN'
RSTRING_EMBED_LEN(str) : 
^~~~~~~~~~~~~~~~~~~~~~
/Users/dev/.rvm/rubies/ruby-2.5.7/include/ruby-2.5.0/ruby/ruby.h:971:6: note: expanded from macro 'RSTRING_EMBED_LEN'
(long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & 
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pg_coder.c:216: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/dev/.rvm/rubies/ruby-2.5.7/include/ruby-2.5.0/ruby/ruby.h:976:28: note: expanded from macro 'RSTRING_LEN'
RSTRING(str)->as.heap.len)
~~~~~~~~~~~~~~~~~~~~~~^~~
2 warnings generated.
compiling pg_connection.c
compiling pg_copy_coder.c
pg_copy_coder.c:228:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
strlen = RSTRING_LEN(subint);
~ ^~~~~~~~~~~~~~~~~~~
/Users/dev/.rvm/rubies/ruby-2.5.7/include/ruby-2.5.0/ruby/ruby.h:975:6: note: expanded from macro 'RSTRING_LEN'
RSTRING_EMBED_LEN(str) : 
^~~~~~~~~~~~~~~~~~~~~~
/Users/dev/.rvm/rubies/ruby-2.5.7/include/ruby-2.5.0/ruby/ruby.h:971:6: note: expanded from macro 'RSTRING_EMBED_LEN'
(long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & 
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pg_copy_coder.c:228:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
strlen = RSTRING_LEN(subint);
~ ^~~~~~~~~~~~~~~~~~~
/Users/dev/.rvm/rubies/ruby-2.5.7/include/ruby-2.5.0/ruby/ruby.h:976:28: note: expanded from macro 'RSTRING_LEN'
RSTRING(str)->as.heap.len)
~~~~~~~~~~~~~~~~~~~~~~^~~
pg_copy_coder.c:534: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_record_coder.c
pg_record_coder.c:196:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
strlen = RSTRING_LEN(subint);
~ ^~~~~~~~~~~~~~~~~~~
/Users/dev/.rvm/rubies/ruby-2.5.7/include/ruby-2.5.0/ruby/ruby.h:975:6: note: expanded from macro 'RSTRING_LEN'
RSTRING_EMBED_LEN(str) : 
^~~~~~~~~~~~~~~~~~~~~~
/Users/dev/.rvm/rubies/ruby-2.5.7/include/ruby-2.5.0/ruby/ruby.h:971:6: note: expanded from macro 'RSTRING_EMBED_LEN'
(long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & 
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pg_record_coder.c:196:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
strlen = RSTRING_LEN(subint);
~ ^~~~~~~~~~~~~~~~~~~
/Users/dev/.rvm/rubies/ruby-2.5.7/include/ruby-2.5.0/ruby/ruby.h:976:28: note: expanded from macro 'RSTRING_LEN'
RSTRING(str)->as.heap.len)
~~~~~~~~~~~~~~~~~~~~~~^~~
...
1 warning generated.
linking shared-object pg_ext.bundle
ld: warning: directory not found for option '-L/usr/local/Cellar/libyaml/0.2.2/lib'
ld: warning: directory not found for option '-L/usr/local/Cellar/libksba/1.3.5/lib'
ld: warning: directory not found for option '-L/usr/local/Cellar/libyaml/0.2.2/lib'
ld: warning: directory not found for option '-L/usr/local/Cellar/libksba/1.3.5/lib'
ld: warning: directory not found for option '-L/usr/local/Cellar/libyaml/0.2.2/lib'
ld: warning: directory not found for option '-L/usr/local/Cellar/libksba/1.3.5/lib'
current directory: /Users/dev/.rvm/gems/ruby-2.5.7/gems/pg-1.2.3/ext
make "DESTDIR=" install
make: /usr/local/Cellar/coreutils/8.31/bin/gmkdir: No such file or directory
make: *** [.sitearchdir.time] Error 1
make install failed, exit code 2
Gem files will remain installed in /Users/dev/.rvm/gems/ruby-2.5.7/gems/pg-1.2.3 for inspection.
Results logged to /Users/dev/.rvm/gems/ruby-2.5.7/extensions/x86_64-darwin-18/2.5.0/pg-1.2.3/gem_make.out
An error occurred while installing pg (1.2.3), and Bundler cannot continue.
Make sure that `gem install pg -v '1.2.3' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
pg

抱歉 - 整个错误消息要长得多,但 Stackoverflow 不允许我粘贴它,因为它说,我在消息中粘贴了太多代码

在宝石文件中: 页

以前我对1.1.4版做了同样的事情,结果相同

怎么办?

谢谢 克里斯

我遇到了同样的问题,这为我解决了它

gem install pg -v '0.18.2' -- with-cflags="-Wno-error=implicit-function-declaration"

现在它可以工作了:gem install pg -- --with-pg-config=<path to pg_config>帮助

参见:宝石描述

不知道上面的错误是什么

最新更新