Rails bundle 無法安裝 gem ffi



注意:我放弃了这个,决定尝试Rails 6和Webpacker,而不是打这场仗。继续其他战斗。

An error occurred while installing ffi (1.13.1), and Bundler cannot continue.我知道这是一个反复出现的问题,我以前在 nokogiri 遇到过这个问题,但这次似乎找不到解决方案。我已经阅读并尝试了许多基于搜索SO的建议,以及显示为类似问题的内容。

部分宝石文件:

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'

终端(略有编辑(,从响应错误开始:

➜ 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

我根据关于这个问题和类似问题的 SO 帖子尝试过的一些事情

删除了 Gemfile.lock,但仍bundle install失败

试过ruby-install ruby 2.7.0以防万一。我正在使用 chruby,但仍然bundle install失败

sudo xcodebuild -license,仍然bundle install失败

尝试注释掉源 github,但仍然bundle install失败

尝试gem install ffi,但仍然bundle install失败

我有另一个使用类似宝石的应用程序,但我已将其更新为 Rails 6,但它是 ruby-2.6.6,因此尝试在终端和 Gemfile 中更改为 ruby-2.6.6,运行bundle install并得到相同的失败,但nokogiri.

我在尝试对一个两年前的应用程序进行更改时陷入了困境,然后无法推送到 heroku。

我想我明白这是一个依赖问题,但除此之外我迷失了。感谢您的任何建议。

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

我发现这个答案(来自 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

收到此错误,并通过以下步骤解决:

  • https://medium.com/@leoliang.climber/missing-ffi-prep-closure-error-for-ffi-1-13-1-gem-70f800a48090

gem install ffi -- --disable-system-libffi

bundle install

编辑:我也必须在应用商店中安装xcode。 Ruby 版本 2.6.5,Rails 6。

我使用了上面的示例@chubb5000并添加了版本以使其工作:

gem install ffi -v 1.13.1 -- --disable-system-libffi

您需要先安装系统范围的库。在 Debian 派生的系统上,在终端中运行以下命令:

$ sudo apt-get install libjpeg-dev libpng-dev libtiff-dev libwebp-dev
$ bundle install

对我来说,这些解决方案都不起作用。我在 xcode 上遇到了问题,所以运行可以为我解决问题。

xcodebuild -runFirstLaunch

如果这些解决方案都不适合您,只需删除Gemfile.lock并再次运行bundle install

最新更新