11 Dec 2019

This article will take about 1 minute to read.
10 Comments

Another Catalina rant, this time about Ruby. As far as I know, on MacOS, it is advisable to For example users don’t have write permission on the system’s gems folder. , and install a separate version for development. I had one installed via Homebrew, and never had any issues with it.

But after Catalina upgrade, I couldn’t run Jekyll. Every time it would fail with the following error:

$ jekyll
  -bash: /usr/local/bin/jekyll: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby:
  bad interpreter: No such file or directory

I checked my bash profile and run which ruby to make sure I’m using the one installed by brew, and everything seemed to be in order.

# .bash_profile
export PATH="/usr/local/opt/ruby/bin:$PATH"

# bash
$ which ruby
/usr/local/opt/ruby/bin/ruby

After quick internet search I learned a lot of people are having similar problems after system upgrade, but I couldn’t find the solution.

I’ve tried reinstalling ruby, setting GEM_HOME, altering PATH in /etc/profile and /etc/bashrc, removing and reinstalling gems, but nothing worked.

Then I tried to see which Jekyll binary is used and realized - for some reason gems were installed using the correct ruby version, but binaries weren’t linked properly.

Jekyll binary wasn't coming from brew ruby installation

So the solution was pretty easy at the end, all I had to do is to find gems/bin folder and add it to my path.

# Use ruby installed by brew
export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/2.6.0/bin/:$PATH"

It looks like a common sense, but it took me a couple of hours to figure it out. Hopefully this will save time people facing the same issue.

Category
Rants

Comments (10)

Mogli
10 Feb 2020, 11:15 AM

Or…. docker run --rm -it -w /src -v $PWD:/src jekyll/jekyll

Stanko
10 Feb 2020, 11:26 AM

Thank you Mogli, I just want to add that it will work only for people running jekyll in a docker container using jekyll-docker.

Cheers!

Sabrina
28 May 2020, 02:13 PM

Thanks for writing this article, it helped me fix up this issue with a different gem on my machine not once but twice!

Craig
14 Jul 2020, 11:32 PM

Thank you so much for this article! That one line of code has fixed a world of problems I’ve had after hours of head-scratching…

I too reinstalled Ruby several times wondering why this wasn’t working and it was such a simple fix… I was just looking in the wrong place.

Not all heroes wear capes :)

Stanko
15 Jul 2020, 06:43 AM

Thank you both for the kind words!

And I hear you, it is a simple one, but was super hard for me to pinpoint it.

Cheers!

Adrian
31 Jul 2020, 10:14 AM

yeah, thanks 1!

Aaron
20 Aug 2020, 05:53 AM

Thank you!

Lucas
20 Aug 2020, 06:44 PM

I tried to follow along with what you are doing but get this error - An error occurred while installing http_parser.rb (0.6.0), and Bundler cannot continue. Make sure that gem install http_parser.rb -v '0.6.0' --source 'https://rubygems.org/' succeeds before bundling.

Suresh D
11 Sep 2020, 10:28 AM

Hi Team, Please help me with the same problem as found: “-bash: /usr/local/bin/papi-client: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory” Your tutorial as good, you are a mastermind but I need an elaborate tutorial. Please help me…

Stanko
11 Sep 2020, 11:01 AM

Lukas, I’m no ruby expert but that seems like a missing gem in your app.

Suresh, not sure where you got stuck. You just need to add paths to the ruby and gems folders to the PATH ENV variable.

Leave a comment

Sending failed, please try again.
Thank you! Your comment is sent. Please note that all of the comments go through moderation.