如何在Mac Mini M1上安装gem pg?

4

我在我的M1 Mac Mini上安装gem pg时遇到了麻烦。我正在尝试将其托管到Heroku和Netlify上。想知道是否有人找到了解决方法。我已经尝试了Stack Overflow上的几种解决方案,但什么都不起作用。

请帮忙,我认为自己在这方面是个新手。

下面是我得到的错误信息:

`

jonathanbleibdrey@Little-Mac listen_to_the_humans % gem install pg
Building native extensions. This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

    current directory: /Users/jonathanbleibdrey/.rvm/gems/ruby-2.6.1/gems/pg-1.2.3/ext
/Users/jonathanbleibdrey/.rvm/rubies/ruby-2.6.1/bin/ruby -I /Users/jonathanbleibdrey/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0 -r ./siteconf20210323-28582-1dv0k5o.rb extconf.rb
checking for pg_config... yes
Using config values from /opt/homebrew/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... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/Users/jonathanbleibdrey/.rvm/rubies/ruby-2.6.1/bin/$(RUBY_BASE_NAME)
        --with-pg
        --without-pg
        --enable-windows-cross
        --disable-windows-cross
        --with-pg-config
        --without-pg-config
        --with-pg_config
        --without-pg_config
        --with-pg-dir
        --without-pg-dir
        --with-pg-include
        --without-pg-include=${pg-dir}/include
        --with-pg-lib
        --without-pg-lib=${pg-dir}/lib
        --with-pqlib
        --without-pqlib
        --with-libpqlib
        --without-libpqlib
        --with-ms/libpqlib
        --without-ms/libpqlib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/jonathanbleibdrey/.rvm/gems/ruby-2.6.1/extensions/x86_64-darwin-19/2.6.0/pg-1.2.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/jonathanbleibdrey/.rvm/gems/ruby-2.6.1/gems/pg-1.2.3 for inspection.
Results logged to /Users/jonathanbleibdrey/.rvm/gems/ruby-2.6.1/extensions/x86_64-darwin-19/2.6.0/pg-1.2.3/gem_make.out

请告诉我可以做什么或可以找到哪些资源,甚至我们是否可以通过Zoom解决它。 我希望在一周内推出它。

2个回答

1

我最初在m1上安装pg gem时遇到的问题的关键是,通过brew安装postgresql没有安装pg gem运行所需的库。解决方法如下:

brew install libpq
export PATH="/opt/homebrew/opt/libpq/bin:$PATH"
gem install pg

0
搞定了:我发现我的Homebrew中有一些过时的依赖关系。我所要做的就是运行以下命令:

homebrew upgrade

我想应该可以了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接