Error upon `bundle exec jekyll 3.8.7 new .` for Github Pages

Goal

Initiate a Github Page using Jekyll. I’m following the Github Pages docs.

Problem

Upon executing:

bundle exec jekyll 3.8.7 new .

The following error is returned:

fatal: 'jekyll 3.8.7' could not be found. You may need to install the jekyll-3.8.7 gem or a related gem to be able to use this subcommand. .

Also note that (a) Jekyll 3.8.7 is the current dependency version for Github Pages and (b) the same error is returned if I attempt it for Jekyll 4.1.0.

Context

I tried the recommendation in this SO post$ bundle init , $ bundle add jekyll – but that didn’t solve my problem.

System details:

$ which ruby
/Users/vishrutarya/.rbenv/shims/ruby

$ ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]

$ jekyll -v
jekyll 4.1.0

$ which jekyll
/Users/vishrutarya/.gem/ruby/2.7.0/bin/jekyll
1 Like

Did you first run jekyll new <project-name>? If not start with that. In your Gemfile add gem 'jekyll', '3.8.7'. Run bundle update which will download version 3.8.7 of the gem. Then you can run bundle exec jekyll build or bundle exec jekyll serve.

I haven’t see bundle add used before but the answer above is correct.

Add jekyll to Gemfile

Then

bundle install

Then

bundle exec jekyll serve

Thanks guys.

Unfortunately jekyll new <project_name> throws the error:
zsh: command: not found: jekyll.

I did install jekyll but the output suggests it might not be in the right path?

➜ ~ gem install --user-install bundler jekyll
Fetching bundler-2.1.4.gem
WARNING:  You don't have /Users/vishrutarya/.gem/ruby/2.7.0/bin in your PATH,
	  gem executables will not run.
Successfully installed bundler-2.1.4
Parsing documentation for bundler-2.1.4
Done installing documentation for bundler after 2 seconds
Fetching jekyll-4.1.0.gem
Successfully installed jekyll-4.1.0
Parsing documentation for jekyll-4.1.0
Done installing documentation for jekyll after 0 seconds
2 gems installed 

Add this to .zshrc and .bashrc. this is a common flow - add the bin directory to your path.

PATH=$HOME/.gem/ruby/2.7.0/bin:$PATH

then start a new terminal

And run

bundle exec jekyll new

Just to clarify, should I not add the export command before it so that it looks like export PATH=$HOME/.gem/ruby/2.7.0/bin:$PATH? Also, are quotes not needed?

I ask because, in the Ruby installation on the Jekyll website, a similar addition to .zshrc includes the export command: export PATH="/usr/local/opt/ruby/bin:$PATH".

Oh yes I forgot. Yes include export

Quotes are safer to add but not required always

You get syntax highlighting which is nicer on using quotes

And if there any items in the PATH which have spaces in them then quotes are necessary
for example between X=My Scripts and X="My Scripts" only the latter works as expected.

so I generally use quotes everywhere even simple cases

FOO='abc'

Thanks for the clarification!

Good news is this produced a different error (bad news is it’s an error):

➜  bundle exec jekyll new
jekyll 3.8.7 | Error:  You must specify a path.
Traceback (most recent call last):
	24: from /Users/vishrutarya/.rbenv/versions/2.7.1/bin/bundle:23:in `<main>'
	23: from /Users/vishrutarya/.rbenv/versions/2.7.1/bin/bundle:23:in `load'
	22: from /Users/vishrutarya/.gem/ruby/2.7.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
	21: from /Users/vishrutarya/.gem/ruby/2.7.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
	20: from /Users/vishrutarya/.gem/ruby/2.7.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
	19: from /Users/vishrutarya/.gem/ruby/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
	18: from /Users/vishrutarya/.gem/ruby/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
	17: from /Users/vishrutarya/.gem/ruby/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
	16: from /Users/vishrutarya/.gem/ruby/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
	15: from /Users/vishrutarya/.gem/ruby/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	14: from /Users/vishrutarya/.gem/ruby/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	13: from /Users/vishrutarya/.gem/ruby/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
	12: from /Users/vishrutarya/.gem/ruby/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
	11: from /Users/vishrutarya/.gem/ruby/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
	10: from /Users/vishrutarya/.gem/ruby/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
	 9: from /Users/vishrutarya/.rbenv/versions/2.7.1/bin/jekyll:23:in `<top (required)>'
	 8: from /Users/vishrutarya/.rbenv/versions/2.7.1/bin/jekyll:23:in `load'
	 7: from /Users/vishrutarya/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/jekyll-3.8.7/exe/jekyll:15:in `<top (required)>'
	 6: from /Users/vishrutarya/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
	 5: from /Users/vishrutarya/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
	 4: from /Users/vishrutarya/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
	 3: from /Users/vishrutarya/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
	 2: from /Users/vishrutarya/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
	 1: from /Users/vishrutarya/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/commands/new.rb:19:in `block (2 levels) in init_with_program'
/Users/vishrutarya/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/commands/new.rb:25:in `process': You must specify a path. (ArgumentError)

At this point, I tried running the recommended command from GitHubbundle exec jekyll 3.8.7 new .. This produced a different error:

➜  bundle exec jekyll 3.8.7 new .
fatal: 'jekyll 3.8.7' could not be found. You may need to install the jekyll-3.8.7 gem or a related gem to be able to use this subcommand.

Interestingly, jekyll -v also throws an error:

➜  jekyll -v
Traceback (most recent call last):
	10: from /Users/vishrutarya/.rbenv/versions/2.7.1/bin/jekyll:23:in `<main>'
	 9: from /Users/vishrutarya/.rbenv/versions/2.7.1/bin/jekyll:23:in `load'
	 8: from /Users/vishrutarya/.gem/ruby/2.7.0/gems/jekyll-4.1.0/exe/jekyll:11:in `<top (required)>'
	 7: from /Users/vishrutarya/.gem/ruby/2.7.0/gems/jekyll-4.1.0/lib/jekyll/plugin_manager.rb:52:in `require_from_bundler'
	 6: from /Users/vishrutarya/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler.rb:149:in `setup'
	 5: from /Users/vishrutarya/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler/runtime.rb:26:in `setup'
	 4: from /Users/vishrutarya/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler/runtime.rb:26:in `map'
	 3: from /Users/vishrutarya/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler/spec_set.rb:147:in `each'
	 2: from /Users/vishrutarya/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler/spec_set.rb:147:in `each'
	 1: from /Users/vishrutarya/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler/runtime.rb:31:in `block in setup'
/Users/vishrutarya/.rbenv/versions/2.7.1/lib/ruby/2.7.0/bundler/runtime.rb:312:in `check_for_activated_spec!': You have already activated i18n 1.8.3, but your Gemfile requires i18n 0.9.5. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)

Note the dot

bundle exec jekyll new .

Or create a new repo like this

bundle exec jekyll new my-project