Hey there. I’m trying to use Jekyll for the first time. Everything is installed, running MacOS Sonoma 14.1.1 and using Homebrew for Ruby. I can see my current Ruby and Jekyll versions. (3.4.1 and 4.3.4 respectively.) I set up my first site and I’m ready to run bundle exec jekyll serve but every time I do, no matter what solutions I try, I get the same error: bundler: failed to load command: jekyll. The Gemfile is the standard Gemfile that comes with every new Jekyll site. I have not altered it.
Here’s the full response when I run bundle exec jekyll serve:
/opt/homebrew/lib/ruby/gems/3.4.0/gems/jekyll-4.3.4/lib/jekyll.rb:26: warning: logger was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.
You can add logger to your Gemfile or gemspec to silence this warning.
/opt/homebrew/lib/ruby/gems/3.4.0/gems/jekyll-4.3.4/lib/jekyll.rb:28: warning: csv was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
You can add csv to your Gemfile or gemspec to silence this warning.
bundler: failed to load command: jekyll (/opt/homebrew/lib/ruby/gems/3.4.0/bin/jekyll)
/opt/homebrew/Cellar/ruby/3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require': cannot load such file -- csv (LoadError)
from /opt/homebrew/Cellar/ruby/3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require'
from /opt/homebrew/lib/ruby/gems/3.4.0/gems/jekyll-4.3.4/lib/jekyll.rb:28:in '<top (required)>'
from /opt/homebrew/Cellar/ruby/3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require'
from /opt/homebrew/Cellar/ruby/3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require'
from /opt/homebrew/lib/ruby/gems/3.4.0/gems/jekyll-4.3.4/exe/jekyll:8:in '<top (required)>'
from /opt/homebrew/lib/ruby/gems/3.4.0/bin/jekyll:25:in 'Kernel#load'
from /opt/homebrew/lib/ruby/gems/3.4.0/bin/jekyll:25:in '<top (required)>'
from /opt/homebrew/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/cli/exec.rb:59:in 'Kernel.load'
from /opt/homebrew/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/cli/exec.rb:59:in 'Bundler::CLI::Exec#kernel_load'
from /opt/homebrew/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/cli/exec.rb:23:in 'Bundler::CLI::Exec#run'
from /opt/homebrew/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/cli.rb:452:in 'Bundler::CLI#exec'
from /opt/homebrew/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/vendor/thor/lib/thor/command.rb:28:in 'Bundler::Thor::Command#run'
from /opt/homebrew/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in 'Bundler::Thor::Invocation#invoke_command'
from /opt/homebrew/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/vendor/thor/lib/thor.rb:538:in 'Bundler::Thor.dispatch'
from /opt/homebrew/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/cli.rb:35:in 'Bundler::CLI.dispatch'
from /opt/homebrew/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/vendor/thor/lib/thor/base.rb:584:in 'Bundler::Thor::Base::ClassMethods#start'
from /opt/homebrew/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/cli.rb:29:in 'Bundler::CLI.start'
from /opt/homebrew/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/exe/bundle:28:in 'block in <top (required)>'
from /opt/homebrew/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/friendly_errors.rb:117:in 'Bundler.with_friendly_errors'
from /opt/homebrew/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/exe/bundle:20:in '<top (required)>'
from /opt/homebrew/opt/ruby/bin/bundle:25:in 'Kernel#load'
from /opt/homebrew/opt/ruby/bin/bundle:25:in '<main>'
I have tried many different solutions. I have uninstalled and reinstalled some gems. I have attempted to add webrick but that didn’t do anything. Adding CSV did not change anything. Trying bundle add jekyll gives me a warning about duplicate gems. Any advice is appreciated. Thank you.
it kinda looks like you have ruby installed twice - 3.4.0 and 3.4.1 and half the stuff is in one in the rest in the other. See if you can tell if that is true and uninstall and reinstall if possible. Might want to see if you are using ruby for anything else.
I’ve been struggling with the same issue. Finally I gave in and explicitly installed the libraries that the warning is about, using
bundle add <library name here>
Do that for both csv and logger. See if bundle exec jekyll serve gives you more of these warnings (which clearly aren’t warnings). I had to get another 3 I think.
I had this problem and others before. Currently I receive the following error: /opt/homebrew/opt/ruby/bin/bundle:25:in 'Kernel#load': cannot load such file -- /opt/homebrew/Cellar/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/exe/bundle (LoadError)
I only need to run jekyll once in a while and every time I wanna do it, there is another problem withe ruby/gem/bundle. I start searching, trying and after a few hours it seems to be fixed and I dont really know what did the trick. Then I leave it, not touching it, hoping by not touching it it wount break but next time, the cylcle starts over.
Is there any way to configure that enviroment in a way that it does’t auto-degrade?
Now I’m back to this problem I have ran into many times before:
bundle install
/Users/bitnapper/.gem/ruby/3.4.1/gems/bundler-2.2.25/lib/bundler/vendor/thor/lib/thor/error.rb:105:in '<class:Thor>': uninitialized constant DidYouMean::SPELL_CHECKERS (NameError)
DidYouMean::SPELL_CHECKERS.merge!(
^^^^^^^^^^^^^^^^
Did you mean? DidYouMean::SpellChecker
from /Users/bitnapper/.gem/ruby/3.4.1/gems/bundler-2.2.25/lib/bundler/vendor/thor/lib/thor/error.rb:1:in '<top (required)>'
from /Users/bitnapper/.gem/ruby/3.4.1/gems/bundler-2.2.25/lib/bundler/vendor/thor/lib/thor/base.rb:3:in 'Kernel#require_relative'
from /Users/bitnapper/.gem/ruby/3.4.1/gems/bundler-2.2.25/lib/bundler/vendor/thor/lib/thor/base.rb:3:in '<top (required)>'
from /Users/bitnapper/.gem/ruby/3.4.1/gems/bundler-2.2.25/lib/bundler/vendor/thor/lib/thor.rb:1:in 'Kernel#require_relative'
from /Users/bitnapper/.gem/ruby/3.4.1/gems/bundler-2.2.25/lib/bundler/vendor/thor/lib/thor.rb:1:in '<top (required)>'
from /Users/bitnapper/.gem/ruby/3.4.1/gems/bundler-2.2.25/lib/bundler/vendored_thor.rb:8:in 'Kernel#require_relative'
from /Users/bitnapper/.gem/ruby/3.4.1/gems/bundler-2.2.25/lib/bundler/vendored_thor.rb:8:in '<top (required)>'
from /Users/bitnapper/.gem/ruby/3.4.1/gems/bundler-2.2.25/lib/bundler/friendly_errors.rb:3:in 'Kernel#require_relative'
from /Users/bitnapper/.gem/ruby/3.4.1/gems/bundler-2.2.25/lib/bundler/friendly_errors.rb:3:in '<top (required)>'
from /Users/bitnapper/.gem/ruby/3.4.1/gems/bundler-2.2.25/exe/bundle:32:in 'Kernel#require_relative'
from /Users/bitnapper/.gem/ruby/3.4.1/gems/bundler-2.2.25/exe/bundle:32:in '<top (required)>'
from /Users/bitnapper/.rubies/ruby-3.4.1/bin/bundle:25:in 'Kernel#load'
from /Users/bitnapper/.rubies/ruby-3.4.1/bin/bundle:25:in '<main>'
I guess just a few hours until this one somehow works and in a few weeks is just falls apart again.
looking at the paths in each line it looks like you are back to 2 ruby installations - one in .rubies and one in .gem/ruby.
I’m not positive that is the case, just looking at the paths it seems like it could be.
I’m not a mac user so not sure on the details but I think macs come with a system ruby and then when you install ruby on your own it gets confused. Not saying 100% that is your situation. Then maybe if the OS updates it does something again with the system ruby? that might undo whatever you did?
You might want to look into using a ruby manager - like RVM? again not a mac user so not sure.
Also you might want to try using docker, though you may have as many issues doing that, or something like a cloud based IDE like gitpod. I’ve used gitpod before and it is super cool though for some reason I stopped using it - I find local dev easier.
Nodding; yeah, Mac has Ruby built in. Tried installing RVM (or something similar) and it was kind of weird. Will take a look soon thanks to those of you who caught that, I certainly didn’t lol. + Will check out gitpod!!
The best recommendation I can give you is to use devcontainers. You can see a simple working example in this repository. Note that you must have Docker installed for it to work. The main advantage is that it will create a docker container with all the dependencies installed inside, so you won’t need to worry about messing with your system installed packages.
If you use VSCode, it is as simple as opening the main directory and letting it install everything for you. To test it, clone the repository I pointed to and open it in VSCode. Plus, you can also use GitHub Codespaces to open a working environment online. You can try it by clicking on the Open in GitHub Codespaces button in their documentation here.