Matt K
asked on
Errors, mess after trying to update Ruby via Terminal
StackOverflow refugee here. Apparently – according to the "help" I received there, I'm hosed. This is the question I asked initially:
End of post. Here are the comments I got (no answers, just SO users smelling noob blood in the water):
I asked what hole?
I didn't see where I changed permissions across the whole filesystem, just for a short list of directories – but what do I know? The user above could/would not say. But hey, I should be fine if I can just get everything back to the way in was before and only use rvm. Great!
Another user comment:
See, but I didn't do that, and apparently that means I've dug myself an inescapable hole. With little regard to my own safety, I tried to do it presently:
I get:
Terminal went through some process, throwing bunch of "Failed to initialize MacPorts, OS platform mismatch" and "Current platform "darwin 17" does not match expected platform "darwin 11" errors. and finally, this:
As suggested, I run:
and get this:
gem.install.gem-wrappers-> =1.4.0.log says:
and in Terminal:
Terminal suggested running the following, so I did:
No idea how Homebrew is back in the picture (thought I was avoiding that), but I clearly have a knowledge gap here – tying to get my head around it. It returned this:
NO idea how to go about removing paths, but I felt as though enough damage had been done without starting in with that. As suggested above, I ran
This returns:
I restarted terminal.
Great. I run:
and get:
`rvm reset` returns same.
Ruby version remains 2.0.0p247.
I have full system backups if that's my only choice – ideally I on'y have to restore certain directories and not my entire system, but I can if I have to. You know, 'cause if I just undo all this and only use RVM, I "should be fine." Ugh...
The irony is that I found the instructions to use Homebrew to install Ruby on SO. I probably should have come here first. Hoping y'all can prove me right on that. I have undeniably made a mess of things.
The long and short here is that I apparently broke my filesystem. I realize I'm way out of my depth, and I guess I learned not to go wild in Terminal again. In the meantime, I'd love to be able to get to a point where I can update ruby and use Jekyll.
If you made it this far, thank you. Please help?
Trying to install Jekyll, I get a warning that I need Ruby 2.1. I am running 2.0.0.
I run:
Evidently, this was my first grievous error. Terminal goes through the process for a bit, then throws this error:
So I run (as prompted):
then again run:
New error:
So I run (suggested by an SO post):
Then run:
and get:
Okay... so I run:
and get:
So Ruby 2.6.3 is installed, but I'm still running 2.0.0. So I run:
and get:
No sign of 2.6.3.
I'm out of my element here. Can anyone help me out?
I run:
brew upgrade ruby
Evidently, this was my first grievous error. Terminal goes through the process for a bit, then throws this error:
Error: The following directories are not writable by your user:
/usr/local/opt
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
So I run (as prompted):
chmod u+w /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions
then again run:
brew upgrade ruby
New error:
Error: Permission denied @ unlink_internal - /usr/local/lib/ruby/2.0.0
So I run (suggested by an SO post):
sudo chown -R $(whoami) /usr/local/lib/ruby/2.0.0
Then run:
brew upgrade ruby
and get:
Error: ruby 2.6.3 already installed
Okay... so I run:
ruby -v
and get:
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.5.0]
So Ruby 2.6.3 is installed, but I'm still running 2.0.0. So I run:
which -a ruby
and get:
/Users/me/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
/Users/me/.rvm/bin/ruby
/usr/bin/ruby
No sign of 2.6.3.
I'm out of my element here. Can anyone help me out?
End of post. Here are the comments I got (no answers, just SO users smelling noob blood in the water):
Not sure how you're going to dig yourself out of the hole you're in now, but never use brew to install Ruby. Always use a Ruby manager like RVM, and only a Ruby manager like RVM. Should be as simple as rvm install 2.1.10, then rvm use 2.1.10, then ruby -v.
I asked what hole?
The hole of having changed permissions across your filesystem & installed Ruby via brew. If you can get everything undone and switch to RVM exclusively you should be fine.
I didn't see where I changed permissions across the whole filesystem, just for a short list of directories – but what do I know? The user above could/would not say. But hey, I should be fine if I can just get everything back to the way in was before and only use rvm. Great!
Another user comment:
Even robust package managers like those on Linux OS cannot deal with multiple versions of Ruby in an appropriate way. Use rvm or rbenv or chruby.
See, but I didn't do that, and apparently that means I've dug myself an inescapable hole. With little regard to my own safety, I tried to do it presently:
rvm install 2.1.10
I get:
Warning! PATH is not properly set up, '/Users/me/.rvm/gems/ruby-2.0.0-p247/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.0.0-p247'.
Terminal went through some process, throwing bunch of "Failed to initialize MacPorts, OS platform mismatch" and "Current platform "darwin 17" does not match expected platform "darwin 11" errors. and finally, this:
Error running 'requirements_osx_port_update_system ruby-2.1.10',
please read /Users/me/.rvm/log/1563389170_ruby-2.1.10/update_system.log
Requirements installation failed with status: 1.
As suggested, I run:
\curl -sSL https://get.rvm.io | bash -s stable --ruby
and get this:
Error running 'command gem install /Users/me/.rvm/gem-cache/gem-wrappers-1.4.0.gem --local --no-ri --no-rdoc',
please read /Users/me/.rvm/log/1563389462_ruby-2.0.0-p247/gem.install.gem-wrappers->=1.4.0.log
gem.install.gem-wrappers->
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Users/me/.rvm/gems/ruby-2.0.0-p247@global/gems/gem-wrappers-1.4.0
and in Terminal:
Regenerating gem wrappers in 1 rubiesERROR: While executing gem ... (Gem::CommandLineError)
Unknown command wrappers
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command wrappers
Terminal suggested running the following, so I did:
brew tap --repair
No idea how Homebrew is back in the picture (thought I was avoiding that), but I clearly have a knowledge gap here – tying to get my head around it. It returned this:
Error: Could not link:
/usr/local/share/man/man1/brew.1
Please delete these paths and run `brew update`.
NO idea how to go about removing paths, but I felt as though enough damage had been done without starting in with that. As suggested above, I ran
rvm get stable --auto-dotfiles
This returns:
A RVM version 1.29.9 (latest) is installed yet 1.23.12 (stable) is loaded.
I restarted terminal.
RVM reloaded!
Great. I run:
rvm -v
and get:
Warning! PATH is not properly set up, /Users/mattk/.rvm/gems/ruby-2.0.0-p247/bin is not at first place.
Usually this is caused by shell initialization files. Search for PATH=... entries.
You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles
To fix it temporarily in this shell session run: rvm use ruby-2.0.0-p247
To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.
rvm 1.29.9 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
`rvm reset` returns same.
Ruby version remains 2.0.0p247.
I have full system backups if that's my only choice – ideally I on'y have to restore certain directories and not my entire system, but I can if I have to. You know, 'cause if I just undo all this and only use RVM, I "should be fine." Ugh...
The irony is that I found the instructions to use Homebrew to install Ruby on SO. I probably should have come here first. Hoping y'all can prove me right on that. I have undeniably made a mess of things.
The long and short here is that I apparently broke my filesystem. I realize I'm way out of my depth, and I guess I learned not to go wild in Terminal again. In the meantime, I'd love to be able to get to a point where I can update ruby and use Jekyll.
If you made it this far, thank you. Please help?
@Matt K
It sounds like your Homebrew install was either incorrectly done or it was initially installed by another user account, based on your beginning error messages. Usually it's done under a single user account. If you really need multiple users to install packages, then you should use MacPorts and run port install package as root using sudo. Homebrew is more for individual personal systems that are mainly run by a single user.
You can fix it by adding write permissions to the "admin" group or putting your account into the admin group. You'll see several folders under /usr/local/ that are owed by the original user that installed Homebrew. You can easily just recursively change the ownership to your account to "fix" Homebrew so that you became the user that can run the brew commands.
brew tap --repair fixes the broken symlinks in the Homebrew casks by replacing them with directories. <- This indicates that someone manually deleted stuff in homebrew and broke the installs or it was installed originally by another user account and you didn't have permissions to /usr/local/Cellar/ where all the homebrew installs reside.
As for why your which command doesn't return /usr/local/bin/ where homebrew symlinks to /usr/local/Cellar/<package >/
You just have the wrong path order, or you're missing it from your path. This seems to indicate that someone removed the path manually. You can either fix the path or reinstall homebrew.
If you had installed homebrew with your account, you would own /usr/local/Cellar/ and you would have /usr/local/bin first in your path. That would allow you to reach the latest version of the ruby package installed through homebrew.
Open terminal. Check the /etc/paths file to see what you have inside. Make the first line /usr/local/bin/ inside the /etc/paths file. Open a new terminal window without closing the previous window. Check your $PATH and make sure you can run the correct version of ruby. If it works, you can close the first terminal. Always leave the original terminal window open in case you mess up a config line. This way you can return to it and fix it in case the new windows doesn't load correctly.
@David
@Matt K.
P.S. This is really a Mac Topic not a linux topic.
It sounds like your Homebrew install was either incorrectly done or it was initially installed by another user account, based on your beginning error messages. Usually it's done under a single user account. If you really need multiple users to install packages, then you should use MacPorts and run port install package as root using sudo. Homebrew is more for individual personal systems that are mainly run by a single user.
You can fix it by adding write permissions to the "admin" group or putting your account into the admin group. You'll see several folders under /usr/local/ that are owed by the original user that installed Homebrew. You can easily just recursively change the ownership to your account to "fix" Homebrew so that you became the user that can run the brew commands.
brew tap --repair fixes the broken symlinks in the Homebrew casks by replacing them with directories. <- This indicates that someone manually deleted stuff in homebrew and broke the installs or it was installed originally by another user account and you didn't have permissions to /usr/local/Cellar/ where all the homebrew installs reside.
As for why your which command doesn't return /usr/local/bin/ where homebrew symlinks to /usr/local/Cellar/<package
You just have the wrong path order, or you're missing it from your path. This seems to indicate that someone removed the path manually. You can either fix the path or reinstall homebrew.
If you had installed homebrew with your account, you would own /usr/local/Cellar/ and you would have /usr/local/bin first in your path. That would allow you to reach the latest version of the ruby package installed through homebrew.
Open terminal. Check the /etc/paths file to see what you have inside. Make the first line /usr/local/bin/ inside the /etc/paths file. Open a new terminal window without closing the previous window. Check your $PATH and make sure you can run the correct version of ruby. If it works, you can close the first terminal. Always leave the original terminal window open in case you mess up a config line. This way you can return to it and fix it in case the new windows doesn't load correctly.
@David
All other Distros will likely provide similar Ruby installation simplicity... so... remove all traces of Homebrew then install using your Distro package manager.Homebrew does not cause complex problems unless you use it in conjunction with other package management or self install from source. If you don't understand Mac Unix, you should learn it rather than keep pushing Ubuntu on Mac users. The rest of your comment is really off topic.
@Matt K.
P.S. This is really a Mac Topic not a linux topic.
ASKER
Thanks, @serialband – much appreciated.
Forgive me, if it isn't already quite obvious I have no idea what I'm doing. I got some bad advice from stack overflow, then followed some suggestions from terminal itself, and things just went from bad to worse.
I am the only user I ever use (there are other of my computers that I give access to, but I've only used them to throw files back and forth), and my user is an admin, so the issue is undoubtedly (and perhaps unsurprisingly) the former. Happy to say I do not need to worry about multiple users.
I'm not educated enough to know exactly who owns which folders here are owned by whom. Not sure if it's relevant, but usr/local itself doesn't have the option to allow admin write access... It says that I (as the admin) "can only read," and the there names available are "system," "wheel," and "everyone."
As for the contents, here's a cap of my usr/local directory:
I started to go through and give each of these folders read and write access for admin, but I froze, fearing I'd done enough damage with my devil-may-care attitude. I have a feeling this is not exactly what I'm supposed to do...
"You can easily just recursively change the ownership to your account"
I have a feeling by recursively you mean I will need do all this via the CLI... the CLI that I used to get me into this trouble in the first place. Would it be possible for you to quickly walk me through the process of recursively take ownership of these folders?
I'm gonna try to take this one step at a time, starting with getting ownership back on track. Hopefully from there I can try reinstalling homebrew, etc. For now, that stuff seems to be Error City.
Forgive me, if it isn't already quite obvious I have no idea what I'm doing. I got some bad advice from stack overflow, then followed some suggestions from terminal itself, and things just went from bad to worse.
your Homebrew install was either incorrectly done or it was initially installed by another user account
I am the only user I ever use (there are other of my computers that I give access to, but I've only used them to throw files back and forth), and my user is an admin, so the issue is undoubtedly (and perhaps unsurprisingly) the former. Happy to say I do not need to worry about multiple users.
You'll see several folders under /usr/local/ that are owned by the original user that installed Homebrew
I'm not educated enough to know exactly who owns which folders here are owned by whom. Not sure if it's relevant, but usr/local itself doesn't have the option to allow admin write access... It says that I (as the admin) "can only read," and the there names available are "system," "wheel," and "everyone."
As for the contents, here's a cap of my usr/local directory:
I started to go through and give each of these folders read and write access for admin, but I froze, fearing I'd done enough damage with my devil-may-care attitude. I have a feeling this is not exactly what I'm supposed to do...
"You can easily just recursively change the ownership to your account"
I have a feeling by recursively you mean I will need do all this via the CLI... the CLI that I used to get me into this trouble in the first place. Would it be possible for you to quickly walk me through the process of recursively take ownership of these folders?
I'm gonna try to take this one step at a time, starting with getting ownership back on track. Hopefully from there I can try reinstalling homebrew, etc. For now, that stuff seems to be Error City.
You likely got answers from Linux users that don't know Mac. You need to ask Mac Unix users for this question. Homebrew should be rather easy to work with.
brew doctor : You need to run this periodically to check on the status of homebrew, especially if you haven't touched it in a while.
brew update : You need to update Homebrew periodically and update the package lists.
brew upgrade : Unless you have a specific need to keep an old package, you should just upgrade all your packages.
Homebrew is supposed to be updated and upgraded constantly. At the very least you should upgrade once a week. If you somehow haven't upgraded in too long, there could be issues the next time you run brew.
In case you have problems with those commands, just reinstall Homebrew.
Current install (2019-07-19) from brew.sh (for convenience) :
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
It's probably best to go to brew.sh to get the installation line, since they have changed it before.
If the there's a failure in the install, the brew doctor command will tell you what may be broken and suggest some fixes. If it's really bad, you can uninstall homebrew by removing the folders in /usr/local/
You can completely remove the Cellar and Homebrew folders from /usr/local/, then fully reinstall Homebrew.
Once that's done correctly, install ruby.
brew install ruby
Also, rather than just individually upgrading ruby with brew upgrade ruby, you should just do the entire thing. If you've had other packages installed, you can get a list of them with brew list and install all those packages as well.
brew doctor : You need to run this periodically to check on the status of homebrew, especially if you haven't touched it in a while.
brew update : You need to update Homebrew periodically and update the package lists.
brew upgrade : Unless you have a specific need to keep an old package, you should just upgrade all your packages.
Homebrew is supposed to be updated and upgraded constantly. At the very least you should upgrade once a week. If you somehow haven't upgraded in too long, there could be issues the next time you run brew.
In case you have problems with those commands, just reinstall Homebrew.
Current install (2019-07-19) from brew.sh (for convenience) :
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
It's probably best to go to brew.sh to get the installation line, since they have changed it before.
If the there's a failure in the install, the brew doctor command will tell you what may be broken and suggest some fixes. If it's really bad, you can uninstall homebrew by removing the folders in /usr/local/
You can completely remove the Cellar and Homebrew folders from /usr/local/, then fully reinstall Homebrew.
Once that's done correctly, install ruby.
brew install ruby
Also, rather than just individually upgrading ruby with brew upgrade ruby, you should just do the entire thing. If you've had other packages installed, you can get a list of them with brew list and install all those packages as well.
Tip: I've been using Macs for decades. I've attempted using Homebrew several times.
Subtle problems always occurred.
Each time I switched back to https://MacPorts.org + normally a simple install works every time.
In the rare instance a problem occurs, a support ticket usually has the problem fixed in a few hours... sometimes a few minutes...
Macports currently installs...
You should get version 2.6.x installing from the Ruby site.
Going back through your original notes, seems like you're trying to mix installation methods.
If you're going to use Homebrew or Macports or RVM, only use one of these methods. Mixing methods will create a royal mess.
Remove all residue from all your previous install attempts, then pick one method + use that one method.
Likely rvm will be best as this will pull the latest interpreter directly from the Ruby Lang site.
Subtle problems always occurred.
Each time I switched back to https://MacPorts.org + normally a simple install works every time.
In the rare instance a problem occurs, a support ticket usually has the problem fixed in a few hours... sometimes a few minutes...
Macports currently installs...
imac> ruby --version
ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-darwin15]
You should get version 2.6.x installing from the Ruby site.
Going back through your original notes, seems like you're trying to mix installation methods.
If you're going to use Homebrew or Macports or RVM, only use one of these methods. Mixing methods will create a royal mess.
Remove all residue from all your previous install attempts, then pick one method + use that one method.
Likely rvm will be best as this will pull the latest interpreter directly from the Ruby Lang site.
I've used all 3 Mac package managers (Homebrew, Macports, Fink) for installing Linux tools on a Mac and never had a problem except for occasionally not being able to find specific apps on one. Those just had to be found on the source sites and manually installed. If you have a problem with Homebrew, something was done incorrectly.
Homebrew is better for a single individual user. It's actually easier to use than Macports. It can be made to work for multiple users, but that's not a default.
Macports is better for a sysadmin. This is also easier when you have multiple users on the same system.
Fink is the first application manager that came to OS X, but isn't as popular after Macports came to existence. Macports just did it better and had more applications migrated, So many have switched.
Slack is where there a lots of users that google things and google regularly returns blogs that have "popular" results that are often times not completely correct. The popular way is not always the correct way. If you've posted on slack with linux as topics, you got Linux answers that are wrong for a Mac, but still sort of work, since it's all based on Unix. I've often actually seen the correct answer with lower ratings on slack, because someone answered correctly much later and it never got the initial flood of votes that the initial, expedient answer got. Expedient teaches the wrong method and may eventually lead to other issues later.
There are also many Mac users that just use a Mac without ever truly working on the BSD based Unix underneath. They don't know the idiosyncrasies of OS X. A lot of users are still thinking in Linux and shoehorn Linux "ideals" onto BSD based Mac OS X. It's the difference between Ubuntu/Debian, Redhat/CENTOS, SUSE, Solaris, Irix, HPUX, AIX, Ultrix. They are all Unix based, but they all have their own layout and idiosyncrasies.
Homebrew is better for a single individual user. It's actually easier to use than Macports. It can be made to work for multiple users, but that's not a default.
Macports is better for a sysadmin. This is also easier when you have multiple users on the same system.
Fink is the first application manager that came to OS X, but isn't as popular after Macports came to existence. Macports just did it better and had more applications migrated, So many have switched.
Slack is where there a lots of users that google things and google regularly returns blogs that have "popular" results that are often times not completely correct. The popular way is not always the correct way. If you've posted on slack with linux as topics, you got Linux answers that are wrong for a Mac, but still sort of work, since it's all based on Unix. I've often actually seen the correct answer with lower ratings on slack, because someone answered correctly much later and it never got the initial flood of votes that the initial, expedient answer got. Expedient teaches the wrong method and may eventually lead to other issues later.
There are also many Mac users that just use a Mac without ever truly working on the BSD based Unix underneath. They don't know the idiosyncrasies of OS X. A lot of users are still thinking in Linux and shoehorn Linux "ideals" onto BSD based Mac OS X. It's the difference between Ubuntu/Debian, Redhat/CENTOS, SUSE, Solaris, Irix, HPUX, AIX, Ultrix. They are all Unix based, but they all have their own layout and idiosyncrasies.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Better to use a sensible Linux Distro, like Ubuntu, then just install the normal OS level packages.
Default packages for Debian/Ubuntu looks to by ruby-2.5.1p57 which can be installed by a simple...
Open in new window
All other Distros will likely provide similar Ruby installation simplicity... so... remove all traces of Homebrew then install using your Distro package manager.
Big Tip: Using Homebrew can cause complex problems with your system. You must be very smart about every package installed to determine if your $PATH setting for Homebrew will cause system instability or all will be well.
Best to use your OS package manager to ensure your system works as expected.