Mel
Mel

Reputation: 2705

RVM upgrade ruby 2.1.7

I am on a mac and trying to figure out how to upgrade my ruby from 2.1.1 to 2.1.7.

I keep getting errors that I can't figure out.

When I try to figure out if Homebrew is on my mac, I try:

which brew

That gives:

/usr/local/bin/brew

Then I try: MJ-2:~ m$ brew doctor

And I get:

/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 23: /usr/local/Library/brew.rb: Undefined error: 0
MJ-2:~ m$ 

I try upgrading with rvm as:

rvm install ruby 2.1.7

And I get:

Warning! PATH is not properly set up, '/Users/m/.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'.
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.10/x86_64/ruby-2.1.7.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx_brew.
/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 23: /usr/local/Library/brew.rb: Undefined error: 0
ERROR: '/bin' is not writable - it is required for Homebrew, try 'brew doctor' to fix it!
Requirements installation failed with status: 1.

When I then try:

rvm get stable --auto-dotfiles

I get a big long list of errors that mostly say:

scripts/functions/support: Can't unlink already-existing object

And finish with:

tar: Error exit delayed from previous errors.
Could not extract RVM sources.
Could not update RVM, get some help at #rvm IRC channel at freenode servers.

I can't understand what's wrong. It seems HomeBrew isn't on my mac anymore or at least it isn't recognised on my mac (although which brew has a file path) and I don't seem to be able to use rvm install command either.

How do I upgrade my ruby version from the terminal on a mac?

Upvotes: 0

Views: 1093

Answers (1)

Rajuk
Rajuk

Reputation: 155

Try the below resolution steps, it worked for me.

  1. First check owner of /usr/local directory. It should be owned by your username. If not run the below command.

    $ sudo chown -R `whoami` /usr/local
    
  2. Reset your Homebrew HEAD

    $ cd /usr/local
    $ git reset --hard FETCH_HEAD
    
  3. Now update and upgrade your brew.

    $ brew update && brew upgrade
    
  4. After this command, your brew installation is fixed and you should be able to install new packages using brew.

  5. There might be one more challenge after this. There might be a chance that some of the packages which where working well might give error. And you will be getting "dyld: Library not loaded:" error. This means the dependency for that installation is missing or an upgrade is needed. You need to install the missing package and re-install your package.

Example Error and Fix:

    $ ruby -v
     dyld: Library not loaded: /usr/local/lib/libgmp.10.dylib
     Referenced from: /Users/claretrembath/.rvm/rubies/ruby-2.1.3/bin/ruby
     Reason: image not found
     Trace/BPT trap: 5

The error says, unable to load "libgmp". You can find and libgmp package in brew and install it. Below command should fix the issue.

    $ brew install gmp && rvm reinstall 2.1.7

Upvotes: 1

Related Questions