Fixing bundle install on macOS
Fixing bundle install on macOS
The site uses the github-pages gem, which depends on several gems that need to compile native code. macOS system Ruby (/usr/bin/ruby) often fails to build these on newer macOS versions, with errors like:
No rule to make target ... ruby/config.hThe compiler failed to generate an executable file
Fix: use a Ruby that isn’t the system one (e.g. Homebrew or rbenv). Then bundle install and bundle exec jekyll build will work.
Option A: Ruby via Homebrew (recommended)
Install Homebrew (if needed): https://brew.sh
- Install Ruby:
brew install ruby - Use Homebrew’s Ruby (add to your
~/.zshrcso it’s used in new terminals):export PATH="/opt/homebrew/opt/ruby/bin:$PATH" export PATH="$(brew --prefix ruby)/lib/ruby/gems/$(ruby -e 'puts RUBY_VERSION')/bin:$PATH"Then run
source ~/.zshrcor open a new terminal. - Confirm you’re not using system Ruby:
which ruby # should be /opt/homebrew/opt/ruby/bin/ruby or similar, not /usr/bin/ruby ruby --version - Install bundler and project gems:
cd /path/to/xiangyum.github.io gem install bundler bundle config set --local path 'vendor/bundle' bundle install - Build/serve the site:
bundle exec jekyll build # or bundle exec jekyll serve
Option B: Ruby via rbenv
- Install rbenv and ruby-build:
brew install rbenv ruby-build rbenv init # follow the prompt to add rbenv to your shell (e.g. ~/.zshrc) - Install a Ruby and use it in this project:
cd /path/to/xiangyum.github.io rbenv install 3.2.0 rbenv local 3.2.0 - Install gems and build:
gem install bundler bundle config set --local path 'vendor/bundle' bundle install bundle exec jekyll build
If you only need to deploy (e.g. GitHub Pages)
You don’t have to run Jekyll on your Mac. Push your branch to GitHub; GitHub Pages will run bundle install and jekyll build in its own environment. Your font and content changes will apply there. Local bundle install is only needed if you want to build or serve the site on your machine.
