'jekyll build' vs 'bundle exec jekyll build'?

While following this issue / thread …suddenly i’m wondering

Umh… What’s the differences (if there are) ? Pros and cons ?

ThX for your hints

1 Like

In general, running naked Jekyll in a bundled project will crash or produce incorrect results. The only correct way to use Jekyll in a bundled project is with bundle exec jekyll.

The only time when naked Jekyll will accidentally work is when the global Jekyll gem is exactly the same version as the one specified in the bundled projects Gemfile/Gemfile.lock. If either version is different, then all bets are off.

Of course, if your project isn’t bundled (no Gemfile), then the global Jekyll is the only thing to use, but you’ll have to manually manage gem versions, etc.

1 Like

Chuck is right.

Jekyll command alone uses Jekyll installed for your user or system (across users).

If you upgrade that from say Jekyll 3.8 to jekyll 3.9, then all your projects on your machine that you normally use global Jekyll with will get a newer version. Some if them may not be compatible. What to do you do if half your projects work with the old Jekyll only and half work can work with the new Jekyll? You have to upgrade the broken ones gradually until they are all working on the new one.

If you use bundle, then every project gets its own version of Jekyll.

You can upgrade 3.8 to 3.9 or down to 3.7 in one project and it will not affect the others.

You can upgrade it to 4.1 and then later to 4.2 and back to 4.1 and it will not affect the other projects.

If you change your global Jekyll, there is an unknown risk of what is does to your projects until you test them out.

You might also run into dependency issues. Say one of your projects uses bundle to install a plugin but not Jekyll. And the plugin needs a certain version of a gem. But your project doesn’t know about your global Jekyll and the fact that it needs an older version of the gem.

When you use Jekyll and other gems in the same Gemfile and lock file, then dependency trees can be mapped and you can know when installing or upgrading that something gives you an error and you can fix it then.

In Python and JavaScript, it is also common practice to install project packages into an isolated virtual environment which you can upgrade and destroy without breaking other projects.

1 Like

If you hate long commands, make an alias

alias jek="bundle exec jekyll"

jek serve --trace

sure @MichaelCurrin , i’ll make use of the suggested Alias !

1 Like

Pro tip…

Jekyll also has alias commands builtin:

jekyll b  # ie build
jekyll s  # ie serve

See jekyll --help

I like to use a Makefile. Works on mac and linux and also windows if you install GNU Make command.

s serve:
  bundle exec jekyll serve --trace --livereload
make s
# serving jekyll site...

My file:

And i also alias make as m so I can do

m s
1 Like

I second the use of a makefile. I used to have an applescript for that :slight_smile: , but a makefile is just a better fit. Mine also contains entries to start bbedit as site editor, a repositioning of the terminal window etc. And when started w/o parameters it gives a help listing, 'cause I tend to forget…

2 Likes