Local build of the site failing due to an error when running "bundle exec Jekyll serve"

I don’t know what happened, everything was working fine with a previous version if my site. I deleted the repo where I have it hosted and tried again like 3 times.

Im using the minimal mistakes theme and forked the repo according to the set-up guide. After forking it I deleted the recommended files and changed the Gemfile to include the dependencies suggested here.

After that I run bundle install and then I try to run bundle exec Jekyll serve. It used to work, but now I get this:

bundle exec jekyll serve
Configuration file: /Users/julio/Library/Mobile Documents/com~apple~CloudDocs/julioveravet.github.io/_config.yml
            Source: /Users/julio/Library/Mobile Documents/com~apple~CloudDocs/julioveravet.github.io
       Destination: /Users/julio/Library/Mobile Documents/com~apple~CloudDocs/julioveravet.github.io/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
       Jekyll Feed: Generating feed for posts
                    done in 0.482 seconds.
 Auto-regeneration: enabled for '/Users/julio/Library/Mobile Documents/com~apple~CloudDocs/julioveravet.github.io'
                    ------------------------------------------------
      Jekyll 4.2.0   Please append `--trace` to the `serve` command 
                     for any additional information or backtrace. 
                    ------------------------------------------------
/Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/commands/serve/servlet.rb:3:in `require': cannot load such file -- webrick (LoadError)
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/commands/serve/servlet.rb:3:in `<top (required)>'
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:179:in `require_relative'
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:179:in `setup'
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:100:in `process'
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `each'
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
	from /Users/julio/.gem/ruby/3.0.1/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
	from /Users/julio/.gem/ruby/3.0.1/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
	from /Users/julio/.gem/ruby/3.0.1/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
	from /Users/julio/.gem/ruby/3.0.1/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
	from /Users/julio/.gem/ruby/3.0.1/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/exe/jekyll:15:in `<top (required)>'
	from /Users/julio/.gem/ruby/3.0.1/bin/jekyll:23:in `load'
	from /Users/julio/.gem/ruby/3.0.1/bin/jekyll:23:in `<top (required)>'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/cli/exec.rb:63:in `load'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/cli/exec.rb:63:in `kernel_load'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/cli/exec.rb:28:in `run'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/cli.rb:474:in `exec'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/cli.rb:30:in `dispatch'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/cli.rb:24:in `start'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/exe/bundle:49:in `block in <top (required)>'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/exe/bundle:37:in `<top (required)>'
	from /Users/julio/.gem/ruby/3.0.1/bin/bundle:23:in `load'
	from /Users/julio/.gem/ruby/3.0.1/bin/bundle:23:in `<main>'

I have tried running bundle update and it shows “bundle updated”, but it always shows that.

I then run bundle jekyll serve --trace and I get:

bundle exec jekyll serve --trace
Configuration file: /Users/julio/Library/Mobile Documents/com~apple~CloudDocs/julioveravet.github.io/_config.yml
            Source: /Users/julio/Library/Mobile Documents/com~apple~CloudDocs/julioveravet.github.io
       Destination: /Users/julio/Library/Mobile Documents/com~apple~CloudDocs/julioveravet.github.io/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
       Jekyll Feed: Generating feed for posts
                    done in 0.483 seconds.
 Auto-regeneration: enabled for '/Users/julio/Library/Mobile Documents/com~apple~CloudDocs/julioveravet.github.io'
bundler: failed to load command: jekyll (/Users/julio/.gem/ruby/3.0.1/bin/jekyll)
/Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/commands/serve/servlet.rb:3:in `require': cannot load such file -- webrick (LoadError)
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/commands/serve/servlet.rb:3:in `<top (required)>'
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:179:in `require_relative'
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:179:in `setup'
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:100:in `process'
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `each'
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
	from /Users/julio/.gem/ruby/3.0.1/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
	from /Users/julio/.gem/ruby/3.0.1/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
	from /Users/julio/.gem/ruby/3.0.1/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
	from /Users/julio/.gem/ruby/3.0.1/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
	from /Users/julio/.gem/ruby/3.0.1/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
	from /Users/julio/.gem/ruby/3.0.1/gems/jekyll-4.2.0/exe/jekyll:15:in `<top (required)>'
	from /Users/julio/.gem/ruby/3.0.1/bin/jekyll:23:in `load'
	from /Users/julio/.gem/ruby/3.0.1/bin/jekyll:23:in `<top (required)>'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/cli/exec.rb:63:in `load'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/cli/exec.rb:63:in `kernel_load'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/cli/exec.rb:28:in `run'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/cli.rb:474:in `exec'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/cli.rb:30:in `dispatch'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/cli.rb:24:in `start'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/exe/bundle:49:in `block in <top (required)>'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
	from /Users/julio/.gem/ruby/3.0.1/gems/bundler-2.2.19/exe/bundle:37:in `<top (required)>'
	from /Users/julio/.gem/ruby/3.0.1/bin/bundle:23:in `load'
	from /Users/julio/.gem/ruby/3.0.1/bin/bundle:23:in `<main>'

Thank you.

Solved my own issue. I had to use chruby 2.7.3 to return to that ruby version, then I tried bundle exec Jekyll serve and it worked again.

I suggest you search the forums and Jekyll before posting.

Your error is cannot find webrick.

There have been a few posts around this exact issue and three identical issues on GitHub.

See for example:

This issue is specific to Ruby 3, and that is why you fixed it with downgrading to Ruby 2.X

If you want to keep using Ruby 3, then use the suggested answer in the linked post, which works for me.

bundle add webrick

Then commit your Gemfile so that webrick will be installed.

Also I found my lock file i had to be deleted and recreated when switching between 2 and 3. Which is the same as bundle update.