ERROR: Failed to build gem native extension.在M1芯片中找不到potrace



我试图在我的Macbook Air上安装Rails 5应用程序。这个应用程序使用了一个名为potracer的gem。

执行$ bundle install后,我得到错误:

Installing potracer 1.1.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/user/.rvm/gems/ruby-2.7.2/gems/potracer-1.1.4/ext/potracer
/Users/user/.rvm/rubies/ruby-2.7.2/bin/ruby -I /Users/user/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0 -r ./siteconf20211025-1533-nnxnj9.rb extconf.rb
checking for potracelib.h... no
potracelib.h not found
*** 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/user/.rvm/rubies/ruby-2.7.2/bin/$(RUBY_BASE_NAME)
--with-potrace-dir
--without-potrace-dir
--with-potrace-include
--without-potrace-include=${potrace-dir}/include
--with-potrace-lib
--without-potrace-lib=${potrace-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/user/.rvm/gems/ruby-2.7.2/extensions/arm64-darwin-20/2.7.0/potracer-1.1.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/user/.rvm/gems/ruby-2.7.2/gems/potracer-1.1.4 for inspection.
Results logged to /Users/user/.rvm/gems/ruby-2.7.2/extensions/arm64-darwin-20/2.7.0/potracer-1.1.4/gem_make.out
An error occurred while installing potracer (1.1.4), and Bundler cannot continue.
Make sure that `gem install potracer -v '1.1.4' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
potracer

我有其他问题安装其他rails应用程序与M1芯片,但我找到了解决方案,但不是在这种情况下。

如何解决这个问题?

您必须在本地重新安装posttrace。安装似乎不完整。

需要安装库/headers。根据你的平台,它可能是像libpotrace和libpitrace-dev这样的东西。

你可以通过homebrew, apt, dnf等安装它们。

除非您在本地获得potrace.h,否则执行potrace会中止。

abort potracelib.h not found'除非find_header('potracelib.h')

require 'mkmf'
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
LIBDIR = RbConfig::CONFIG['libdir']
INCLUDEDIR = RbConfig::CONFIG['includedir']
HEADER_DIRS = ['/opt/local/include', '/usr/local/include', INCLUDEDIR,
'/usr/include']
LIB_DIRS = ['/opt/local/lib', '/usr/local/lib', LIBDIR, '/usr/lib']
dir_config('potrace', HEADER_DIRS, LIB_DIRS)
abort 'potracelib.h not found' unless find_header('potracelib.h')
abort 'lib potrace not found' unless find_library('potrace', 'potrace_version')
create_header
create_makefile('potracer/potracer')

来源:https://github.com/kennyp/potracer/blob/b67d3ff6a1ae672ccc6701fa5245fa532b461ef3/ext/potracer/extconf.rb

最新更新