我在macOS Big Sur上,最近安装了自制程序。安装工作正常,当我运行brew doctor时显示Your system is ready to brew.
。
我还成功地安装了使用自制软件的PostgreSQL。
现在我有了一个新的Rails应用程序,当我运行bundle时,我一直收到这个错误:
Installing pg 1.2.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/max/.rvm/gems/ruby-3.1.2/gems/pg-1.2.3/ext
/Users/max/.rvm/rubies/ruby-3.1.2/bin/ruby -I /Users/max/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0 -r ./siteconf20221017-65333-4ldjbt.rb extconf.rb
--with-cflags\=-Wno-error\=implicit-function-declaration
checking for pg_config... yes
Using config values from /usr/local/opt/libpq/bin/pg_config
*** 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
--without-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/max/.rvm/rubies/ruby-3.1.2/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
/Users/max/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/mkmf.rb:498:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/max/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/mkmf.rb:591:in `try_link0'
from /Users/max/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/mkmf.rb:609:in `try_link'
from extconf.rb:40:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/max/.rvm/gems/ruby-3.1.2/extensions/x86_64-darwin-19/3.1.0/pg-1.2.3/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/max/.rvm/gems/ruby-3.1.2/gems/pg-1.2.3 for inspection.
Results logged to /Users/max/.rvm/gems/ruby-3.1.2/extensions/x86_64-darwin-19/3.1.0/pg-1.2.3/gem_make.out
/Users/max/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:95:in `run'
/Users/max/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:47:in `block in build'
/Users/max/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/tempfile.rb:317:in `open'
/Users/max/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:26:in `build'
/Users/max/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:161:in `build_extension'
/Users/max/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:195:in `block in build_extensions'
/Users/max/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `each'
/Users/max/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `build_extensions'
/Users/max/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/installer.rb:853:in `build_extensions'
/Users/max/.rvm/gems/ruby-3.1.2/gems/bundler-2.3.16/lib/bundler/rubygems_gem_installer.rb:71:in `build_extensions'
/Users/max/.rvm/gems/ruby-3.1.2/gems/bundler-2.3.16/lib/bundler/rubygems_gem_installer.rb:28:in `install'
/Users/max/.rvm/gems/ruby-3.1.2/gems/bundler-2.3.16/lib/bundler/source/rubygems.rb:207:in `install'
/Users/max/.rvm/gems/ruby-3.1.2/gems/bundler-2.3.16/lib/bundler/installer/gem_installer.rb:54:in `install'
/Users/max/.rvm/gems/ruby-3.1.2/gems/bundler-2.3.16/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
/Users/max/.rvm/gems/ruby-3.1.2/gems/bundler-2.3.16/lib/bundler/installer/parallel_installer.rb:186:in `do_install'
/Users/max/.rvm/gems/ruby-3.1.2/gems/bundler-2.3.16/lib/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
/Users/max/.rvm/gems/ruby-3.1.2/gems/bundler-2.3.16/lib/bundler/worker.rb:62:in `apply_func'
/Users/max/.rvm/gems/ruby-3.1.2/gems/bundler-2.3.16/lib/bundler/worker.rb:57:in `block in process_queue'
/Users/max/.rvm/gems/ruby-3.1.2/gems/bundler-2.3.16/lib/bundler/worker.rb:54:in `loop'
/Users/max/.rvm/gems/ruby-3.1.2/gems/bundler-2.3.16/lib/bundler/worker.rb:54:in `process_queue'
/Users/max/.rvm/gems/ruby-3.1.2/gems/bundler-2.3.16/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads'
An error occurred while installing pg (1.2.3), and Bundler cannot continue.
In Gemfile:
pg
其他的gems安装得很好,但是pg似乎是问题所在。PostgreSQL已经安装在机器上了,我可以用psql
命令访问它。
也安装了libpq
,因为我在运行brew list
命令时列出了它。
我已经调查了终端上的这两条红色线,但没有找到解决方案。
错误1:Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
错误2:An error occurred while installing pg (1.2.3), and Bundler cannot continue.
请帮帮忙。
1条答案
按热度按时间iqih9akk1#
我能够通过重新安装Xcode并使用
brew install coreutils
安装coreutils
来修复此问题我还必须使用pg_config路径标志来安装pg。
gem install pg -- --with-pg-config=/path-to-pg-config/pg_config
它需要一点时间,然后安装pg gem。