【问题标题】:gem install pg won't bundlegem install pg 不会捆绑
【发布时间】:2021-07-11 23:28:50
【问题描述】:

尝试在 Ubuntu 20 上部署 Rails 应用是无法安装 pg 的,任何尝试捆绑都会出错

$ 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

在bundle install 上似乎没有任何效果:

安装 bcrypt (3.1.16) 时出错,Bundler 无法继续。 在捆绑之前确保gem install bcrypt -v '3.1.16' --source 'https://rubygems.org/' 成功。

在 Gemfile 中: 加密

安装 nio4r (2.5.7) 时出错,Bundler 无法继续。 在捆绑之前确保gem install nio4r -v '2.5.7' --source 'https://rubygems.org/' 成功。

在 Gemfile 中: rails 被解析为 6.1.3.1,这取决于 actioncable 被解析为 6.1.3.1,这取决于 nio4r

安装 racc (1.5.2) 时出错,Bundler 无法继续。 在捆绑之前确保gem install racc -v '1.5.2' --source 'https://rubygems.org/' 成功。

似乎没有任何效果,也没有关于如何解决问题的有用信息

【问题讨论】:

    标签: ruby-on-rails ubuntu deployment


    【解决方案1】:

    make: /usr/bin/mkdir: Command not found就是这个原因。

    请使用 sudo perm 编写此命令。

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

    然后再试一次。

    【讨论】:

    • 太棒了!非常感谢,但这是为什么呢?我通常与该用户一起使用mkdir.. 为什么捆绑找不到它?对我来说没有意义
    • 我不知道?我刚刚修复了我看到的错误
    【解决方案2】:

    发生这种情况是因为您需要安装 pg gem 所需的以下软件包:

    sudo apt install postgresql postgresql-contrib libpq-dev
    

    然后配置 postgres 并验证是否正在运行。

    【讨论】:

      猜你喜欢
      • 2012-03-03
      • 2014-09-14
      • 1970-01-01
      • 2017-08-27
      • 1970-01-01
      • 1970-01-01
      • 2012-10-09
      • 2018-10-01
      • 2015-07-21
      相关资源
      最近更新 更多