1

I'm trying to get Jekyll running on my Mac M1. This requires a Ruby install. I had everything working a couple days ago, but must have changed something and now I cannot make sense of why it's no longer working nor find a fix. Here are the pieces of the puzzle - I hope someone smarter and more experienced than me can help.

It appears that I have Ruby 3.2.1 installed:

MacBook-Air.local~: rbenv version
3.2.1 (set by /Users/johnzumsteg/.rbenv/version) 

Run rbenv global for 3.2.1

MacBook-Air.local~: rbenv global 3.2.1

See what Ruby version is current

MacBook-Air.local~: ruby --version
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22]

Not what I expected. That's the default MacOS Ruby install. Try chruby:

MacBook-Air.local~: chruby 3.2.1
chruby: unknown Ruby: 3.2.1

Also not what I expected.

If it's of help, here's PATH (with line-feeds between individual paths for clarity):

/Users/johnzumsteg/.rbenv/bin:
/Users/johnzumsteg/.gem/ruby/3.2.1/bin:
/Users/johnzumsteg/.rbenv/shims:
/usr/local/opt/ruby/bin:
/usr/local/lib/ruby/gems/3.2.1/bin:
/opt/homebrew/bin:
/opt/homebrew/sbin:
/Library/Frameworks/Python.framework/Versions/3.10/bin:
/Library/Frameworks/Python.framework/Versions/3.9/bin:
/usr/local/bin:/System/Cryptexes/App/usr/bin:
/usr/bin:
/bin:/usr/sbin:
/sbin:/Library/Apple/usr/bin:
/Users/johnzumsteg/.cargo/bin

And the appropriate section of .zshrc:

export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.2.1/bin:$PATH"
eval "$(rbenv init - zsh)"
export PATH="$HOME/.gem/ruby/3.2.1/bin: $PATH" 
export PATH="$HOME/.rbenv/bin:$PATH"
# enable chruby
source /usr/local/opt/chruby/share/chruby/auto.sh
source /opt/homebrew/opt/chruby/share/chruby/chruby.sh

Clearly I'm not expert at this. I've tried to research for a solution, so I can learn something, but though it seems that I've tried everything I can find, I'm still stuck.

I will greatly appreciate any and all help.

I've trie multiple installs of Ruby 3.2.1 and many trouble-shooting ideas found in my search for a solution

Kache
  • 15,647
  • 12
  • 51
  • 79
JohnZ
  • 11
  • 2
  • 2
    Remove those custom lines adding `/usr/local/opt/ruby`, `/usr/local/lib/ruby`, `.gem/`, `.rbenv/` to `PATH`. Let version managers like `rbenv` handle it for you. Don't use two version managers at the same time, pick just one `rbenv` or `chruby` (I recommend the former, since you have it already). Use `which ruby` to see the full path of what it resolves to, for debugging. – Kache Mar 29 '23 at 20:56
  • Have you followed the instructions on https://jekyllrb.com/docs/installation/macos/? Have you run step 2 completely? Have you done this? "Quit and relaunch Terminal, then check that everything is working" before you run `ruby -v`? What does `rbenv versions` return? Rbenv should work without using chruby. Also, checkout https://github.com/rbenv/rbenv and follow the instructions here. – Christian Mar 29 '23 at 21:02
  • Thank you both, Kache and Christian. I went through Christian's answer first, using the steps of the Jekyll installation page (I used these steps when I first installed Jekyll andmRuby, so I still don't know what I later did to invalidate the install). Also took out the lines suggested by Kache. Did an install on 3.1.3, then a "bundle install" and "bundle exec jelly serve" then worked as it should. Thanks to both of you for taking the time and effort to help me out. I very much appreciate it! – JohnZ Mar 29 '23 at 23:08

1 Answers1

0

Don't use multiple ruby version managers, otherwise they'll end up fighting each other over which one is controlling your current version of ruby.

For rbenv, this should be the only Ruby-related config for your shell:

eval "$(rbenv init -)"

And this should be the only Ruby-related path in your PATH:

/Users/yourusername/.rbenv/shims

I see five different configs for you, so it's not surprising that one of those is taking precedence over rbenv.

Max
  • 21,123
  • 5
  • 49
  • 71
  • Thanks, Max. Following the comment of Kache I cleaned up my .zshrc and the comment of Christian I re-did some stuff and got it all working. I appreciate the time you and others gave me to fix this - all is working well now. – JohnZ Apr 01 '23 at 23:08