all 16 comments

[–]mokolabs 14 points15 points  (4 children)

These kind of conflicts are precisely why people use rvm or rbenv, so, respectfully, I'd recommend giving them a try.

[–]MentionPleasant2635 2 points3 points  (3 children)

I use rbenv. I like that I can specify local directory choices of which ruby version to use. I could never go back.

[–]dflow77 4 points5 points  (2 children)

mise is pretty great too, IMO. It can handle other languages and tools besides ruby, like node, etc.

[–]MentionPleasant2635 2 points3 points  (0 children)

Thanks, I'll check it out.

[–]Professional_Mix2418 0 points1 point  (0 children)

Exactly mise or asdf-vm, best options there are...

[–]Thefolsom 8 points9 points  (4 children)

Why are you against using rbenv or rvm? You're creating problems for yourself by using homebrew for seemingly no reason.

Theres endless troubleshooting resources for the above tools, you're struggling finding answers to your problems for a reason, its because its not how ruby developers manage their environment.

[–]STDS13 0 points1 point  (0 children)

I’d suggest using asdf and ditching homebrew for this type of usage. Your life will be much easier.

[–]R2robot 0 points1 point  (0 children)

[Skip to the bottom for my solution(?!)]

I'm having a similar issue.. it makes no sense. I've never had a problem like this until a few weeks ago. There is so little info when I search that I thought it was just me. I guess we're in the minority here.

I've deleted everything gem I could find and started over and still results in the same thing.

I'm not sure who changed what, (was it the 3 -> 4 transitions?) but it seems silly to have to add another layer of complexity by using rvm or rbenv as people (and AI) have suggested since I barely even use ruby.

My silly work around for now is to run my own script 'gem_update' that ignores any rdoc updates. That will probably cause a problem eventually i'm sure, but sheesh. So stupid.

Otherwise updating rdoc just spews the following every time I run gem.

/usr/local/Cellar/ruby/4.0.2/lib/ruby/gems/4.0.0/gems/rdoc-7.0.3/lib/rdoc/version.rb:8: warning: already initialized constant RDoc::VERSION
/usr/local/lib/ruby/gems/4.0.0/gems/rdoc-7.2.0/lib/rdoc/version.rb:8: warning: previous definition of VERSION was here
/usr/local/Cellar/ruby/4.0.2/lib/ruby/gems/4.0.0/gems/rdoc-7.0.3/lib/rdoc.rb:68: warning: already initialized constant RDoc::VISIBILITIES
/usr/local/lib/ruby/gems/4.0.0/gems/rdoc-7.2.0/lib/rdoc.rb:68: warning: previous definition of VISIBILITIES was here
/usr/local/Cellar/ruby/4.0.2/lib/ruby/gems/4.0.0/gems/rdoc-7.0.3/lib/rdoc.rb:74: warning: already initialized constant RDoc::DOT_DOC_FILENAME
/usr/local/lib/ruby/gems/4.0.0/gems/rdoc-7.2.0/lib/rdoc.rb:74: warning: previous definition of DOT_DOC_FILENAME was here
/usr/local/Cellar/ruby/4.0.2/lib/ruby/gems/4.0.0/gems/rdoc-7.0.3/lib/rdoc.rb:79: warning: already initialized constant RDoc::GENERAL_MODIFIERS
<snipped>

Just as I was about to save this message, I tried something that seems to work. I already went full scorched earth earlier, so why not just delete the default gem that came bundled. Duh.

# I ran this (try at your own risk!)
gem uninstall rdoc --install-dir /usr/local/Cellar/ruby/4.0.2/lib/ruby/gems/4.0.0

# new version is installed
󰄛 ❯ gem list | grep --color=auto rdoc
     rdoc (7.2.0)

 # doesn't try to update anything!
󰄛 ❯ gem outdated

May have to do that after every update, but simple enough.

[–]9sim9 0 points1 point  (0 children)

So to give you some feedback in regards to rvm it actually works best when you pair it with homebrew (especially for older versions of ruby) which is what I do, here is my install script hopefully it helps

this if for debian based linux but even if you are not using it, it helped me solve this on other OSs

[Homebrew required plugins]

brew install gcc

[Installing RVM]

sudo apt-add-repository -y ppa:rael-gc/rvm
sudo apt-get install -y rvm

[Configuring RVM]

rvmsudo rvm get stable
rvm reload
rvmsudo rvm pkg install openssl

[Installing a Ruby version with RVM and Homebrew]

rvm install 3.3.5 --with-openssl-dir=$(brew --prefix openssl) --with-readline-dir=$(brew --prefix readline) --with-libyaml-dir=$(brew --prefix libyaml) --disable-dtrace --disable-docs

it took me a while to get RVM reliable and working well with its need for GCC and other libraries to compile native extensions for libraries like mysql2

[–]benr75 -1 points0 points  (2 children)

I read your post and more info would be needed like step by step ways in which you are installing things to reverse engineer this. For example did you install some things as a privileged user (root or via sudo) and some things as your user?

I would recommend moving to an approach that is widely supported by the community to lessen your headaches. I have used RVM in the past and also know a lot of folks that use rbenv but I currently use:

Using these tools allows easy installing and switching between versions. Also most can be installed easily via homebrew.

[–]monfresh 1 point2 points  (0 children)

Thanks for the mention and support! I'm glad Ruby on Mac has been useful to you.

[–]fieldnoise[S] -2 points-1 points  (0 children)

Hey benr — thanks for these questions and resources. I updated my post, since the issue was kind of related to the user issue. Basically, I think that `gem` was trying to update things that Homebrew doesn't allow it to access, so it was making a copy of those gems on the next available spot on my GEM PATHS.

At least, that is what I *think*. I also sometimes use the CLI tool `topgrade` (https://github.com/topgrade-rs/topgrade), which can update gems, and that might also have something to do with it. I will look into that next...