0

I tried to install Jekyll on my Mac (OS X 10.11.6 El Capitan with Xcode cli tools installed) using gem install jekyll, but I received this error:

$ gem install jekyll
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

I furrowed my eyebrows and then read the install troubleshooting docs on the Jekyll site, which discuss SIP in El Capitan. I'm still feeling dissatisfied at this point.

I don't know anything about Ruby other than what I've read today, but I know a fair bit about bash. The developers suggest using sudo gem install -n /usr/local/bin jekyll. Is the sudo in this case only for if the folder permissions for /usr/local/bin require escalated privileges or is it for something else also?

Is there a way that I can install Jekyll

  • without using sudo and
  • without installing Homebrew (or any other package installation tools / third-party software) and
  • without modifying the permissions (755 root:wheel) on my /usr/local/ folder?

If so, what are the implications on the operation of Jekyll?

2 Answers 2

0

I think you can change your $GEM_HOMEenvironment variable to a folder you have write and execute permissions to. Convention is to create a .gem folder in home. Then make sure and add that folder to your $GEM_PATH environment variable. Then you should be able to install gems to your hearts content AND use gems installed in the system gem folder.

References: https://unix.stackexchange.com/a/210012 https://stackoverflow.com/a/11277228/203845

1
  • 1
    ✌️ Thanks for that. I did the equivalent of this for npm global installs and it's much nicer than using /usr/local/.
    – jsejcksn
    Jul 21, 2016 at 15:49
0

Here is another approach I found on a relevant GitHub issue (from 25 Sep 2015) and am copying below the horizontal rule below. (Be sure to add the binary path to your $PATH via your ~/.bash_profile or /etc/paths.d/)


Have a few moments and want to reiterate, and re-share-- in a summary format, that installing jekyll (gems in general) by leveraging the gem executable capabilities to isolate ruby gem installations works out of box with OS X 10.11 for example with [only] the following, with the added benefit of leaving the system completely alone, and isolating jekyll and its dependencies to the current user/group [only]:

OS X XCode Command Line Utilities

Can be installed via calling a developer command such as git and following prompts.

With OS X' native ruby and gem:

gem install --user-install --bindir ~/bin --no-document --pre --verbose jekyll
export PATH=$PATH:~/bin
$ jekyll --version
jekyll 3.0.0.pre.beta9

$ ruby --version
ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
$ which ruby
/usr/bin/ruby

If System-wide meddling with a tinker-hostile environment is not your interest, and or you don't want/need custom/specific Ruby environment(s) (rbenv, chruby, RVM, ...), then a --user-install approach may be worth considering. And it works with stock OS X (10.11 currently).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .