Failed installation attempts on MacOS Catalina

[Caveat: I am a novice Terminal user and this is my first experience with a command line procedure for installing software (which may be at least half of my problem, I know).]

In an effort to install and use Jekyll on my system, I have studied the Jekyll website and watched the video tutorials by Mike Dane. I understand the process, but after attempting to perform the scripted Terminal commands described in these resources, I get multiple errors and seem to be going in circles.

I have followed the instructions to install Jekyll on MacOS very carefully—several times. I can verify that Ruby is installed, but cannot verify that Jekyll is installed. Here is what I get:

ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]

jekyll -v
-bash: jekyll: command not found

Strangely, when I enter

export PATH=$HOME/.gem/ruby/2.6.0/bin:$PATH

as is specified in the installation instructions, I then am able to run

jekyll -v
jekyll 4.0.0

However, when trying to execute commands from Jekyll to publish the site, things go south. When trying to serve up the site to my local host, I get:

bundle exec jekyll serve
Could not locate Gemfile or .bundle/ directory

Also, when I close out my Terminal window and reopen it, it will not verify that Jekyll is downloaded until I run

export PATH=$HOME/.gem/ruby/2.6.0/bin:$PATH

again.

So, needless to say, I’m stuck in a rut here and could use some help with my specific issues. It would be greatly appreciated.

Basically, you need to have Ruby’s bin directory permanently added to your PATH env variable. Ideally, it should’ve been automatically handled when you installed Ruby itself.

Running gem env will give you some nice insight regarding where Ruby looks for stuff.
The path we’re interested in here is printed with the label: EXECUTABLE DIRECTORY:. Adding that value to your system’s PATH will ensure that Ruby finds executables made available by a Rubygem.

To permanently add a value to your PATH so that all terminal sessions works as expected without having to manually export PATH=$HOME/.gem/ruby/2.6.0/bin:$PATH each time, take look into the following StackOverflow thread:

Prepending bundle exec to Jekyll commands is only needed if you have multiple versions of various gems installed and there’s a Gemfile present in your site’s source directory.
If you do have a Gemfile in the source directory, then ensure that you’re within your site’s source directory:

cd path/to/source/directory

Thank you, @ashmaroli, for this info. Unfortunately, I am too ignorant of the command line syntax and vocabulary, and the underlying processes, that I am not able to translate your information here into practical action. Please pardon my ignorance. As I said earlier, I am a novice, but am wanting to learn. Bear with me…

I would like to share the results of running gem env in my Terminal. Perhaps you could look this over and provide me with a specific next step to get things sorted out.

RubyGems Environment:
  - RUBYGEMS VERSION: 3.0.3
  - RUBY VERSION: 2.6.3 (2019-04-16 patchlevel 62) [universal.x86_64-darwin19]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.6.0
  - USER INSTALLATION DIRECTORY: /Users/Roy/.gem/ruby/2.6.0
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - SPEC CACHE DIRECTORY: /Users/Roy/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-19
  - GEM PATHS:
     - /Library/Ruby/Gems/2.6.0
     - /Users/Roy/.gem/ruby/2.6.0
     - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /Library/TeX/texbin
     - /opt/X11/bin

For whatever it’s worth, when I attempt to run path/to/source/directory I get -bash: cd: path/to/source/directory: No such file or directory. Also, when attempting to run gem install jekyll I get `

ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

Any further help is greatly appreciated!

Perhaps @frank can guide you through the process with more clarity…

MacOS make it hard to install gems as a user for security reasons.

Catalina comes up with Ruby 2.6, what happens when you try to set the gems path to your home folder?

I have this in my ZSH config ( works similarly for your bash profile)
export GEM_HOME=/Users/USERNAME/gems

You can also force bundler to install gems to vendor/bundle

bundle config set path 'vendor/bundle

If anyone else comes up with a solid install process on latest macOS, we’ll happitly update our docs, my setup is quiet messy at the moment :slight_smile:

I’m still getting this error:

gem install jekyll
ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

Strangely, this is immediately after I run

gem install --user-install bundler jekyll

and get a confirmation:

Successfully installed jekyll-4.0.0
Parsing documentation for jekyll-4.0.0
Done installing documentation for jekyll after 0 seconds
2 gems installed

When requesting the version (jekyll -v) I get

-bash: jekyll: command not found

I had the same errors on macOS Catalina.

First make sure that the .bash_profile in your home directory includes this path:

(Show hidden files in Finder on Catalina: cmd + shift + fn + period)

export PATH="$HOME/.gem/ruby/2.6.0/bin:$PATH"

With macOS Catalina, Apple is now using Zsh as the default shell.

I solved the problem with switching the default shell to Bash.

Run this command in Terminal:

chsh -s /bin/bash