Netlify build—bash: jekyll: command not found

Hi guys,

I’m getting stuck at something that should probably be very easy to deal with… But for some I’m not able to figure out what I need to solve it.

My system: MacOS, zsh, ruby 2.7.1p83 installed via homebrew, jekyll 4.0.0

When I run netlify build I get the following error: bash: jekyll: command not found

Fair enough, if I switch to bash with exec bash and run jekyll I get the same error. But it’s working just fine in zsh.

echo $PATH returns the same both from zsh and bash:


Can I somehow just make netlify build use zsh, or does it need to use bash?

Some stuff I already tried:

  • Adding the following to my otherwise empty .bash_profile:
export PATH="/usr/local/opt/ruby/bin:$PATH"
if which ruby >/dev/null && which gem >/dev/null; then
    PATH="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin:$PATH"
  • installed jekyll again using bash

my gem env output:

RubyGems Environment:
  - RUBY VERSION: 2.7.1 (2020-03-31 patchlevel 83) [x86_64-darwin19]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.7.0
  - USER INSTALLATION DIRECTORY: /Users/tkrunning/.gem/ruby/2.7.0
  - RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/2.7.0/bin
  - SPEC CACHE DIRECTORY: /Users/tkrunning/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.7.1_2/etc
    - ruby
    - x86_64-darwin-19
     - /usr/local/lib/ruby/gems/2.7.0
     - /Users/tkrunning/.gem/ruby/2.7.0
     - /usr/local/Cellar/ruby/2.7.1_2/lib/ruby/gems/2.7.0
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - /usr/local/opt/ruby/bin
     - /usr/local/opt/ruby/bin
     - /Users/tkrunning/bin
     - /usr/local/bin
     - /usr/local/lib/ruby/bin
     - /usr/local/opt/ruby/bin
     - /usr/local/opt/ruby/bin
     - /Users/tkrunning/bin
     - /usr/local/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /usr/local/opt/ruby/bin
     - /Users/tkrunning/bin

Any ideas?

Hi, welcome to the Netlify community forum!

This Stack Overflow post might help. Otherwise, try asking the Jekyll community, as your issue is a bit out of the Netlify scope.


Nice! This sounds like a fun one :nerd_face: first, which version of macOS are you using? The default system shell switched to Zsh in… I think Catalina, so if you’re already on Catalina, the following may be moot…

While it may be some shell churn or something like that; try running bundle exec jekyll build and see if that resolves?

Thanks, but I already gave that a try. I figured there might be a way to make Netlify Build rely on zsh, which is why I posted here.

It’s unfortunately also not working… And yes, I’m on Catalina, but had been using zsh for a few years prior to that. Did a fresh install of Catalina when upgrading, though.

Thanks for your help guys :slight_smile: I’ll see if I can find help on SO or somewhere else. Or maybe I’ll just skip using Netlify Build for the time being.

Hm. I mean I too have been running Zsh for years and run all of my local netlify dev just fine with it, but I wonder if your PATH is augmented only by Zsh and Bash isn’t getting those same augmentations :thinking: let us know if you find something that works!


1 Like

I am having a similar issue for which the cause appears to be the same on MacOS Catalina. I am using gulp/jekyll and the latest version of ruby installed using brew. This set up allows me to run gulp / jekyll commands without sudo. Catalina comes with an older version of ruby pre-installed and brew installs a newer version in a different path, which is set in .zshrc so that the ruby/gems commands are executed using the newer version.

When I attempt to run netlify build command, it somehow is picking up the older Catalina version and thus cannot find some gems plugins that were installed in the newer version of ruby. It appears that the command is somehow not inheriting the paths of the user which runs the command.

It would be helpful to know how others have worked around this and whether or not there is a way to set paths for netlify-cli or tell it which version of ruby to use. I have tried to override Ruby version using the steps in this doc, however that seems to have no effect when running netlify build command locally.

Hi @duveedigital, the doc you mentioned are ways to set versions for the buildbot when building on Netlify, not locally. That’s likely why it’s not working for you.

Have you tried running echo $PATH to see if the new Ruby version is in your path? If not, could you try prefixing export PATH=$PATH:<path/to/ruby> to the netlify cli command?

Hi @duveedigital and @tkrunning. What you are experiencing is a common issue unfortunately due to incomplete documentation on the Jekyll site. The solution is to update your PATH with the location where gems get installed when you are using the Homebrew version of Ruby. If you’re using Ruby version 2.7.x, that location is /usr/local/lib/ruby/gems/2.7.0/bin. If your current Ruby version is something other than 2.7.x, then replace 2.7 with the first two digits of your Ruby version, then run this command:

echo 'export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/2.7.0/bin:$PATH"' >> ~/.zshrc

Replace .zshrc with .bash_profile if you’re using bash instead of zsh.

Helping people set up a proper Ruby development environment on their Mac is a passion of mine. I’ve been doing it for the past 9 years. It saddens me that people have to go through the same issues over and over. I wrote a script that can automate the whole process, and I wish that practice was more widespread. Why make people do things manually when it is almost guaranteed to result in errors due to missing steps or human error?

If you’re interested in the setup I recommend, check out my definitive guide to installing Ruby gems on a Mac.