Jekyll - cannot load such file -- webrick (LoadError)
Bug
While installing this site, I already ran into something weird. I was following the instructions on official site of jekyll, until I ran into this:
why@computer:~/blog$ bundle exec jekyll serve
Configuration file: /home/why/blog/_config.yml
Source: /home/why/blog
Destination: /home/why/blog/_site
Incremental build: disabled. Enable with --incremental
Generating...
Jekyll Feed: Generating feed for posts
done in 0.255 seconds.
Auto-regeneration: enabled for '/home/why/blog'
------------------------------------------------
Jekyll 4.2.2 Please append `--trace` to the `serve` command
for any additional information or backtrace.
------------------------------------------------
/usr/share/rvm/gems/ruby-3.0.0/gems/jekyll-4.2.2/lib/jekyll/commands/serve/servlet.rb:3:in `require': cannot load such file -- webrick (LoadError)
from /usr/share/rvm/gems/ruby-3.0.0/gems/jekyll-4.2.2/lib/jekyll/commands/serve/servlet.rb:3:in `<top (required)>'
from /usr/share/rvm/gems/ruby-3.0.0/gems/jekyll-4.2.2/lib/jekyll/commands/serve.rb:179:in `require_relative'
from /usr/share/rvm/gems/ruby-3.0.0/gems/jekyll-4.2.2/lib/jekyll/commands/serve.rb:179:in `setup'
from /usr/share/rvm/gems/ruby-3.0.0/gems/jekyll-4.2.2/lib/jekyll/commands/serve.rb:100:in `process'
from /usr/share/rvm/gems/ruby-3.0.0/gems/jekyll-4.2.2/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
from /usr/share/rvm/gems/ruby-3.0.0/gems/jekyll-4.2.2/lib/jekyll/command.rb:91:in `each'
from /usr/share/rvm/gems/ruby-3.0.0/gems/jekyll-4.2.2/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
from /usr/share/rvm/gems/ruby-3.0.0/gems/jekyll-4.2.2/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
from /usr/share/rvm/gems/ruby-3.0.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
from /usr/share/rvm/gems/ruby-3.0.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
from /usr/share/rvm/gems/ruby-3.0.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
from /usr/share/rvm/gems/ruby-3.0.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
from /usr/share/rvm/gems/ruby-3.0.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
from /usr/share/rvm/gems/ruby-3.0.0/gems/jekyll-4.2.2/exe/jekyll:15:in `<top (required)>'
from /usr/share/rvm/gems/ruby-3.0.0/bin/jekyll:23:in `load'
from /usr/share/rvm/gems/ruby-3.0.0/bin/jekyll:23:in `<top (required)>'
from /usr/share/rvm/gems/ruby-3.0.0/gems/bundler-2.3.19/lib/bundler/cli/exec.rb:58:in `load'
from /usr/share/rvm/gems/ruby-3.0.0/gems/bundler-2.3.19/lib/bundler/cli/exec.rb:58:in `kernel_load'
from /usr/share/rvm/gems/ruby-3.0.0/gems/bundler-2.3.19/lib/bundler/cli/exec.rb:23:in `run'
from /usr/share/rvm/gems/ruby-3.0.0/gems/bundler-2.3.19/lib/bundler/cli.rb:483:in `exec'
from /usr/share/rvm/gems/ruby-3.0.0/gems/bundler-2.3.19/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /usr/share/rvm/gems/ruby-3.0.0/gems/bundler-2.3.19/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
from /usr/share/rvm/gems/ruby-3.0.0/gems/bundler-2.3.19/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
from /usr/share/rvm/gems/ruby-3.0.0/gems/bundler-2.3.19/lib/bundler/cli.rb:31:in `dispatch'
from /usr/share/rvm/gems/ruby-3.0.0/gems/bundler-2.3.19/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
from /usr/share/rvm/gems/ruby-3.0.0/gems/bundler-2.3.19/lib/bundler/cli.rb:25:in `start'
from /usr/share/rvm/gems/ruby-3.0.0/gems/bundler-2.3.19/exe/bundle:48:in `block in <top (required)>'
from /usr/share/rvm/gems/ruby-3.0.0/gems/bundler-2.3.19/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
from /usr/share/rvm/gems/ruby-3.0.0/gems/bundler-2.3.19/exe/bundle:36:in `<top (required)>'
from /usr/share/rvm/gems/ruby-3.0.0/bin/bundle:23:in `load'
from /usr/share/rvm/gems/ruby-3.0.0/bin/bundle:23:in `<main>'
Solution
bundle add webrick
Notes
The problem is mentioned in docs, but it’s difficult to search.