veer7 veer7 - 5 months ago 10
Ruby Question

brew install rbenv Error: rbenv-rbenv already installed To install this version, first `brew unlink rbenv`

I am trying to install

rbenv
on
OS X
by following instruction from site link - setup ruby on macbook

when I try
brew install rbenv
I get below error

Error: rbenv-rbenv already installed To install this version, first 'brew unlink rbenv'


Here is the output from
brew doctor


brew doctor
Your system is ready to brew.


I tried brew unlink rbenv on which fails with message
Error: No such keg: /usr/local/Cellar/rbenv


Please suggest how this can be solved.

I have tried all solutions as listed below

brew update


brew prune


brew link rbenv


nothing really works

Answer

This, I was able to solve by thrashing all the junk files and folders related to rbenv still existing in the system; as brew link rbenv wasn't working

Use command below to find any rbenv files/folder still existing in the system.

sudo find /user/ -name "*rbenv*"

most of the issues could be because /usr/local/opt may still have folders related to rbenv

then carefully remove any listed files/folder using command

sudo rm -r <folder-listed-in-result-of-above-command>

then try brew install rbenv, follow any output from this command (which may suggest brew unlink rbenv && brew link rbenv) and you should be good to go.

I do not recommend file/folder thrashing this way as it could be risky however, to be frank, this is only what worked for me.