简体   繁体   English

无法在 Mac Big Sur 11.5.2 上安装 Ruby Compass

[英]Can't install Ruby Compass on Mac Big Sur 11.5.2

I'm trying to get Compass installed on a 2020 Mac Book Pro running Big Sur (11.5.2).我正在尝试在运行 Big Sur (11.5.2) 的 2020 Mac Book Pro 上安装 Compass。

When I try and run:当我尝试运行时:

gem install compass

I get the error:我得到错误:

You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory

If I try and run:如果我尝试运行:

sudo gem install compass

I get the error:我得到错误:

ERROR:  Error installing compass:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/ext/ffi_c

I've tried installing and updating Ruby.我已经尝试安装和更新 Ruby。 I've tried updating the system Ruby, but the system doesn't allow a more recent version than the below:我已经尝试更新系统 Ruby,但系统不允许比以下版本更新:

Updating rubygems-update
Fetching rubygems-update-3.3.3.gem
Successfully installed rubygems-update-3.3.3
Parsing documentation for rubygems-update-3.3.3
Installing ri documentation for rubygems-update-3.3.3
Installing darkfish documentation for rubygems-update-3.3.3
Done installing documentation for rubygems-update after 206 seconds
Parsing documentation for rubygems-update-3.3.3
Done installing documentation for rubygems-update after 0 seconds
Installing RubyGems 3.3.3
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/gem

 % ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]

Not sure what to do or try next.不确定下一步该做什么或尝试。

Anyone have any ideas on how to get Compass installed?有人对如何安装 Compass 有任何想法吗?

This really decomposes to two issues, as you noticed with the sudo call.正如您在sudo调用中注意到的那样,这实际上分解为两个问题。

(1) You're trying to write gems to the protected directory for your system Ruby. (1) 您正在尝试将 gems 写入系统 Ruby 的受保护目录。

In most development environments, it's best to install a Ruby version manager that allows you to install multiple Rubies side-by-side for different projects.在大多数开发环境中,最好安装一个 Ruby 版本管理器,它允许您为不同的项目并排安装多个 Rubies。 Purely subjectively, I'd recommend rbenv to manage only Ruby, or asdf to manage Ruby versions along with other languages versions.纯粹主观上,我建议rbenv管理 Ruby,或asdf管理 Ruby 版本以及其他语言版本。 However, the question of which Ruby version manager to use is very well tread already , so you can pick the solution that's best for your needs with existing information.但是,使用哪个 Ruby 版本管理器的问题已经很好解决了,因此您可以根据现有信息选择最适合您需求的解决方案。

(2) You're installing a gem with native extensions, which means that you need the underlying C libraries installed on your system to build correctly (assuming you're using CRuby, the default Ruby implementation). (2) 您正在安装带有本机扩展的 gem,这意味着您需要安装在系统上的底层 C 库才能正确构建(假设您使用的是 CRuby,默认的 Ruby 实现)。 You'll need to install libffi-dev on your machine to build that gem correctly.您需要在您的机器上安装libffi-dev才能正确构建该 gem。 Based on this question , it seems a simple brew install libffi should work for that.基于这个问题,似乎一个简单的brew install libffi应该可以解决这个问题。

Lastly, I'll suggest that it's idiomatic to use the bundler gem to manage gems per-project with Ruby.最后,我建议使用捆绑器bundler来管理 Ruby 的每个项目的 gem 是惯用的。 I'd reconsider if you really want to run this gem system-wide, or if it might vary versions across multiple projects.我会重新考虑您是否真的想在整个系统范围内运行这个 gem,或者它是否可能在多个项目中改变版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM