ruby-on-rails - 如何在 mac mini m1 上安装 gem pg?
问题描述
我在我的 m1 mac mini 上安装 gem pg 时遇到问题。我试图托管到 Heroku 和 netlify。想知道是否有人找到了解决方法。我已经尝试了几种堆栈溢出的解决方案,但没有任何效果。
请帮忙,我认为自己是这种东西的菜鸟。
下面是我得到的错误。
`
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
`
让我知道我能做什么或我能找到的资源,或者即使我们可以缩放来修复它也想在一周内启动它。
解决方案
我在 m1 上安装 gem 的最初问题的关键pg
是通过 brew 安装 postgresql 并没有安装 pg gem 需要运行的库。这修复了它:
brew install libpq
export PATH="/opt/homebrew/opt/libpq/bin:$PATH"
gem install pg
推荐阅读
- hyperledger-fabric - 截止日期前无法连接
- reactjs - 如何在axios中重定向?
- javascript - 如何使用 jQuery 在页面加载时找到选定的单选按钮?
- ios - swift - 如何禁用 iOS tableView 上的点击历史记录
- c# - TFS 2017 - 错误 MSB4126:指定的解决方案配置“dev|any cpu”无效
- django - Django 重定向到 /accounts/profile
- javascript - 如何显示从 HttpResponseErrInterceptor 到特定控制器的响应消息
- c++ - 为什么 google styleguide 建议默认使用可选的 int64_t 来处理大整数?
- javascript - ng-view 在 angularjs 1 中不起作用
- java - 如何将此 FOR 循环转换为 WHILE 循环,以便它也适用于辅音?(JAVA)