Skip to content

Instantly share code, notes, and snippets.

@DirtyF
Last active April 11, 2021 17:24
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save DirtyF/5d2bde5c682101b7b5d90708ad333bf3 to your computer and use it in GitHub Desktop.
Save DirtyF/5d2bde5c682101b7b5d90708ad333bf3 to your computer and use it in GitHub Desktop.
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.6.5
echo "export GEM_HOME=$HOME/gems" >> ~/.zshrc
echo "export PATH=$HOME/gems/bin:$PATH" >> ~/.zshrc
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
if ! type rbenv | grep function; then
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.zshrc
fi
source ~/.zshrc
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
rbenv global 2.6.5
gem install jekyll bundler
rbenv rehash
ruby -v
jekyll -v
set +x
echo "Done! Close and reopen your terminal"
@fengyuentau
Copy link

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.

@desireesanchez
Copy link

I have rbenv global 2.5.3 but still unable to use the command jekyll serve
Please help.

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