几天前,我做了一个Mac OS Sierra 10.12.6安全更新2018-005。昨天我咕gr一声,得到了:
Warning: Running "sass:dist" (sass) task
Warning: spawn sass ENOENT Use --force to continue.
Aborted due to warnings.
我按照此处的说明进行操作:https://github.com/appseed-io/supermodular/issues/45
xcode-select --install
sudo gem update --system
sudo gem install -n /usr/local/bin compass
我仍然遇到咕unt的错误:
Running "sass:build" (sass) task
ERROR: Cannot load compass.
Warning: Exited with error code 1 Use --force to continue.
Aborted due to warnings.
然后我按照此处的说明进行操作:https://halfelf.org/2017/grunt-cant-build-sass-on-high-sierra/
brew install rbenv ruby-build
rbenv install 2.4.2
rbenv global 2.4.2
sudo gem update --system
sudo gem install -n /usr/local/bin sass
仍然发牢骚ERROR: Cannot load compass.
然后再次尝试sudo gem install -n /usr/local/bin compass
,但出现以下错误:
ERROR: Error installing compass:
ERROR: Failed to build gem native extension.
我检查了mkmf.log文件,该文件显示:
"pkg-config --exists libffi"
package configuration for libffi is not found
"xcrun clang -o conftest -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin16 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -iwithsysroot /usr/local/libressl/include conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib -L. -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.Internal.sdk/usr/local/libressl/lib -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.Internal.sdk/usr/local/lib -arch x86_64 -arch i386 -lruby.2.3.0 -lpthread -ldl -lobjc "
In file included from conftest.c:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby.h:33:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found
#include "ruby/config.h"
^~~~~~~~~~~~~~~
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
我从中得到的(不是很清楚)是package configuration for libffi is not found
和fatal error: 'ruby/config.h' file not found
。
其他信息:
Xcode 9.2版(9C40b)
ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin16]
sass -v
Sass 3.4.25 (Selective Steve)
compass -v
-bash: /usr/local/bin/compass:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby: bad interpreter: No such file or directory
谢谢。
更新
我跑了gem env
。这是输出:
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.8
- RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin16]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/username/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- SPEC CACHE DIRECTORY: /Users/username/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-16
- GEM PATHS:
- /Library/Ruby/Gems/2.3.0
- /Users/username/.gem/ruby/2.3.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/username/.nvm/versions/node/v8.4.0/bin
- /Users/username/.wp-cli/bin
- /usr/local/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
答案 0 :(得分:2)
不要sudo gem install -n /usr/local/bin compass
使用rbenv
的全部目的是让它处理所有依赖关系,而完全不必处理OS系统ruby或它的宝石。您需要正确配置$PATH
,然后再也不需要使用sudo
,实际上,在获取环境之后,您不应该使用gem install
或任何gem
命令正确设置。
您碰巧尝试过npm install -g grunt-cli
吗?
更新:不出所料,您的$ PATH不正确。
关闭所有端子。开始一个新的。然后运行它。
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
这应该有助于您找出$PATH
设置中存在的问题。
请参阅https://github.com/rbenv/rbenv#installation
但首先要专门尝试:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
然后重新启动终端,再次检查gem env
,看看您的路径是否包含.rbenv
如果这些步骤不起作用,那么我建议fully uninstall rbenv并从https://github.com/rbenv/rbenv#installation的步骤1重新开始