Instantly share code, notes, and snippets.

@DirtyF /README.md
Last active Nov 15, 2018

Embed
What would you like to do?
Setup Jekyll on macOS with brew and rbenv - See https://jekyllrb.com/docs/installation/macos/

First, make sure you have command line tools installed:

xcode-select --install

Then open Terminal.app and type:

curl https://gist.githubusercontent.com/DirtyF/5d2bde5c682101b7b5d90708ad333bf3/raw/fbc736fa1b50bd637929a315e6803df306c8bc8e/setup-rbenv.sh | bash
#!/bin/bash
set -ex
brew update
brew install rbenv ruby-build
rbenv install 2.5.3
echo "export GEM_HOME=$HOME/gems" >> ~/.bashrc
echo "export PATH=$HOME/gems/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
rbenv global 2.5.3
gem install jekyll bundler
rbenv rehash
ruby -v
jekyll -v
if ! type rbenv | grep function; then
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
fi
set +x
echo "Done! Close and reopen your terminal"
@fengyuentau

This comment has been minimized.

fengyuentau commented Aug 1, 2018

I just ran the commands in setup-rbenv.sh, but it turns out that we should run the following command(from this answer on stackoverflow) after installing rbenv in order to make rbenv global 2.4.3 work:

# for bash:
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
# for zsh:
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
$ echo 'eval "$(rbenv init -)"' >> ~/.zshrc

Then reopen terminal.
Or the version of ruby would still be the one pre-installed on macos.

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