Skip to content

Instantly share code, notes, and snippets.

@KetchCyork
Last active May 4, 2024 03:03
Show Gist options
  • Save KetchCyork/ab896f1c8e3e845b8d17d3aef169b871 to your computer and use it in GitHub Desktop.
Save KetchCyork/ab896f1c8e3e845b8d17d3aef169b871 to your computer and use it in GitHub Desktop.
Permission error installing Jekyll

My Journey installing Jekyll on my new Macbook Pro

I went to the Jekyll website https://jekyllrb.com/docs/installation/ and read the pre-requisites

I ran each command line recommended to validate the correct prerequisites are installed

Installing Jekyll should be straight-forward if all requirements are met. Before you start, make sure your system has the following: GNU/Linux, Unix, or macOS Ruby version 2.2.5 or above, including all development headers (ruby installation can be checked by running ruby -v, development headers can be checked on Ubuntu by running apt list --installed ruby-dev) RubyGems (which you can check by running gem -v) GCC and Make (in case your system doesn't have them installed, which you can check by running gcc -v,g++ -v and make -v in your system's command line interface)

Then using command line I installed using Ruby Gem via the command

gem install Jekyll

When I did this I got the following error:

gem install jekyll
Fetching: public_suffix-3.0.2.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

My next step was to google "gem install jekyll you don't have write permissions" and I found an article on github recommending a different command line - "$ gem install --user-install --bindir ~/bin --no-document --pre --verbose Jekyll" which gave me a bash error of "command not found".

I then reached out to a friend @mention @davebeach with the error and we realized that out of the box Mac's come installed with Ruby but the permissions are locked down and I needed to give myself ownership of the directory so that the install could complete successfully The first thing I did was navigate to the directory giving me permission issues

cd /Library/Ruby/Gems/2.3.0

Then navigated "up" one level by typing the command

cd ..

then I typed

ls -al

the response was

drwxr-xr-x  3 root  wheel   96 Jul 15  2017 .
drwxr-xr-x  4 root  wheel  128 Jul 15  2017 ..
drwxr-xr-x  8 root  wheel  256 Jul 15  2017 2.3.0

The result told me that I was not the owner of the "2.3.0" directory to complete the install, as well as the fact that I was in the root directory and not within my user directory so the next step was to enter the command

sudo chown christopheryork: 2.3.0

Then I entered my passowrd and then the command

ls -al

and the result was

drwxr-xr-x  3 root             wheel   96 Jul 15  2017 .
drwxr-xr-x  4 root             wheel  128 Jul 15  2017 ..
drwxr-xr-x  8 christopheryork  wheel  256 Jul 15  2017 2.3.0

next I used the command

sudo chown christopheryork:staff 2.3.0

and then the command

ls -al

and the result was

drwxr-xr-x  3 root             wheel   96 Jul 15  2017 .
drwxr-xr-x  4 root             wheel  128 Jul 15  2017 ..
drwxr-xr-x  8 christopheryork  staff  256 Jul 15  2017 2.3.0

Note the directory is now under my ownership

I next ran the command

gem install jekyll

and I got the error

Fetching: public_suffix-3.0.2.gem (100%)
ERROR:  While executing gem ... (Errno::EACCES)
Permission denied @ rb_sysopen - /Library/Ruby/Gems/2.3.0/cache/public_suffix-3.0.2.gem

I then navigated back to the correct directory

cd /library/ruby/gems

I entered the command

sudo chown -R christopheryork:staff 2.3.0

Then I issued the command

gem install jekyll

and the result was

Done installing documentation for public_suffix, addressable, colorator, http_parser.rb, eventmachine, em-websocket, concurrent-ruby, i18n, rb-fsevent, ffi, rb-inotify, sass-listen, sass, jekyll-sass-converter, ruby_dep, listen, jekyll-watch, kramdown, liquid, mercenary, forwardable-extended, pathutil, rouge, safe_yaml, jekyll after 50 seconds 25 gems installed

@oyinkanso
Copy link

I CANNOT THANK YOU ENOUGH!!!!!!!!!!!! After always struggling to install things on my command line, your step by step guidance meant I downloaded Jekyll for the first time!! Thank you :) 🥇

@ramonmulia
Copy link

Thanks a lot! I followed all the steps above and I could download Jekyll correctly!

@moctips
Copy link

moctips commented Jan 28, 2023

I ended up just navigating to /usr/local/lib/ruby/gems/2.7.0/ and running sudo chown -R <username> .

@charliebunt
Copy link

No mine still says permission denied.

@rwslinkman
Copy link

Taking a hint from @moctips comment, I got it to work using the following command

sudo chown -R $(whoami) /usr/local/lib/ruby/gems

@mcbalz
Copy link

mcbalz commented May 3, 2024

This almost worked for me but I got an error at the end related to my version of rogue:

ERROR: Error installing jekyll:
The last version of rouge (>= 3.0, < 5.0) to support your Ruby & RubyGems was 3.30.0. Try installing it with gem install rouge -v 3.30.0 and then running the current command again
rouge requires Ruby version >= 2.7. The current ruby version is 2.6.10.210.

Then I tried following the instruction and it said it couldn't find a valid 'rouge'

ERROR: Could not find a valid gem 'rogue' (= 3.30.0) in any repository
ERROR: Possible alternatives: rogue

Then I tried installing rogue and got this error:

ERROR: Error installing rogue:
There are no versions of nokogiri (~> 1.14) compatible with your Ruby & RubyGems. Maybe try installing an older version of the gem you're looking for?
nokogiri requires Ruby version >= 3.0, < 3.4.dev. The current ruby version is 2.6.10.210.

Finally, I find this strange since I tried and I thought successfully installed ruby 3.12 with homebrew and rbenv but my system still has ruby 2.6.0 ... I'm stuck for now. Can anyone tell me what I'm doing wrong? #newb

@mcbalz
Copy link

mcbalz commented May 4, 2024

I ended up figuring out that in order to install Jekyll, I had to install Ruby properly, and to do that I needed not to change permissions on the built in mac Ruby install, but to change my terminal from bash to zsh, ignore the native mac Ruby, use the Ruby I had installed via Homebrew, and properly and set the $PATH variable in ~/.zschrc ... and not only that, but I had to set that path using the proper syntax, which is not properly on the otherwise wonderful website Mac Install Guide run by Daniel Kehoe that helped me on my way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment