Search code examples
macosrubygemsjekyllbundler

Install bundler on MacOS with out using sudo?


I'm running MacOS 10.14.1 and can not install Jekyll with out using sudo to install bundler. Its here a workaround?

When I run:

gem install bundler jekyll

I get:

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

With sudo everything installs but I keep reading articles about using sudo to install gems as being poor practice. Is there a workaround?


Solution

  • I'm a Jekyll user as well. But, I didn't run into this issue. I believe it's because I use rbenv to manage Ruby, and installed 2.5.3 with it first.

    I'd highly recommend checking out rbenv. While I do find managing Ruby to be kind of a pain to setup, once you have things set, it works quite well.

    One you have a dedicated, non-system-installed Ruby, you won't need sudo. From there, you can also use bundle install --path vendor/bundle to really contain your gems into your current project.

    Good luck, and hopefully this is helpful.