Getting started OSX permission issues

Hi

Ruby complete newbie here. I wanted to try out Jekyll from recommendation here

I am running macOS 10.12.4, system version of Ruby is ;
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]

Based on above guide i followed steps:

  • installed homebrew (1.2.2)
  • installed RBENV via homebrew (v 1.1.0)
  • rbenv install 1.9.3-p551
  • cd into your project directory and run rbenv local 1.9.3-p551

ruby versions
system

  • 1.9.3-p551 (set by /Users/me/jekyltest/.ruby-version)

However when I do gem install bundler, I get:
ERROR: While executing gem … (Gem::FilePermissionError)
You don’t have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

I’ve googled but finding various solutions and don’t know which is the right one.

I’ve previously installed fastlane via sudo as per their recommendation, but now reading that using sudo isn’t good. I’m not sure if i can clean out installed gems without breaking something in macOS, but I like the idea of it all being self contained within rbenv.

Any recommendations to get around the permissions issue and properly install bundler for use with rbenv?

Many thanks

$ brew update
$ brew install rbenv
$ rbenv init

You need to run the rbenv init just onece.

# list all available versions:
$ rbenv install -l

# install a Ruby version:
$ rbenv install 2.4.1

2.4.1 is the latest version of Ruby by the time I’m writing this.

$ gem install bundler

Then you need to make 2.4.1 your global version

$ rbenv global 2.4.1

You can find more details in the repo.

Thanks for your reply. These are the steps I followed. Then I do:

rbenv versions

  • system (set by /Users/me/.rbenv/version)
    1.9.3-p551
    2.4.1

gem install bundler

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

Thanks

this link suggesting it is a path issue

thing is when i do echo $PATH I get:

/Users/me/Developer/android-sdk-macosx/platform-tools
/opt/local/bin
/opt/local/sbin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

There is no .rbenv in there at all.

If I run rbenv version output is:
system (set by /Users/me/.rbenv/version)

Are you using BASH, ZSH, Fish, something else ?

you’ll need at add rbenv to your path as @gdiaz suggest you need to check out the rbenv repo

in a nutshell you’ll be doing something like, assuming you’re using BASH:

echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile
exec $SHELL

If you are having issues, getting frustrated, and you start installing and uninstalling the rbenv, it will be hard for the community to help. I’m saying this because some times, after you run the command $ rbenv global 2.4.1, you won’t see the version taking effect until you restart the terminal or source your either bashrc, zshrc, or other shell you are using. I recommend to uninstall rbenv and follow the steps again. After you finish just restart your terminal and run rbenv version command… You should have 2.4.1. Hope this helps.

Thanks for replies.

I have rbenv working now, the issue was missunderstanding the install instructions.

putting eval “$(rbenv init -)” in .bash_profile makes it work.

However now I am having a different issue.

I installed bundler:
Bundler version 1.15.1

When I call bundle install --without heroku

I get this:

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

    /Users/me/.rbenv/versions/1.9.3-p551/bin/ruby extconf.rb

Thanks

Make sure you source you .bash_profile - run this source ~/.bash_profile

after that do which ruby && which gem && which bundler and check to see what it spits out?
should look like this:

/Users/ed/.rbenv/shims/ruby
/Users/ed/.rbenv/shims/gem
/Users/ed/.rbenv/shims/bundler

If not then you’re using the system ruby version - which you need to tell rbenv to manage.

When I run those commands I get:

/Users/me/.rbenv/shims/ruby
/Users/me/.rbenv/shims/gem
/Users/me/.rbenv/shims/bundler

when I run rbenv versions I get:

system

  • 1.9.3-p551 (set by /Users/me/Documents/work/jekyltest/.ruby-version)
    2.4.1

bundler version:
Bundler version 1.15.1

rbenv version
1.9.3-p551 (set by /Users/me/Documents/work/jekyltest/.ruby-version)

then, when I call bundle install --without heroku I get:

An error occurred while installing mysql2 (0.3.18), and Bundler cannot continue.
Make sure that gem install mysql2 -v '0.3.18' succeeds before bundling.

full output:
https://pastebin.com/XKSNBsZ3

Not finding any obvious answers, anyone have any ideas?

Thanks so much!

So it turns out this issue above was solved doing:
xcode-select --install

I did this before, but upgrading xcode breaks it.

Thanks

Hi Chris,

Just noticed the thread and could not walk away from the subject. Are you okay to install just 1 thing on your laptop and get Jekyll up & running?

I’m talking here about using Docker for that matter. Believe it or not, you will save yourself time, tears, hair and confidence going Docker route. :wink:

No fuss with funky toolset and stuff, just pure awesomeness…