[英]Gem 'ruby-jq' compilation error by Apple M1 (ARM) chip
我正在尝试将安装 Sinatra 项目与gem 'ruby-jq'
bundle install
。 我发现它适用于配备英特尔芯片的 Mac。 我的 Apple M1 Max 芯片结果:
➜ my_service git:(develop) ✗ bundle install
Warning: the running version of Bundler (2.2.22) is older than the version that created the lockfile (2.3.13). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.3.13`.
Fetching gem metadata from https://rubygems.org/
Fetching gem metadata from https://rubygems.org/.........
Using rake 13.0.6
...
Using bundler 2.2.22
...
Fetching ruby-jq 0.2.1
...
Installing ruby-jq 0.2.1 with native extensions
...
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/ruby-jq-0.2.1/ext
/Users/Sergey.Kovalov/.rvm/rubies/ruby-3.0.2/bin/ruby -I /Users/Sergey.Kovalov/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0 -r ./siteconf20220826-74763-mnprea.rb extconf.rb
Buildling jq using packaged libraries.
Downloading jq-1.6.tar.gz
...
Downloading jq-1.6.tar.gz
Extracting jq-1.6.tar.gz into tmp/arm64-apple-darwin21.6.0/ports/jq/1.6... OK
Running 'autoreconf' for jq 1.6... OK
Running 'configure' for jq 1.6... OK
Running 'compile' for jq 1.6... ERROR, review '/Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/ruby-jq-0.2.1/ext/tmp/arm64-apple-darwin21.6.0/ports/jq/1.6/compile.log' to see what happened. Last lines are:
========================================================================
GEN src/builtin.inc
fatal: not a git repository (or any of the parent directories): .git
GEN src/version.h
fatal: not a git repository (or any of the parent directories): .git
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive
Making all in modules/oniguruma
make[2]: *** No rule to make target `all'. Stop.
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
========================================================================
*** 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/Sergey.Kovalov/.rvm/rubies/ruby-3.0.2/bin/$(RUBY_BASE_NAME)
--use-system-libraries
/Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/mini_portile2-2.8.0/lib/mini_portile2/mini_portile.rb:460:in `block in execute': Failed to complete compile task (RuntimeError)
from /Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/mini_portile2-2.8.0/lib/mini_portile2/mini_portile.rb:426:in `chdir'
from /Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/mini_portile2-2.8.0/lib/mini_portile2/mini_portile.rb:426:in `execute'
from /Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/mini_portile2-2.8.0/lib/mini_portile2/mini_portile.rb:144:in `compile'
from /Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/mini_portile2-2.8.0/lib/mini_portile2/mini_portile.rb:187:in `cook'
from extconf.rb:27:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/ruby-jq-0.2.1 for inspection.
Results logged to /Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/extensions/arm64-darwin-21/3.0.0/ruby-jq-0.2.1/gem_make.out
An error occurred while installing ruby-jq (0.2.1), and Bundler cannot continue.
Make sure that `gem install ruby-jq -v '0.2.1' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
ruby-jq
**********
➜ my_service git:(develop) ✗ gem install ruby-jq -v '0.2.1' --source 'https://rubygems.org/'
Building native extensions. This could take a while...
ERROR: Error installing ruby-jq:
ERROR: Failed to build gem native extension.
current directory: /Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/ruby-jq-0.2.1/ext
/Users/Sergey.Kovalov/.rvm/rubies/ruby-3.0.2/bin/ruby -I /Users/Sergey.Kovalov/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0 -r ./siteconf20220826-78454-9gmb3t.rb extconf.rb
Buildling jq using packaged libraries.
Downloading jq-1.6.tar.gz
Extracting jq-1.6.tar.gz into tmp/arm64-apple-darwin21.6.0/ports/jq/1.6... OK
Running 'autoreconf' for jq 1.6... OK
Running 'configure' for jq 1.6... OK
Running 'compile' for jq 1.6... ERROR, review '/Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/ruby-jq-0.2.1/ext/tmp/arm64-apple-darwin21.6.0/ports/jq/1.6/compile.log' to see what happened. Last lines are:
========================================================================
GEN src/builtin.inc
fatal: not a git repository (or any of the parent directories): .git
GEN src/version.h
fatal: not a git repository (or any of the parent directories): .git
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive
Making all in modules/oniguruma
make[2]: *** No rule to make target `all'. Stop.
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
========================================================================
*** 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/Sergey.Kovalov/.rvm/rubies/ruby-3.0.2/bin/$(RUBY_BASE_NAME)
--use-system-libraries
/Users/Sergey.Kovalov/.rvm/rubies/ruby-3.0.2/lib/ruby/gems/3.0.0/gems/mini_portile2-2.8.0/lib/mini_portile2/mini_portile.rb:460:in `block in execute': Failed to complete compile task (RuntimeError)
from /Users/Sergey.Kovalov/.rvm/rubies/ruby-3.0.2/lib/ruby/gems/3.0.0/gems/mini_portile2-2.8.0/lib/mini_portile2/mini_portile.rb:426:in `chdir'
from /Users/Sergey.Kovalov/.rvm/rubies/ruby-3.0.2/lib/ruby/gems/3.0.0/gems/mini_portile2-2.8.0/lib/mini_portile2/mini_portile.rb:426:in `execute'
from /Users/Sergey.Kovalov/.rvm/rubies/ruby-3.0.2/lib/ruby/gems/3.0.0/gems/mini_portile2-2.8.0/lib/mini_portile2/mini_portile.rb:144:in `compile'
from /Users/Sergey.Kovalov/.rvm/rubies/ruby-3.0.2/lib/ruby/gems/3.0.0/gems/mini_portile2-2.8.0/lib/mini_portile2/mini_portile.rb:187:in `cook'
from extconf.rb:27:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/ruby-jq-0.2.1 for inspection.
Results logged to /Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/extensions/arm64-darwin-21/3.0.0/ruby-jq-0.2.1/gem_make.out
gem_make.out 文件内容:
current directory: /Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/ruby-jq-0.2.1/ext
/Users/Sergey.Kovalov/.rvm/rubies/ruby-3.0.2/bin/ruby -I /Users/Sergey.Kovalov/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0 -r ./siteconf20220826-82776-3jn351.rb extconf.rb
Buildling jq using packaged libraries.
Downloading jq-1.6.tar.gz ( 0%)
...
Downloading jq-1.6.tar.gz (100%)
Extracting jq-1.6.tar.gz into tmp/arm64-apple-darwin21.6.0/ports/jq/1.6... OK
Running 'autoreconf' for jq 1.6... OK
Running 'configure' for jq 1.6... OK
Running 'compile' for jq 1.6... ERROR, review '/Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/ruby-jq-0.2.1/ext/tmp/arm64-apple-darwin21.6.0/ports/jq/1.6/compile.log' to see what happened. Last lines are:
========================================================================
GEN src/builtin.inc
fatal: not a git repository (or any of the parent directories): .git
GEN src/version.h
fatal: not a git repository (or any of the parent directories): .git
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive
Making all in modules/oniguruma
make[2]: *** No rule to make target `all'. Stop.
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
========================================================================
*** 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/Sergey.Kovalov/.rvm/rubies/ruby-3.0.2/bin/$(RUBY_BASE_NAME)
--use-system-libraries
/Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/mini_portile2-2.8.0/lib/mini_portile2/mini_portile.rb:460:in `block in execute': Failed to complete compile task (RuntimeError)
from /Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/mini_portile2-2.8.0/lib/mini_portile2/mini_portile.rb:426:in `chdir'
from /Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/mini_portile2-2.8.0/lib/mini_portile2/mini_portile.rb:426:in `execute'
from /Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/mini_portile2-2.8.0/lib/mini_portile2/mini_portile.rb:144:in `compile'
from /Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2/gems/mini_portile2-2.8.0/lib/mini_portile2/mini_portile.rb:187:in `cook'
from extconf.rb:27:in `<main>'
extconf failed, exit code 1
我还尝试了不同的安装选项和品种,例如:
RUBYJQ_USE_SYSTEM_LIBRARIES=true gem install ruby-jq -v '0.2.1'
***
arch -x86_64 gem install ruby-jq -v '0.2.1' --source 'https://rubygems.org/'
***
bundle config --global build.ruby-jq --use-system-libraries --with-jqlib=/opt/homebrew/lib/
***
bundle config --global build.ruby-jq --use-system-libraries --with-jq-dir=/opt/homebrew/bin/jq
来自我的笔记本电脑的信息:
➜ my_service git:(develop) ✗ rvm list
=* ruby-3.0.2 [ arm64 ]
# => - current
# =* - current && default
# * - default
***
➜ my_service git:(develop) ✗ echo $GEM_HOME
/Users/Sergey.Kovalov/.rvm/gems/ruby-3.0.2
➜ my_service git:(develop) ✗ jq --version
jq-1.6
***
➜ my_service git:(develop) ✗ which jq
/opt/homebrew/bin/jq
***
➜ my_service git:(develop) ✗ ls -lah /opt/homebrew/lib/ | grep -i libjq
lrwxr-xr-x 1 Sergey.Kovalov admin 34B 25 Aug 09:45 libjq.1.dylib -> ../Cellar/jq/1.6/lib/libjq.1.dylib
lrwxr-xr-x 1 Sergey.Kovalov admin 28B 25 Aug 09:45 libjq.a -> ../Cellar/jq/1.6/lib/libjq.a
lrwxr-xr-x 1 Sergey.Kovalov admin 32B 25 Aug 09:45 libjq.dylib -> ../Cellar/jq/1.6/lib/libjq.dylib
顺便说一句,将gem 原始存储库克隆到本地机器并将Gemfile
中的路径设置为gem 'ruby-jq', path: '/Users/Sergey.Kovalov/work/ruby-jq'
有效,并且bundle install
成功完成。
关键是使用https://rubygems.org/gems/ruby-jq/源完成bundle install
。 请告知或告诉您如何解决此问题。
一位来自在线学校的同事提供了正确的参数如何设置bundle config
:
brew install jq
bundle config set build.ruby-jq --use-system-libraries --with-jq-dir=$(brew --prefix jq)
bundle install
在 Apple M1 Max 芯片上验证:
➜ my_service git:(develop) ✗ ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin21]
➜ my_service git:(develop) ✗ jq --version
jq-1.6
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.