Can't install Jekyll. MacOS Big Sur 11.2.3

On an Intel Mac, I’ve managed to install ruby 3.0.1p64 (with brew install ruby) in /usr/local/opt/ruby/bin/ruby. I’ve added this to my path putting

export PATH="/usr/local/opt/ruby/bin:$PATH"

in .zshrc

But when running gem install bundler jekyll I get the error

ERROR:  While executing gem ... (Errno::EPERM)
Operation not permitted @ apply2files - /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.16/CHANGELOG.md

Using sudo provides a different, longer error.

Successfully installed bundler-2.2.16
Parsing documentation for bundler-2.2.16
Done installing documentation for bundler after 1 seconds
Building native extensions. This could take a while...
ERROR:  Error installing jekyll:
	ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/3.0.0/gems/sassc-2.4.0/ext
/usr/local/opt/ruby/bin/ruby -I /usr/local/lib/ruby/site_ruby/3.0.0 -r ./siteconf20210411-72539-k9wlvj.rb extconf.rb
creating Makefile

current directory: /usr/local/lib/ruby/gems/3.0.0/gems/sassc-2.4.0/ext
make DESTDIR\= clean

current directory: /usr/local/lib/ruby/gems/3.0.0/gems/sassc-2.4.0/ext
make DESTDIR\=
compiling ./libsass/src/ast.cpp
In file included from ./libsass/src/ast.cpp:5:
In file included from ./libsass/src/ast.hpp:9:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:409:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:18:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:317:9: error: no member named 'signbit' in the global namespace
using ::signbit;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:318:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:319:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
      ~~^
/usr/local/include/math.h:749:12: note: 'finite' declared here
extern int finite(double)
           ^
In file included from ./libsass/src/ast.cpp:5:
In file included from ./libsass/src/ast.hpp:9:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:409:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:18:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:320:9: error: no member named 'isinf' in the global namespace
using ::isinf;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:321:9: error: no member named 'isnan' in the global namespace
using ::isnan;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:322:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:323:7: error: no member named 'isgreater' in the global namespace; did you mean '::std::greater'?
using ::isgreater;
      ^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:738:29: note: '::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
                            ^
In file included from ./libsass/src/ast.cpp:5:
In file included from ./libsass/src/ast.hpp:9:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:409:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:18:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:324:7: error: no member named 'isgreaterequal' in the global namespace; did you mean '::std::greater_equal'?
using ::isgreaterequal;
      ^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:767:29: note: '::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
                            ^
In file included from ./libsass/src/ast.cpp:5:
In file included from ./libsass/src/ast.hpp:9:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:409:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:18:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:325:9: error: no member named 'isless' in the global namespace
using ::isless;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:326:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:327:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:328:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:329:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
13 errors generated.
make: *** [ast.o] Error 1

make failed, exit code 2

Gem files will remain installed in /usr/local/lib/ruby/gems/3.0.0/gems/sassc-2.4.0 for inspection.
Results logged to /usr/local/lib/ruby/gems/3.0.0/extensions/x86_64-darwin-20/3.0.0/sassc-2.4.0/gem_make.out
1 gem installed

I have also tried gem install --user-install bundler jekyll, but get the following:

WARNING:  You don't have /Users/benjamv/.gem/ruby/3.0.0/bin in your PATH,
	  gem executables will not run.
Successfully installed bundler-2.2.16
Parsing documentation for bundler-2.2.16
Done installing documentation for bundler after 1 seconds
Building native extensions. This could take a while...
ERROR:  Error installing jekyll:
	ERROR: Failed to build gem native extension.

    current directory: /Users/benjamv/.gem/ruby/3.0.0/gems/sassc-2.4.0/ext
/usr/local/opt/ruby/bin/ruby -I /usr/local/lib/ruby/site_ruby/3.0.0 -r ./siteconf20210411-72578-ju17sb.rb extconf.rb
creating Makefile

current directory: /Users/benjamv/.gem/ruby/3.0.0/gems/sassc-2.4.0/ext
make DESTDIR\= clean

current directory: /Users/benjamv/.gem/ruby/3.0.0/gems/sassc-2.4.0/ext
make DESTDIR\=
compiling ./libsass/src/ast.cpp
In file included from ./libsass/src/ast.cpp:5:
In file included from ./libsass/src/ast.hpp:9:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:409:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:18:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:317:9: error: no member named 'signbit' in the global namespace
using ::signbit;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:318:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:319:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
      ~~^
/usr/local/include/math.h:749:12: note: 'finite' declared here
extern int finite(double)
           ^
In file included from ./libsass/src/ast.cpp:5:
In file included from ./libsass/src/ast.hpp:9:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:409:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:18:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:320:9: error: no member named 'isinf' in the global namespace
using ::isinf;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:321:9: error: no member named 'isnan' in the global namespace
using ::isnan;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:322:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:323:7: error: no member named 'isgreater' in the global namespace; did you mean '::std::greater'?
using ::isgreater;
      ^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:738:29: note: '::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
                            ^
