[英]Rails bundle can't install gem ffi
Note: I gave up on this and decided to try Rails 6 and Webpacker rather than fighting this fight.注意:我放弃了这个并决定尝试 Rails 6 和 Webpacker 而不是打这场仗。 Moving on to other fights.继续进行其他战斗。
An error occurred while installing ffi (1.13.1), and Bundler cannot continue.
I know this a recurring problem and I've run into it before with nokogiri, but can't seem to find the solution this time.我知道这是一个反复出现的问题,我之前使用 nokogiri 遇到过它,但这次似乎找不到解决方案。 I have read and tried many suggestions based on searching SO and what shows up as similar questions.我已经阅读并尝试了许多基于搜索 SO 的建议以及显示为类似问题的内容。
Partial Gemfile:部分宝石文件:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
ruby '2.7.0'
gem 'rails', '~> 5.2.0'
gem 'pg' , '~> 0.18'
gem 'puma'
gem 'bootstrap', '~> 4'
Terminal (edited slightly), starting at responding to the error:终端(稍作编辑),从响应错误开始:
➜ gem install ffi -v '1.13.1' --source 'https://rubygems.org/'
Building native extensions. This could take a while...
Successfully installed ffi-1.13.1
1 gem installed
➜ bundle update
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies..........
Using rake 13.0.1
<long list of gems installed>
Using bundler 2.1.4
Using rails 5.2.4.3
Using execjs 2.7.0
Fetching ffi 1.13.1
Installing ffi 1.13.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: <project>/vendor/bundle/ruby/2.7.0/gems/ffi-1.13.1/ext/ffi_c
/Users/me/.rubies/ruby-2.7.0/bin/ruby -I ~/.rubies/ruby-2.7.0/lib/ruby/2.7.0 -r ./siteconf20200613-94985-w9dh35.rb extconf.rb
checking for ffi_prep_closure_loc() in -lffi... no
checking for ffi_prep_closure_loc() in -llibffi... no
checking for ffi_prep_closure_loc() in -llibffi-8... no
creating extconf.h
creating Makefile
current directory: <project>/vendor/bundle/ruby/2.7.0/gems/ffi-1.13.1/ext/ffi_c
make "DESTDIR=" clean
current directory: <project>/vendor/bundle/ruby/2.7.0/gems/ffi-1.13.1/ext/ffi_c
make "DESTDIR="
/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file
make: *** ["/Users/me/Documents/Folder] Error 2
make failed, exit code 2
Gem files will remain installed in <project>/vendor/bundle/ruby/2.7.0/gems/ffi-1.13.1 for inspection.
Results logged to <project>/vendor/bundle/ruby/2.7.0/extensions/x86_64-darwin-18/2.7.0-static/ffi-1.13.1/gem_make.out
An error occurred while installing ffi (1.13.1), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.13.1' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
ffi
Some of the things I've tried based on SO posts on this and similar problems我根据关于这个问题和类似问题的 SO 帖子尝试过的一些事情
Removed Gemfile.lock and still bundle install
failed删除了 Gemfile.lock 仍然bundle install
失败
Tried ruby-install ruby 2.7.0
just in case.试过ruby-install ruby 2.7.0
以防万一。 I'm using chruby and still bundle install
failed我正在使用 chruby,但仍然bundle install
失败
sudo xcodebuild -license
and still bundle install
failed sudo xcodebuild -license
仍然bundle install
失败
Tried commenting out source github and still bundle install
failed尝试注释掉源代码 github 仍然bundle install
失败
Tried gem install ffi
and still bundle install
failed试过gem install ffi
还是bundle install
失败
I have another app that uses similar gems but I had updated it to Rails 6, but it was at ruby-2.6.6, so tried changing to ruby-2.6.6 in terminal and Gemfile, ran bundle install
and got the same kind of failure but for nokogiri
.我有另一个使用类似 gems 的应用程序,但我已将它更新到 Rails 6,但它是 ruby-2.6.6,所以尝试在终端和 Gemfile 中更改为 ruby-2.6.6,运行bundle install
并获得相同类型的失败除了nokogiri
。
I got trapped in this while trying to make changes on a two-year old app and then couldn't push to heroku.我在尝试对一个已有两年历史的应用程序进行更改时陷入此困境,然后无法推送到 heroku。
I think I get that this a dependency issue, but am lost beyond that.我想我知道这是一个依赖性问题,但除此之外我迷路了。 Thanks for any suggestions.感谢您的任何建议。
Gemfile.lock
with everything that depends on ffi
removed (bootstrap) so bundle update
could run without errors. Gemfile.lock
了所有依赖于ffi
的东西(引导程序),因此bundle update
可以无误地运行。
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.4.3)
actionpack (= 5.2.4.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.4.3)
actionpack (= 5.2.4.3)
actionview (= 5.2.4.3)
activejob (= 5.2.4.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.4.3)
actionview (= 5.2.4.3)
activesupport (= 5.2.4.3)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.4.3)
activesupport (= 5.2.4.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.4.3)
activesupport (= 5.2.4.3)
globalid (>= 0.3.6)
activemodel (5.2.4.3)
activesupport (= 5.2.4.3)
activerecord (5.2.4.3)
activemodel (= 5.2.4.3)
activesupport (= 5.2.4.3)
arel (>= 9.0)
activerecord-postgis-adapter (5.2.2)
activerecord (~> 5.1)
rgeo-activerecord (~> 6.0)
activestorage (5.2.4.3)
actionpack (= 5.2.4.3)
activerecord (= 5.2.4.3)
marcel (~> 0.3.1)
activesupport (5.2.4.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
ansi (1.5.0)
arel (9.0.0)
ast (2.4.1)
awesome_print (1.8.0)
aws-eventstream (1.1.0)
aws-partitions (1.329.0)
aws-sdk-core (3.99.2)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-kms (1.34.1)
aws-sdk-core (~> 3, >= 3.99.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.68.1)
aws-sdk-core (~> 3, >= 3.99.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.1.4)
aws-eventstream (~> 1.0, >= 1.0.2)
bcrypt (3.1.13)
better_errors (2.7.1)
coderay (>= 1.0.0)
erubi (>= 1.0.0)
rack (>= 0.9.0)
bindex (0.8.1)
binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
builder (3.2.4)
byebug (11.1.3)
capybara (2.18.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (>= 2.0, < 4.0)
carrierwave (1.1.0)
activemodel (>= 4.0.0)
activesupport (>= 4.0.0)
mime-types (>= 1.16)
childprocess (3.0.0)
choice (0.2.0)
coderay (1.1.3)
comfy_bootstrap_form (4.0.9)
rails (>= 5.0.0)
concurrent-ruby (1.1.6)
crass (1.0.6)
database_cleaner (1.8.5)
debug_inspector (0.0.3)
docile (1.3.2)
dotenv (2.7.5)
dotenv-rails (2.7.5)
dotenv (= 2.7.5)
railties (>= 3.2, < 6.1)
erubi (1.9.0)
execjs (2.7.0)
font-awesome-rails (4.7.0.5)
railties (>= 3.2, < 6.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
gon (6.3.2)
actionpack (>= 3.0.20)
i18n (>= 0.7)
multi_json
request_store (>= 1.0)
guard-compat (1.2.1)
guard-minitest (2.4.6)
guard-compat (~> 1.2)
minitest (>= 3.0)
heroku_db_restore (0.0.5)
i18n (1.8.3)
concurrent-ruby (~> 1.0)
jbuilder (2.10.0)
activesupport (>= 5.0.0)
jmespath (1.4.0)
jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (6.0.1)
railties (>= 3.2.16)
leaflet-draw-rails (0.1.0)
loofah (2.5.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.0512)
mimemagic (0.3.5)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.1)
minitest-reporters (1.1.9)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
multi_json (1.14.1)
nio4r (2.5.2)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
paper_trail (10.3.1)
activerecord (>= 4.2)
request_store (~> 1.1)
parallel (1.19.1)
parser (2.7.1.3)
ast (~> 2.4.0)
pg (0.21.0)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.9.0)
byebug (~> 11.0)
pry (~> 0.13.0)
public_suffix (4.0.5)
puma (4.3.5)
nio4r (~> 2.0)
rack (2.2.2)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.4.3)
actioncable (= 5.2.4.3)
actionmailer (= 5.2.4.3)
actionpack (= 5.2.4.3)
actionview (= 5.2.4.3)
activejob (= 5.2.4.3)
activemodel (= 5.2.4.3)
activerecord (= 5.2.4.3)
activestorage (= 5.2.4.3)
activesupport (= 5.2.4.3)
bundler (>= 1.3.0)
railties (= 5.2.4.3)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.2)
actionpack (~> 5.x, >= 5.0.1)
actionview (~> 5.x, >= 5.0.1)
activesupport (~> 5.x)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-erd (1.6.0)
activerecord (>= 4.2)
activesupport (>= 4.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (5.2.4.3)
actionpack (= 5.2.4.3)
activesupport (= 5.2.4.3)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rainbow (3.0.0)
rake (13.0.1)
regexp_parser (1.7.1)
request_store (1.5.0)
rack (>= 1.4)
rexml (3.2.4)
rgeo (2.1.1)
rgeo-activerecord (6.2.1)
activerecord (>= 5.0)
rgeo (>= 1.0.0)
rgeo-geojson (2.1.1)
rgeo (>= 1.0.0)
rubocop (0.85.1)
parallel (~> 1.10)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.0.3)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.0.3)
parser (>= 2.7.0.1)
ruby-graphviz (1.2.5)
rexml
ruby-progressbar (1.10.1)
rubyzip (2.3.0)
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
simplecov (0.18.5)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov-html (0.12.2)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
super_awesome_print (0.2.5)
awesome_print
tether-rails (1.4.0)
rails (>= 3.1)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.7.0)
web-console (3.7.0)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
websocket-driver (0.7.2)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
PLATFORMS
ruby
DEPENDENCIES
activerecord-postgis-adapter
awesome_print
aws-sdk-s3 (~> 1)
bcrypt (~> 3.1.11)
better_errors
binding_of_caller
byebug
capybara (~> 2.13)
carrierwave (= 1.1.0)
comfy_bootstrap_form (~> 4.0.0)
database_cleaner
dotenv-rails
font-awesome-rails
gon
guard-minitest (= 2.4.6)
heroku_db_restore
jbuilder (~> 2.7)
jquery-rails
jquery-ui-rails
leaflet-draw-rails
minitest-reporters (= 1.1.9)
paper_trail
pg (~> 0.18)
pry-byebug
puma
rails (~> 5.2.0)
rails-controller-testing (= 1.0.2)
rails-erd
rgeo-geojson
rubocop
selenium-webdriver
simplecov
super_awesome_print
tether-rails
uglifier
web-console (>= 3.5.1)
RUBY VERSION
ruby 2.7.0p0
BUNDLED WITH
2.1.4
I found this answer (from https://stackoverflow.com/a/63267668/592820 ) helpful:我发现这个答案(来自https://stackoverflow.com/a/63267668/592820 )很有帮助:
brew upgrade libffi
export LDFLAGS="-L/usr/local/opt/libffi/lib"
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
bundle install
Was getting this error and resolved by following steps in:收到此错误并通过以下步骤解决:
gem install ffi -- --disable-system-libffi
bundle install
Edit: I had to install xcode in appstore as well.编辑:我还必须在 appstore 中安装 xcode。 ruby version 2.6.5, rails 6. ruby 版本 2.6.5,导轨 6。
I used the example above that @chubb5000 and added the version to make it work:我使用了上面的示例 @chubb5000 并添加了版本以使其工作:
gem install ffi -v 1.13.1 -- --disable-system-libffi
You need to install the system-wide libraries first.您需要先安装系统范围的库。 On Debian-derived systems, run the following commands in your terminal:在 Debian 派生系统上,在终端中运行以下命令:
$ sudo apt-get install libjpeg-dev libpng-dev libtiff-dev libwebp-dev
$ bundle install
For me, none of these solutions works.对我来说,这些解决方案都不起作用。 I had an issue with xcode so running fix the issue for me.我遇到了 xcode 的问题,所以运行解决了这个问题。
xcodebuild -runFirstLaunch
If none of these solutions works for you, just remove the Gemfile.lock
and run bundle install
again如果这些解决方案都不适合您,只需删除Gemfile.lock
并再次运行bundle install
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.