This document explains how to set up and maintain bundle dependencies when working across both Intel and Apple Silicon Macs.
Nokogiri (and other gems with native extensions) have platform-specific builds. When you run bundle install, bundler may install the wrong architecture version, causing this error:
LoadError: cannot load such file -- nokogiri/nokogiri
If you get the nokogiri error on Apple Silicon:
# Remove the x86_64 version
rm -rf vendor/bundle/ruby/2.6.0/gems/nokogiri-*-x86_64-darwin
rm -f vendor/bundle/ruby/2.6.0/specifications/nokogiri-*-x86_64-darwin.gemspec
# Install nokogiri compiled for ARM64
gem install nokogiri -v '1.13.10' \
--install-dir vendor/bundle/ruby/2.6.0 \
--platform=ruby \
--no-document \
-- --use-system-libraries
# Test Jekyll
bundle exec jekyll serve
On Intel Macs, the standard bundle install should work:
bundle install --path vendor/bundle
bundle exec jekyll serve
If you encounter issues:
# Clean and reinstall
rm -rf vendor/bundle
bundle install --path vendor/bundle
When you switch between Intel and Apple Silicon Macs:
# On the new machine, remove vendor/bundle
rm -rf vendor/bundle .bundle
# Reinstall for current architecture
bundle install --path vendor/bundle
# On Apple Silicon, apply the nokogiri fix if needed (see above)
Add vendor/bundle to .gitignore (it already should be) and maintain separate bundles on each machine.
# Install dependencies
bundle install --path vendor/bundle
# Update dependencies
bundle update
# Run Jekyll development server
bundle exec jekyll serve
# Clean bundle cache
bundle clean --force
Consider using a Ruby version manager with native ARM64 Ruby:
# Install rbenv via Homebrew
brew install rbenv
# Install Ruby
rbenv install 3.2.2
rbenv local 3.2.2
# Reinstall bundler and gems
gem install bundler
bundle install
# Install asdf via Homebrew
brew install asdf
# Add Ruby plugin
asdf plugin add ruby
# Install Ruby
asdf install ruby 3.2.2
asdf local ruby 3.2.2
# Reinstall bundler and gems
gem install bundler
bundle install
You have the wrong architecture version installed. See “Quick Fix” above for your architecture.
The path configuration was lost. Run:
bundle install --path vendor/bundle
ls -la vendor/bundle/ruby/2.6.0/gems/ | grep nokogiri
You should see either:
nokogiri-1.13.10 (compiled from source, works on both)nokogiri-1.13.10-x86_64-darwin (Intel only)nokogiri-1.13.10-arm64-darwin (Apple Silicon only, rare for old versions)uname -m
# arm64 = Apple Silicon
# x86_64 = Intel
bundle pristine
vendor/bundle directory is gitignored and machine-specific.Gemfile.lock tracks gem versions but may need platform-specific entries.