In file included from ./libsass/src/ast.cpp:5:
In file included from ./libsass/src/ast.hpp:9:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:409:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:18:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:324:7: error: no member named 'isgreaterequal' in the global namespace; did you mean '::std::greater_equal'?
using ::isgreaterequal;
      ^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:767:29: note: '::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
                            ^
In file included from ./libsass/src/ast.cpp:5:
In file included from ./libsass/src/ast.hpp:9:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:409:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:18:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:325:9: error: no member named 'isless' in the global namespace
using ::isless;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:326:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:327:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:328:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:329:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
13 errors generated.
make: *** [ast.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/benjamv/.gem/ruby/3.0.0/gems/sassc-2.4.0 for inspection.
Results logged to /Users/benjamv/.gem/ruby/3.0.0/extensions/x86_64-darwin-20/3.0.0/sassc-2.4.0/gem_make.out
1 gem installed

I’m not strong with the command line, but have tried to follow the Jekyll on macOS install instructions, but am stuck at this point.

This usually means that the ruby devkit is not installed, though I am not a mac user so not sure how that applies to the mac os.

check this post - and the guide @MichaelCurrin links to:

No luck I’m afraid. Clicked through to the link in the link you provided. Followed the instructions and at gem install bundler --user-install I got:

ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted @ apply2files - /Users/benjamv/.gem/ruby/3.0.0/gems/bundler-2.2.16/CHANGELOG.md

I tried running gem install bundler jekyll just to see and I get the same error:

ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted @ apply2files - /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.16/CHANGELOG.md

Searched for that error and found this. So trying sudo gem install -n /usr/local/bin jekyll also results in the same error starting

Building native extensions. This could take a while...
ERROR:  Error installing jekyll:
	ERROR: Failed to build gem native extension.

didn’t see this before, maybe you are missing this from your path?

I’d also check and see if you have ruby in there twice - might be in both usr/local/opt and usr/local/lib? not a mac person so not sure what some of the directories mean. And maybe those could be in addition to Users/benjamv/.gem/ruby? you should only have it once I think.

The answer linked above around ffi is a different native extension issue.

As pointed out above though, you need dev tools installed to build native extensions. ie you need C header files setup to install gems which at the C level not just Ruby level.

Mac

xcode-select --install

Linux

sudo apt install ruby-dev

Also the errors in the original post have Xcode in the path so that looks like xcode step above will work.

The very first issue you got was because you tried to install to a path owned by root

/usr/local/lib/

Which means to needed to either use --user-install to install to ~/.gem
or use sudo gem install ... for access to /usr/local/lib/.
Even better, use chmod to allow users to install to that directory without sudo access

Something like

sudo chmod 666 /usr/local/lib
gem install bundler

You can also update your installed gems, with or without sudo, to get newer versions that can help with installs

gem update

Thanks for all the help so far.

In terms of tips from @MichaelCurrin

I ran gem update which added a few things to /usr/local/lib/ruby/gems/3.0.0/gems. Although it didn’t help in installing Jekyll.

I already have command line tools installed, and running xcode-select --install regardless results in xcode-select: error: command line tools are already installed, use "Software Update" to install updates. I opened Xcode to see if there was any autoupdate, and no. And there are no software updates to command line tools (or anything else) through System Preferences > Software Update. So no real success on that front.

Tips from @rdyar

Ruby relates stuff in .zshrc is as follows. I’ve arrived at this from following instructions distributed around in various places.

export RUBY_HOME=/usr/local/opt/ruby/bin
export PATH="$RUBY_HOME:$PATH"

export GEM_PATH="$HOME/.gem/ruby/3.0.0/bin"
export PATH="$GEM_PATH:$PATH"

There is a ruby folder in usr/local/lib.
There are also 3 shortcut folders (ruby, ruby@3, ruby@3.0) in usr/local/opt. As far as I can tell, they all point to /usr/local/Cellar/ruby. I have no idea what Cellar is.

I’m not so confident with the command line, so I don’t know if the contents of .zshrc are ok, or if I should delete any of these ruby folders.

When this is all resolved, I will try to do the install process on my second machine to see if there is something problematic with the install instructions, or if it’s just something with this machine.

Cellar is where Brew keeps stuff. Brew being a beer themed tool.

You can also try switching to Ruby 2.7

brew install ruby@2.7

And use 2.7.0 in the path.

If you’re using brew, you should will learn to love brew doctor it tends to offer helpful messages.

You don’t really want /usr/local/lib to be 0666, you just want it owned by you:

drwxrwxr-x  1271 jsoref  staff    40K Apr 22 16:11 /usr/local/lib

sudo chown $(whoami) /usr/local/lib; chmod 0775 /usr/local/lib

I have the same problem! I am not able to solve it either.

I was working perfectly fine with Jekyll till I updated MAC. My guess is that the problem is on the paths, but I have no clue .

What happens if you do ?

echo $PATH

Presumably echo, not cat