ruby - 更新到 Catalina 后无法安装 Jekyll - 安装 ffi (1.9.18) 时出错
问题描述
我已经更新了我的 mac 以使用 Catalina,现在我在尝试安装 Jekyll 时遇到了各种各样的问题。
这是我运行通常的 grunt 设置时得到的结果:
Running "jekyll:dist" (jekyll) task
>> Error: Command failed: bundle exec jekyll -v
>> bundler: command not found: jekyll
>> Install missing gem executables with `bundle install`
Warning: Please install Jekyll before running this task. Use --force to continue.
然后我跑sudo bundle install
然后我得到这个:
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this
application for all non-root users on this machine.
Fetching gem metadata from https://rubygems.org/.........
Using public_suffix 3.0.1
Using addressable 2.5.2
Using bundler 2.1.4
Using colorator 1.1.0
Fetching ffi 1.9.18
Installing ffi 1.9.18 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Applications/MAMP/htdocs/hangr/vendor/bundle/ruby/2.6.0/gems/ffi-1.9.18/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20201016-30905-1yh2cx1.rb extconf.rb
checking for ffi_call() in -lffi... yes
checking for ffi_prep_closure()... yes
checking for ffi_raw_call()... yes
checking for ffi_prep_raw_closure()... yes
checking for shlwapi.h... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
checking for ffi_prep_cif_var()... yes
creating extconf.h
creating Makefile
current directory: /Applications/MAMP/htdocs/hangr/vendor/bundle/ruby/2.6.0/gems/ffi-1.9.18/ext/ffi_c
make "DESTDIR=" clean
current directory: /Applications/MAMP/htdocs/hangr/vendor/bundle/ruby/2.6.0/gems/ffi-1.9.18/ext/ffi_c
make "DESTDIR="
compiling AbstractMemory.c
compiling ArrayType.c
compiling Buffer.c
compiling Call.c
Call.c:355:5: error: implicit declaration of function 'rb_thread_call_without_gvl' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
rbffi_thread_blocking_region(call_blocking_function, data, (void *) -1, NULL);
^
./Thread.h:78:39: note: expanded from macro 'rbffi_thread_blocking_region'
# define rbffi_thread_blocking_region rb_thread_call_without_gvl
^
1 error generated.
make: *** [Call.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Applications/MAMP/htdocs/hangr/vendor/bundle/ruby/2.6.0/gems/ffi-1.9.18 for inspection.
Results logged to
/Applications/MAMP/htdocs/hangr/vendor/bundle/ruby/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.9.18/gem_make.out
An error occurred while installing ffi (1.9.18), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.9.18' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
jekyll was resolved to 3.4.3, which depends on
jekyll-sass-converter was resolved to 1.5.1, which depends on
sass was resolved to 3.5.5, which depends on
sass-listen was resolved to 4.0.0, which depends on
rb-inotify was resolved to 0.9.10, which depends on
ffi
当我跑
ruby -v
我明白了
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
我完全不知道我需要做什么。
当我跑
jekyll -v
我明白了
-bash: /usr/local/bin/jekyll: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory
我尝试从另一个帖子运行它,但没有运气
gem install ffi -v '1.9.18' -- --with-cflags="-Wno-error=implicit-function-declaration"
有没有人有任何想法?
谢谢
解决方案
根本问题是您无法安装 jekyl 的依赖项之一 - 特别是 ffi gem。知道这将更好地帮助您进行修复。
您可以通过阅读您的捆绑输出看到这是错误。学习如何阅读这些内容,以便将来更好地帮助自己;如果您正在搜索“在 macOS 上安装 ffi”,您可能会找到更多可用的信息。
假设您刚刚安装了 Catalina,很可能 GCC 不在您的机器上,或者已经过时,或者没有链接。
尝试运行xcode-select --install
以(重新)安装 Xcode 命令行工具。
还 - 停止使用 SUDO
在你的包输出的最顶部是一个警告,你不应该sudo
在安装 gems 时使用它。这是一个很好的建议!
更好的建议是使用 rbenv 或 rvm 为您正在使用的每个 ruby 应用程序创建 gem 集或环境。但是,如果你没有一路走下去,** 至少,停止使用 sudo **
推荐阅读
- javascript - javascript ecma5 重载
- c - 从文件中读取行的函数,经过几次迭代会引发错误
- python - pyspark 'Index' 对象不可调用
- typescript - 从对象中删除空值的打字稿完全类型化函数
- python - 记录在特定频道 discord.py 中发送的所有消息
- angular - 带有参数的自定义验证器不适用于角度中的文本框和复选框
- javascript - 从 Firestore 查询返回数据数组
- vb.net - VB Linq GroupBy Min
- .net - 使用 Wix 安装 RabbitMQ,并设置节点名称
- javascript - MicroTask 在当前任务完成之前执行