简体   繁体   中英

gem install pg won't bundle

Trying to deploy Rails app onUbuntu 20 is impossible to install pg, and any attempt to bundle will incur in errors

$ gem install pg
Building native extensions. This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

    current directory: /home/user/.rvm/gems/ruby-2.6.1/gems/pg-1.2.3/ext
/home/user/.rvm/rubies/ruby-2.6.1/bin/ruby -I /home/user/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0 -r ./siteconf20210417-119158-37ke72.rb 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 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: /home/user/.rvm/gems/ruby-2.6.1/gems/pg-1.2.3/ext
make "DESTDIR=" clean

current directory: /home/user/.rvm/gems/ruby-2.6.1/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
compiling pg_connection.c
compiling pg_copy_coder.c
compiling pg_errors.c
compiling pg_record_coder.c
compiling pg_result.c
compiling pg_text_decoder.c
compiling pg_text_encoder.c
compiling pg_tuple.c
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
compiling pg_type_map_by_mri_type.c
compiling pg_type_map_by_oid.c
compiling pg_type_map_in_ruby.c
compiling pg_util.c
linking shared-object pg_ext.so

current directory: /home/user/.rvm/gems/ruby-2.6.1/gems/pg-1.2.3/ext
make "DESTDIR=" install
make: /usr/bin/mkdir: Command not found
make: *** [Makefile:201: .sitearchdir.time] Error 127

make install failed, exit code 2

Gem files will remain installed in /home/user/.rvm/gems/ruby-2.6.1/gems/pg-1.2.3 for inspection.
Results logged to /home/user/.rvm/gems/ruby-2.6.1/extensions/x86_64-linux/2.6.0/pg-1.2.3/gem_make.out

on bundle install nothing seem to work:

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

In Gemfile: bcrypt

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

In Gemfile: rails was resolved to 6.1.3.1, which depends on actioncable was resolved to 6.1.3.1, which depends on nio4r

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

Nothing seems to work and there is not useful information on how to solve problem

make: /usr/bin/mkdir: Command not found it's the reason.

Please write this command with sudo perm.

sudo ln -s $(which mkdir) /usr/bin/mkdir

And try again bundle.

This happens because you need install the following packages that the pg gem requires:

sudo apt install postgresql postgresql-contrib libpq-dev

Then configure postgres and verify is running.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM