Jekyll - Get Started
Table of contents
Jekyll Prerequisite
Ruby Installation
1. xcode-select
xcode-select --install
Install Homebrew
2. Install via brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
3. Install Ruby/Gem:
brew install ruby
4. Uninstall Ruby:
brew uninstall ruby
brew autoremove
Uninstall Gem method 1
sudo gem uninstall --all
gem uninstall -i /usr/local/Cellar/ruby/3.0.2_1/lib/ruby/gems/3.0.0 minitest
Uninstall Gem method 2
gem uninstall -aIx
a => removes all versions
I => ignores dependencies
x => includes executables
5. Check ruby version:
ruby -v
>>>>> ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin20]
6. Manually add path if required:
- Replace [X.X.0] with the ruby version, eg:
...ruby/3.0.2...
echo 'export PATH="$HOME/.gem/ruby/[X.X.0]/bin:$PATH"' >> ~/.bash_profile
echo $SHELL
7. Environment
Check gem
path, below command outputs paths.
gem env
Ruby Path
About Ruby and Gem
which -a ruby (show all ruby path)
/usr/local/opt/ruby/bin/ruby
/usr/local/opt/ruby/bin/ruby
/usr/local/opt/ruby/bin/ruby
/usr/bin/ruby
/usr/local/opt/ruby/bin/ruby
which gem
/usr/local/opt/ruby/bin/gem
Ruby path in .bashrc
- option 1 - simple
export
line in.bashrc
or.zshrc
export PATH="/usr/local/opt/ruby/bin:$PATH"
- option 2 - comprehensive export in
.hashrc
or.zshrc
# '-d' is an operator to test if the given directory exists or not.
if [ -d "/usr/local/opt/ruby/bin" ]; then
export PATH=/usr/local/opt/ruby/bin:$PATH
export PATH=`gem environment gemdir`/bin:$PATH
fi
# other ruby path suggested on command output during installation via homebrew
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"
Jekyll Installation
Gem Bundler Install & Uninstall
gem install jekyll bundler
# for the whole PC, not directory related
gem uninstall jekyll bundler
jekyll new myblog
cd myblog
bundle add webrick
bundle exec jekyll serve
- If there is no error, open browser: http://127.0.0.1:4000/
Gem Path
I was confused with gem
path and ruby
path, once ruby path is configured, there is no need to export the gem
path again.
Use gem env
to see the paths.
echo 'PATH=$PATH:[/path/to/gems]' >> ~/.bash_profile