rubyhomebrewjekyllbundlerzshrc

Could not find 'bundler' (2.5.7)


MacOS user here. I am trying to build a website hosted on github. Followed the instructions from this website but used a different jekyll theme. When I try to preview my website locally via bundle exec jekyll serve I get the following error:

Could not find 'bundler' (2.5.7) required by your /Users/ad/Desktop/Website/Gemfile.lock. (Gem::GemNotFoundException) To update to the latest version installed on your system, run bundle update --bundler. To install the missing version, run gem install bundler:2.5.7

When I try bundle update --bundler, it says

You must use Bundler 2 or greater with this lockfile.

My bundler version is Bundler version 1.17.2.

How can I get bundle exec jekyll serve to run?

I tried to install a second version of ruby using homebrew since I read that one cannot update the preinstalled MacOS version of ruby. ruby-install -V gives ruby-install: 0.9.3. However, chruby -h gives zsh: command not found: chruby.

When I use open -e ~/.zshrc, I get

source /usr/local/opt/chruby/share/chruby/chruby.sh
source /usr/local/opt/chruby/share/chruby/auto.sh
chruby ruby-3.3.3.

Please help...


Solution

  • There are different ways, but what I do is:

    1. Install https://brew.sh (a package manager for macOS)

    2. Install rbenv (a version manager for different ruby versions)

      brew install rbenv
      echo 'eval "$(rbenv init - zsh)"' > ~/.zshrc
      
    3. Open new terminal and cd into your repository

    4. Create a file called .ruby-version in your repo with the contents 3.3.3 (or whatever ruby version you want to run)

    5. rbenv install (after that, ruby -v should print 3.3.3)

    6. bundle install (install jekyll and its dependencies)

    7. bundle exec jekyll serve (start your dev server)