簡體   English   中英

Rails / Postgres:警告:隱式轉換丟失 integer 精度:'long' 到 'int'

[英]Rails / Postgres: warning: implicit conversion loses integer precision: 'long' to 'int'

我無法讓 postgres-gem 運行。

macOS 10.15.4 Postgres-App 2.3.5 ( https://postgresapp.com/downloads.html ) PostgreSQL -v12 Rails-6.0.2 gem '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 不允許我粘貼它,因為它說,我在消息中粘貼了太多代碼

在 Gemfile 中:pg

以前我對版本 1.1.4 做了同樣的事情,同樣的結果

該怎么辦?

謝謝,克里斯

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

請參閱:寶石描述

不知道上面的錯誤是什么

我有同樣的問題,這解決了我

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM