Can bundler access jekyll from $HOME/.gem & other gems from 'vendor/bundle'?

I’m new to ruby/jekyll; went through the step-by-step tutorial at the Jekyll docs. Installed jekyll and bundler locally (~/.gem/ruby/2.7.0/bin/*) per these macOS instructions. I also set bundle config set path 'vendor/bundle' so each time I do jekyll new [PATH] gems are installed there. I am looking for a way for bundle install to find my local jekyll gem without installing it in each small project. I tried gem "jekyll", :path => "/User/Steve/.gem/ruby/2.7.0/bin/jekyll" in the Gemfile but :path seems to only be a relative path from the current directory. (Coming from Python, I am looking for something like os.path.abspath).

Is what I am asking possible? I saw a similar question at stackoverflow and commented there too.

Hi Steve.

Fellow Python wrangler here.

You can use jekyll new and a folder name to create a new project but I have only done this a handful times. Mostly I create a new project one file at a time or I use a github template repo that I made or that someone else made.

You’ll want to do the following:

Create a new project or clone a repo. This should have a homepage, config and Gemfile at minimum.

Navigate to the project.

Configure bundler for the project. Only needed once for each project.

bundle config set path vendor/bundle

Install gems inside the project.

# this will use any 'gem install GEM_NAME' lines in Gemfile. This is what you should be using 90% of the time.
bundle install

# install ad hoc. Remember to add it to Gemfile if you want to keep it around.
bundle install GEM_NAME 'VERSION'

Note there is no virtual environment to activate, as bundler knows to install to vendor directory within a project.

And you’ll want to avoid using gem install GEM in the shell unless it’s at the user level. See my guide below which does that. Also don’t worry about setting :path - I’ve never come across that before I have worked on many Jekyll projects.

A reference for installing Ruby and Jekyll if you need more help with that part

If you want a simple project to run, I have two templates here.

Either click Use this Template and add to your own repo. Then clone.

Or clone the original project (you just need read access to clone so this is fine)

Thanks. I did, in fact, follow those MacOS installation instructions and that went smoothly, resulting in --user-install of both bundler-2.1.4 and jekyll-4.0.0 in my ~/.gem/ruby/2.7.0/bin (and adding that directory to $PATH).

I also read Using Jekyll with Bundler. It’s advice about using vendor/bundle made sense to me coming from Python venv experiences. But that requires any gems in the Gemfile to be installed into vendor/bundle. So if I want to bundle exec jekyll [command] I need another copy of jekyll in vendor/bundle. It seemed redundant.

So my questions:

  1. Can I remove jekyll from ~/.gem/ruby/2.7.0/bin with gem uninstall jekyll --user-install since I have to install jekyll with each project anyway (in vendor/bundle)?

  2. bundle config set path "vendor/bundle" created ~/.bundle/config and ~/.bundle/cache, ie, in my $HOME rather than in the project directory. Is that correct, or do these need to be in each project directory?

  3. I’ve been playing around with gem list -d and noticed that there is a version of bundler(2.1.2) that was installed with ruby into /usr/local/Cellar/ruby/2.7.1_2/lib/ruby/gems/2.7.0. So I am wondering if I need --user-install of bundler? That did install an updated version – 2.1.4. I tried gem update which brought me bundler-2.1.4 but put it in /usr/local/lib/ruby/gems/2.7.0 (that really confused me), not in /usr/local/Cellar/ruby/2.7.1_2/lib/ruby/gems/2.7.0. Running gem list -d bundler now:

    bundler (2.1.4, 2.1.2)
        Authors: André Arko, Samuel Giddins, Colby Swandale, Hiroshi
        Shibata, David Rodríguez, Grey Baker, Stephanie Morillo, Chris
        Morris, James Wen, Tim Moore, André Medeiros, Jessica Lynn Suttles,
        Terence Lee, Carl Lerche, Yehuda Katz
        License: MIT
        Installed at (2.1.4): /Users/Steve/.gem/ruby/2.7.0
                     (2.1.2, default): /usr/local/Cellar/ruby/2.7.1_2/lib/ruby/gems/2.7.0
        The best way to manage your application's dependencies

I am a bit confused. I do not program in ruby, but I think I should be able to understand the basic logic with some work. Any help is greatly appreciated.


  1. You are welcome to keep jekyll installed at the user level and then call it as jekyll serve. With the caveat that some projects will still be on jekyll 3 and you can’t have two Jekylls installed in the same ruby space, so then you end up using jekyll in each Gemfile where its needed and bundle exec jekyll serve. So you can switch between global and project jekyll. If you do uninstall use jekyll (which matches what i do) then your uninstall command is correct.
  2. Bundle is only for project level installs and not user installs as far as I know. So delete ~/.bundle (easily recreated if needed). And make sure you only run the config command in the root of a project. Yes it is a config per project
  1. My experience is limited with this question but here goes… The usr/local/lib Ruby I guess is the system ruby. Since Catalina, this ruby and its gems are locked. So if you use this Ruby’s bundle you get to use 2.1.2 which is not too old. The user install of Ruby in the brew Cellar let’s you install and gems and versions like bundler 2.1.4 or higher. So that’s probably better. But see if you can edit your path in your bashrc or zshrc to ensure you use the custom ruby and bundler and not the system one. You don’t have to remove the gem dir for where system gems are, you just have to make sure that custom install is before it in the path. Seeing two bundle versions with one gem command baffles me.

Maybe run gem update after making sure the custom brew ruby is near the start of the path before the lib ruby.

Thanks again. I think I sort of solved the gem update question. According to its help page, the default use is --document --no-force --install-dir /usr/local/lib/ruby/gems/2.7.0. I installed homebrew and used it just once to install ruby-2.7. I am pretty sure that is what created /usr/local/Cellar/ruby/2.7.1_2/lib/ruby/gems/2.7.0.

I think if I had run gem update --install-dir /usr/local/Cellar/ruby/2.7.1_2/lib/ruby/gems/2.7.0 the bundler associated with the ruby gems would have been updated. My impression is that none of that is terribly important. But I think your advice to use jekyll per project with vendor/bundle sounds like good practice and I will follow that. Thanks again for all your help.

Okay great. I didn’t know about those flags but glad you figured it out.

Side note - Jekyll 3.8.5 is what Github Pages uses. So if you’re using Jekyll 4.0.0 locally then you’ll have a mismatch when you deploy. Then you’ll need a solution where you get gem 'jekyll', '~> 4.0.0' honored.

So for that I’d recommend using Github Actions - I wrote this for the Jekyll docs recently: . I added a link at the bottom to my template / live demo if you’re interested.

Alternatively, you can use Netlify. I found it is less hassle to setup than Github Actions. It just means maintaining a separate account and sites outside Github.

That’s great info. I did not realize that about Github Pages. I will check out your templates as well.

One more thing. I needed to use bundle config set --local path "vendor/bundle" from the project direcotry to get .bundle/config to land in the project directory. If I left off the --local option, I ended up with ~/.bundle/config (per user, not per application).

Okay grear thanks I’ll add that to my instructions for my projects.

I helped someone else with a path issue and they posted their PATH and link to Muffin Man tutorial in case that helps you too. I don’t know if the order of the two items in path is better if swapped though.