Problem Root Cause
Jekyll server encountered Gemfile module mismatch version
You have already activated [module_name] x.x.x(version), but your Gemfile requires [module_name] x.x.x(version). Prepending bundle exec to your command may solve this. (Gem::LoadError)
above error message will be shown on the console when ruby tried to start jekyll via serve command with dependencies issues between module specifices on syesm and gemlock.
jekyll serve
serve command on jekyll will utilize latest installed package on system to run jekyll. For example, rake version 13.3.0 installed on system and the rake version specificied on Gemfile.lock is version 13.2.1 will trigger those error.
Installed module version on the system (local machine) need to be 100% (exact) match with predefined module version on Gemfile.lock
Resolution
There are two ways to solve module versioning dependencies on jekyll.
- Quickwin: run jekyll via bundler. It will use Gemfile.lock as the version basline instead of using the system version.
- Upgrade (Preferred): update Gemfile to match with version reqiured by the system. Because system wide installed package usually are up to date. best for security, performance and integrity.
Run Jekyll via Bundler
below command will force jekyll serve command to be executed from the bundler. Installed jekyll dependencies package version on system will be forced when running the jekyll project. Hence, error will be solved.
Use following command to run jekyll via bundler
bundler exec jekyll serve
Update Module version on Gemfile
On a case where ruby module version installed at the system is newer than defined module version at Gemfile.lock, an update can be made by adjusting the version number on Gemfile.lock file using bundle update
Update Module version on Gemfile.lock using bundle update
execute following command
bundle update
this will update the “rake” version on Gemfile.lock
Module version is successfully upgraded on the Gemfile
Now run jekyll serve usual (without the bundle exec)
jekyll serve
run jekyll serve after fixing module dependencies and versioning issue on Gemfile.lock