Homebrew broken? Ruby Broken? Can't run brew or reinstall - ruby

I can't run anything in brew. I do not know what has happened. I tried to install Jekyll and I started getting this error.
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 23: /usr/local/Library/brew.rb: Undefined error: 0
Also, ruby version: ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
Here is what I typed:
~]$ brew install ruby (gh-pagesāœ±)
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 23: /usr/local/Library/brew.rb: Undefined error: 0

Try switching over to rbenv to install and manage your ruby:
$ brew update
$ brew install rbenv ruby-build
Afterwards you'll still need to add eval "$(rbenv init -)" to your profile. You'll only ever have to do this once.
$ rbenv install 2.0.0p481
https://github.com/sstephenson/rbenv#homebrew-on-mac-os-x

Related

ERROR: Loading command: install (LoadError) cannot load such file -- zlib

I need for my project ruby version 1.9.3.
It was really difficult to instal this version on my Mac(macOS Catalina 10.15.7) via rbenv (it did not work at all via rvm) But after installation all commands gem install (bundler, for example), leads to this error.
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
brew install zlib says that it has already been installed.
Ruby version was installed successfully through command
RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl#1.0)" rbenv install 1.9.3-p551
After that I reinstalled it through this command
RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl#1.0)
--with-zlib-dir=/usr/local/Cellar/zlib/1.2.11" rbenv install 1.9.3-p551
And reinstall my Xcode from 12 version to 11 and back. Nothing worked. Please help!

Ruby 2.2.3 in 2020

Ruby 2.2.3 has been dead for a while and yet I've been asked to look at a legacy project in order to update and fix it.
I can't get 2.2.3 to install in order to get a local env up and running on either MacOS or Ubuntu.
The error seems to be down to an openssl rubygems issue:
from rubygems.install.log
Exception `LoadError' at /Users/user/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems.rb:1222 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /Users/user/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems.rb:1231 - cannot load such file -- rubygems/defaults/ruby
/Users/user/.rvm/src/rubygems-3.0.8/lib/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- openssl (LoadError)
Does anyone have any suggestions on how proceed?
On MacOS using rbenv instead of rvm solves this issue and has allowed me to move onto another host of dependency issues.
$ brew update && brew upgrade
$ brew doctor
Solve all brew doctor warnings, then proceed further
$ brew uninstall ruby
$ brew install rbenv
$ brew install ruby-build
$ echo 'export RBENV_ROOT=/usr/local/var/rbenv' >> ~/.bash_profile
$ echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
$ rbenv install -l
$ rbenv install 2.2.3
$ rbenv global 2.2.3

Updating fastlane fails: signet requires Ruby version >= 2.4.0

I'm unable to update fastlane.
When I execute fastlane update_fastlane I get the following error.
ERROR: Error installing fastlane:
signet requires Ruby version >= 2.4.0.
When I execute ruby -v I get ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]
I'm stuck at fastlane version 2.28.3. I have tried reinstalling fastlane but I still get the same error.
What can be the cause of this issue? How can I resolve this?
Use this approach.
Remove fastlane from homebrew. Open terminal and run:
brew cask uninstall fastlane
Install ruby environments. Run in terminal:
brew install rbenv ruby-build
echo "" >> ~/.bash_profile
echo 'export PATH=${HOME}/homebrew/bin:${PATH}' >> ~/.bash_profile
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
rbenv install 2.6.5
rbenv global 2.6.5
exit
Open terminal again and run:
gem install fastlane
fastlane -v
Inspiration form:
https://hackernoon.com/the-only-sane-way-to-setup-fastlane-on-a-mac-4a14cb8549c8
I was able to install following the steps provided by gdingenen: https://github.com/fastlane/fastlane/issues/15467#issuecomment-540964272
Delete the .fastlane folder from the user's home folder
rm -r -df ~/.fastlane
Install using gem
sudo gem install fastlane -NV
You just need to replace the old ruby with the lastest one.
Find the lastest one. Execute which ruby, my result is /usr/local/opt/ruby/bin/ruby.
Find the old one. It's /Users/username/.fastlane/bin/bundle/bin/ruby
Replace it. Done.

brew doctor bad interpetor no such file

I haven't tried using brew since upgrading from Mavericks to Yosemite. I'm getting the following error.
legion:~ jkratz$ brew doctor
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 26: /usr/local/Library/brew.rb: Undefined error: 0
Would you have anything against running the uninstaller script and starting again? Looks like ruby has moved and it can't find it.
You haven't run brew upgrade in a while and Apple upgraded their Ruby!
To fix, do cd /usr/local && git pull and you should be fine.

While trying to install rvm and ruby on ubuntu, curl is not recognized but is installed

I'm installing rvm/ruby onto ubuntu 12.04 but I'm running into an issue.
rvm successfully installs, but afterwards when I try to do rvm install ruby I get this output:
RVM requires 'curl'. Install 'curl' first and try again.
Warning, new version of rvm available '', you are using older version '1.24.7'.
You can disable this warning with: echo rvm_autoupdate_flag=0 >> ~/.rvmrc
You can enable auto-update with: echo rvm_autoupdate_flag=2 >> ~/.rvmrc
/usr/local/rvm/scripts/functions/utility_system: line 21: awk: command not found
/usr/local/rvm/scripts/functions/utility_system: line 22: dpkg: command not found
/usr/local/rvm/scripts/functions/utility_system: line 191: tr: command not found
/usr/local/rvm/scripts/functions/utility: line 210: head: command not found
/usr/local/rvm/scripts/functions/utility: line 204: sort: command not found
/usr/local/rvm/scripts/functions/utility_system: line 21: awk: command not found
/usr/local/rvm/scripts/functions/utility_system: line 22: dpkg: command not found
/usr/local/rvm/scripts/functions/utility_system: line 191: tr: command not found
/usr/local/rvm/scripts/functions/support: line 248: find: command not found
/usr/local/rvm/scripts/functions/utility_system: line 21: awk: command not found
/usr/local/rvm/scripts/functions/utility_system: line 22: dpkg: command not found
/usr/local/rvm/scripts/functions/utility_system: line 191: tr: command not found
/usr/local/rvm/scripts/functions/utility: line 210: head: command not found
/usr/local/rvm/scripts/functions/utility: line 204: sort: command not found
Searching for binary rubies, this might take some time.
No binary rubies available for: ///ruby-2.0.0-p353.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for .
Requirements support for ruby-2.0.0-p353 is not implemented yet,
report a bug here => https://github.com/wayneeseguin/rvm/issues
Requirements installation failed with status: 1.
The thing is, curl is installed:
# curl
curl: try 'curl --help' or 'curl --manual' for more information
I can run curl no problem. Any ideas?
UPDATE 2014-09
If you'are trying to install RVM system wide, preferred is to use a normal user (not root) for RVM installation.
$ curl -L get.rvm.io | bash -s stable
$ source ~/.rvm/scripts/rvm
$ rvm requirements
$ rvm install 2.1.3
$ rvm use --default 2.1.3
Also, perhaps off-topic, for a prod server and to replace default 1.8.7 (system wide) you could do it without RVM:
$ git clone https://github.com/sstephenson/ruby-build.git
$ cd ruby-build
$ ./install.sh
$ ruby-build 2.1.3 /usr/local

Resources