Delowar Hosain
Delowar Hosain

Reputation: 2369

Sass is not working & Can't install ruby-sass on macOS Catalina

Ruby sass is not working after upgrading to macOS Catalina beta.

When I run sudo gem install sass, I'm getting an error:

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

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.11.1/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20191007-37566-177grvx.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/include/ruby.h

You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.11.1 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.11.1/gem_make.out```

Upvotes: 5

Views: 8248

Answers (4)

Ukr
Ukr

Reputation: 2694

In my case several Ruby folders and files didn't have permissions to enter directories and read files.

  • macOS Catalina 10.15.7
  • ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
{{ disable SIP Security }} 

$ sudo find /Library/Ruby/ -type d -exec chmod -v o+x {} +
$ sudo chmod -Rv go+r /Library/Ruby/

{{ enable SIP Security }}

Upvotes: 0

SteppingHat
SteppingHat

Reputation: 1372

Since macOS Catalina has removed ruby from the base install, you are no longer able to execute the sass executable installed via gem.

However, you can install Dart Sass as instructed on the sass website:

Install on Mac OS X (Homebrew)

If you use the Homebrew package manager for Mac OS X, you can install Dart Sass by running

brew install sass/sass/sass

Before doing this however, it may be wise to uninstall the instance of sass that was installed via gem

gem uninstall sass

If you come across any issues with linking the sass that was installed via brew, you may need to manually link it (brew will usually tell you this if it is the case)

brew link --overwrite sass

Upvotes: 4

Marnix Harderwijk
Marnix Harderwijk

Reputation: 1313

Let me start by pressing people not to install gems with sudo. Since Catalina, user permissions changed for core/system files, which perfectly makes sense. This way no program can change the core files and they are save and secure.

Now the correct way to solve this issue is to install an additional Ruby build in your home folder which can be altered and tempered with.

  1. brew update && brew install rbenv ruby-build
  2. xcode-select --install
  3. vim ~/.zshenv
  4. add the following to the opened file export PATH="$HOME/.rbenv/bin:$PATH"
  5. vim ~/.zshrc
  6. add the following to the opened file:
source $HOME/.zshenv
eval "$(rbenv init - zsh)"
  1. source ~/.zshrc
  2. rbenv install 2.6.4 or any version you feel comfortable with
  3. rbenv global 2.6.4
  4. ruby -v check current running ruby version
  5. ruby -e "puts (1..100).reduce(:+)" outputs 5050
  6. Now install any gem you want gem install sass

Upvotes: 6

Delowar Hosain
Delowar Hosain

Reputation: 2369

Problem solved, here's the solution

Open terminal & run these code

  • Step 1: brew update
  • Step 2: xcode-select --install
  • Step 3: sudo gem install -n /usr/local/bin sass

Now check your sass version: sass -v

Upvotes: 13

Related Questions