Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run "Bundle install" I'm facing error occurred while installing pg (0.18.1), and Bundler cannot continue. #5060

Closed
hamidiqbal598 opened this issue Mar 18, 2021 · 6 comments

Comments

@hamidiqbal598
Copy link

(base) hamidiqbal598@Hamids-MacBook-Pro % bundle install
Fetching gem metadata from https://rubygems.org/.......
Using rake 12.3.2
Using CFPropertyList 2.3.6
Using concurrent-ruby 1.1.4
Using i18n 0.9.5
Using json 1.8.6
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 4.2.0
Using builder 3.2.3
Using erubis 2.7.0
Using mini_portile2 2.4.0
Using nokogiri 1.9.1
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.9
Using crass 1.0.4
Using loofah 2.2.3
Using rails-html-sanitizer 1.0.4
Using actionview 4.2.0
Using rack 1.6.11
Using rack-test 0.6.3
Using actionpack 4.2.0
Using globalid 0.4.1
Using activejob 4.2.0
Using mini_mime 1.0.1
Using mail 2.7.1
Using actionmailer 4.2.0
Using activemodel 4.2.0
Using arel 6.0.4
Using activerecord 4.2.0
Using activerecord-sortable 0.0.8
Using public_suffix 3.0.3
Using addressable 2.5.2
Using awesome_print 1.8.0
Using aws-eventstream 1.0.3
Using aws-partitions 1.184.0
Using aws-sigv4 1.1.0
Using jmespath 1.4.0
Using aws-sdk-core 3.59.0
Using aws-sdk-kms 1.23.0
Using aws-sdk-s3 1.45.0
Using barby 0.6.6
Using bcrypt 3.1.12
Using coderay 1.1.2
Using erubi 1.8.0
Using better_errors 2.5.0
Using debug_inspector 0.0.3
Using binding_of_caller 0.8.0
Using thor 0.20.3
Using railties 4.2.0
Using bootstrap-tagsinput-rails 0.4.2.1
Using momentjs-rails 2.10.6
Using bootstrap3-datetimepicker-rails 4.17.47
Using browser 2.5.3
Using bundler 1.17.3
Using byebug 10.0.2
Using cancancan 1.12.0
Using regexp_parser 1.3.0
Using xpath 3.2.0
Using capybara 3.12.0
Using chartkick 3.0.1
Using choice 0.2.0
Using coffee-script-source 1.12.2
Using execjs 2.7.0
Using coffee-script 2.4.1
Using coffee-rails 4.1.1
Using rb-fsevent 0.10.3
Using ffi 1.9.25
Using rb-inotify 0.10.0
Using sass-listen 4.0.0
Using sass 3.7.2
Using sprockets 3.7.2
Using sprockets-rails 3.2.1
Using tilt 2.0.9
Using sass-rails 5.0.7
Using chosen-rails 1.8.7
Using chunky_png 1.3.11
Using climate_control 0.2.0
Using cliver 0.3.2
Using cocoon 1.2.12
Using sexp_processor 4.11.0
Using code_analyzer 0.4.8
Using database_cleaner 1.7.0
Using orm_adapter 0.5.0
Using responders 2.4.0
Using warden 1.2.7
Using devise 3.4.1
Using rails 4.2.0
Using devise_token_auth 0.1.31
Using diff-lcs 1.3
Using dry-inflector 0.1.2
Using exception_notification 4.3.0
Using excon 0.64.0
Using ey_config 0.0.7
Using factory_girl 4.9.0
Using factory_girl_rails 4.9.0
Using multipart-post 2.0.0
Using faraday 0.15.4
Using faraday_middleware 0.12.2
Using mime-types-data 3.2018.0812
Using mime-types 3.2.2
Using multi_xml 0.6.0
Using httparty 0.16.3
Using fcm 0.0.6
Using figaro 1.1.1
Using fission 0.5.0
Using formatador 0.2.5
Using fog-core 1.45.0
Using multi_json 1.13.1
Using fog-json 1.2.0
Using ipaddress 0.8.3
Using xml-simple 1.1.5
Using fog-aliyun 0.3.3
Using fog-xml 0.1.3
Using fog-atmos 0.1.0
Using fog-aws 2.0.1
Using fog-brightbox 0.16.1
Using fog-cloudatcost 0.1.2
Using fog-digitalocean 0.4.0
Using fog-dnsimple 1.0.0
Using fog-dynect 0.0.3
Using fog-ecloud 0.3.0
Using fog-google 0.1.0
Using fog-internet-archive 0.0.1
Using fog-joyent 0.0.1
Using fog-local 0.6.0
Using fog-openstack 0.3.10
Using fog-powerdns 0.2.0
Using fog-profitbricks 4.1.1
Using fog-rackspace 0.1.6
Using fog-radosgw 0.0.5
Using fog-riakcs 0.1.0
Using fog-sakuracloud 1.7.5
Using fog-serverlove 0.1.2
Using fog-softlayer 1.1.4
Using fog-storm_on_demand 0.1.1
Using fog-terremark 0.1.0
Using fog-vmfusion 0.1.0
Using fog-voxel 0.1.0
Using optimist 3.0.0
Using rbvmomi 2.2.0
Using fog-vsphere 3.1.1
Using xmlrpc 0.3.0
Using fog-xenserver 1.0.0
Using fog 1.41.0
Using jquery-rails 4.3.3
Using fullcalendar-rails 2.3.1.0
Using rspec-support 3.8.0
Using rspec-core 3.8.0
Using rspec-expectations 3.8.2
Using rspec-mocks 3.8.0
Using rspec 3.8.0
Using ruby-progressbar 1.10.0
Using fuubar 2.0.0
Using gcm 0.1.1
Using geocoder 1.5.0
Using groupdate 4.1.1
Using haml 4.0.7
Using ruby_parser 3.12.0
Using html2haml 2.2.0
Using haml-rails 0.9.0
Using invisible_captcha 0.12.1
Using jasminerice 0.0.10
Using jbuilder 2.8.0
Using jquery-ui-rails 6.0.1
Using jwt 2.1.0
Using kaminari-core 1.1.1
Using kaminari-actionview 1.1.1
Using kaminari-activerecord 1.1.1
Using kaminari 1.1.1
Using launchy 2.4.3
Using mimemagic 0.3.3
Using newrelic_rpm 5.6.0.349
Using terrapin 0.6.0
Using paperclip 6.1.0
Using parse-ruby-client 1.0.0.alpha2 from https://github.com/adelevie/parse-ruby-client.git (at 98596a0@98596a0)
Using pdf-core 0.7.0
Using pdfkit 0.8.2
Fetching pg 0.18.1
Installing pg 0.18.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /Users/hamidiqbal598/.rvm/gems/ruby-2.3.3/gems/pg-0.18.1/ext

/Users/hamidiqbal598/.rvm/rubies/ruby-2.3.3/bin/ruby -I /Users/hamidiqbal598/.rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0 -r
./siteconf20210318-41738-16bk7id.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/local/opt/libpq/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()... yes
checking for PQconninfo()... yes
checking for PQhostaddr()... 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
creating extconf.h
creating Makefile

current directory: /Users/hamidiqbal598/.rvm/gems/ruby-2.3.3/gems/pg-0.18.1/ext
make "DESTDIR=" clean

current directory: /Users/hamidiqbal598/.rvm/gems/ruby-2.3.3/gems/pg-0.18.1/ext
make "DESTDIR="
compiling pg_type_map_all_strings.c
compiling pg_type_map_by_class.c
compiling pg_result.c
compiling pg_errors.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.
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/hamidiqbal598/.rvm/rubies/ruby-2.3.3/include/ruby-2.3.0/ruby/ruby.h:994:6: note: expanded from macro 'RSTRING_LEN'
RSTRING_EMBED_LEN(str) :
^~~~~~~~~~~~~~~~~~~~~~
/Users/hamidiqbal598/.rvm/rubies/ruby-2.3.3/include/ruby-2.3.0/ruby/ruby.h:990: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/hamidiqbal598/.rvm/rubies/ruby-2.3.3/include/ruby-2.3.0/ruby/ruby.h:995: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_binary_encoder.c
compiling pg_type_map_by_oid.c
compiling pg_text_decoder.c
compiling pg_connection.c
pg_connection.c:2410:3: error: implicit declaration of function 'gettimeofday' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
gettimeofday(&currtime, NULL);
^
pg_connection.c:2427:4: error: implicit declaration of function 'gettimeofday' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
gettimeofday(&currtime, NULL);
^
2 errors generated.
make: *** [pg_connection.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/hamidiqbal598/.rvm/gems/ruby-2.3.3/gems/pg-0.18.1 for inspection.
Results logged to /Users/hamidiqbal598/.rvm/gems/ruby-2.3.3/extensions/x86_64-darwin-20/2.3.0/pg-0.18.1/gem_make.out

An error occurred while installing pg (0.18.1), and Bundler cannot continue.
Make sure that gem install pg -v '0.18.1' --source 'https://rubygems.org/' succeeds before bundling.

In Gemfile:
pg

@hamidiqbal598
Copy link
Author

And if I Run "gem install pg -v '0.18.1' --source 'https://rubygems.org/'"
Then error occurred:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.

current directory: /Users/hamidiqbal598/.rvm/gems/ruby-2.3.3/gems/pg-0.18.1/ext

/Users/hamidiqbal598/.rvm/rubies/ruby-2.3.3/bin/ruby -I /Users/hamidiqbal598/.rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0 -r ./siteconf20210318-44721-r1vfu0.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/local/opt/libpq/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()... yes
checking for PQconninfo()... yes
checking for PQhostaddr()... 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
creating extconf.h
creating Makefile

current directory: /Users/hamidiqbal598/.rvm/gems/ruby-2.3.3/gems/pg-0.18.1/ext
make "DESTDIR=" clean

current directory: /Users/hamidiqbal598/.rvm/gems/ruby-2.3.3/gems/pg-0.18.1/ext
make "DESTDIR="
compiling pg_type_map_all_strings.c
compiling pg_type_map_by_class.c
compiling pg_result.c
compiling pg_errors.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.
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/hamidiqbal598/.rvm/rubies/ruby-2.3.3/include/ruby-2.3.0/ruby/ruby.h:994:6: note: expanded from macro 'RSTRING_LEN'
RSTRING_EMBED_LEN(str) :
^~~~~~~~~~~~~~~~~~~~~~
/Users/hamidiqbal598/.rvm/rubies/ruby-2.3.3/include/ruby-2.3.0/ruby/ruby.h:990: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/hamidiqbal598/.rvm/rubies/ruby-2.3.3/include/ruby-2.3.0/ruby/ruby.h:995: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_binary_encoder.c
compiling pg_type_map_by_oid.c
compiling pg_text_decoder.c
compiling pg_connection.c
pg_connection.c:2410:3: error: implicit declaration of function 'gettimeofday' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
gettimeofday(&currtime, NULL);
^
pg_connection.c:2427:4: error: implicit declaration of function 'gettimeofday' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
gettimeofday(&currtime, NULL);
^
2 errors generated.
make: *** [pg_connection.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/hamidiqbal598/.rvm/gems/ruby-2.3.3/gems/pg-0.18.1 for inspection.
Results logged to /Users/hamidiqbal598/.rvm/gems/ruby-2.3.3/extensions/x86_64-darwin-20/2.3.0/pg-0.18.1/gem_make.out

@hamidiqbal598
Copy link
Author

I solve this issue by:
gem install pg -v '0.18.4' -- --with-cflags="-Wno-error=implicit-function-declaration"

@sahil1mg
Copy link

sahil1mg commented Aug 2, 2021

Adding to the answer, for bundle install one can use below

bundle config build.pg --with-cflags="-Wno-error=implicit-function-declaration"
bundle install

@vivektiwary
Copy link

I was having the same issue in Mac, I first installed Postgres using
brew install postgresql and then did/
gem install pg -v '1.2.3' --source 'https://rubygems.org/'
and it worked

@Omarabdul3ziz
Copy link

I faced the same issue on ubuntu and I got it fixed by installing these

sudo apt install postgresql postgresql-contrib libpq-dev

after that bundle install again install the pg gem.

thanks to https://stackoverflow.com/a/56308158/11215703

@zer0veritas
Copy link

Omara,

you will have to install each one in the bundle manually, ex.
gem install xmlrpc -v 0.3.2
gem install simple_oauth -v 0.3.1

each one can be found in the ruby gems library here: https://libraries.io/rubygems/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants