mac os 如何更新Ruby

1 、执行pod update 报错如下

[!] /bin/bash -c

set -e

sh build.sh cocoapods-setup

./scripts/swift-version.sh: line 59: [: =: unary operator expected

No version of Xcode found that supports Swift 2.2

2、检查pod  版本 和ruby 版本

 ✗ pod –version

1.2.1.beta.1

✗ ruby –version

ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]      

3 、升级ruby   

先参考ruby升级链接ruby升级链接

安装ruby版本管理器rvm

#1、  RVM安装

$ curl -L get.rvm.io | bash -s stable

# 2、  之后就是等待一段时间之后,就可以安装成功了,使用以下命令来验证

$ source ~/.bashrc

$ source ~/.bash_profile

# 3、 测试是否安装正常

$ rvm -v

#1、查看当前ruby版本

$ ruby -v

这一步会显示出来当前ruby的版本

#2、列出已知ruby的版本

$ rvm list known

稍等一下,会出现很多平台不同的ruby的版本,我因为是需要2.2.2以上的版本,所以直接安装2.2.4版本

#3、安装ruby 2.2.4

$ rvm install 2.2.4

解释安装总是没有一帆风顺的

1、$ rvm install 2.2.4 会出现报错  

 ✗ rvm install 2.2.4

Searching for binary rubies, this might take some time.

Found remote file https://rvm_io.global.ssl.fastly.net/binaries/osx/10.11/x86_64/ruby-2.2.4.tar.bz2

Checking requirements for osx.

Installing requirements for osx.

Updating system……..

Error running ‘requirements_osx_brew_update_system ruby-2.2.4’,

showing last 15 lines of /Users/SY_jinjinzhou/.rvm/log/1489975304_ruby-2.2.4/update_system.log

https://github.com/Homebrew/homebrew/wiki/Common-Issues

and make sure `brew update` works before continuing.’

++ rvm_pretty_print stderr

++ case “${rvm_pretty_print_flag:=auto}” in

++ case “${TERM:-dumb}” in

++ case “$1” in

++ [[ -t 2 ]]

++ return 1

++ printf %b ‘Failed to update Homebrew, follow instructions here:

https://github.com/Homebrew/homebrew/wiki/Common-Issues

and make sure `brew update` works before continuing.\n’

Failed to update Homebrew, follow instructions here:

https://github.com/Homebrew/homebrew/wiki/Common-Issues

and make sure `brew update` works before continuing.

++ return 1

Requirements installation failed with status: 1.

2、根据提示需要更新brew

 ✗ brew update

Error: /usr/local must be writable!

更新brew依然报错

可参考链接:http://securityer.lofter.com/post/1d0f3ee7_bcf5f05

大致过程是 执行✗ brew doctor  命令 会显示如下

Please note that these warnings are just used to help the Homebrew maintainers

with debugging if you file an issue. If everything you use Homebrew for is

working fine: please don’t worry and just ignore them. Thanks!

Warning: /usr/local is not writable.

You should probably change the ownership and permissions of /usr/local

back to your user account.

sudo chown -R $(whoami) /usr/local

Warning: /usr/local is not writable.

Even if this directory was writable when you installed Homebrew, other

software may change permissions on this directory. For example, upgrading

to OS X El Capitan has been known to do this. Some versions of the

“InstantOn” component of Airfoil or running Cocktail cleanup/optimizations

are known to do this as well.

You should probably change the ownership and permissions of /usr/local

back to your user account.

sudo chown -R $(whoami) /usr/local

Warning: Your Homebrew is outdated.

You haven’t updated for at least 24 hours. This is a long time in brewland!

To update Homebrew, run `brew update`.

接着

 ✗ sudo chown -R $(whoami) /usr/local

Password:

➜  Toon git:(develop) ✗ brew update

/usr/local/Library/Homebrew/cmd/update.sh: line 13: /usr/local/Library/ENV/scm/git: No such file or directory

/usr/local/Library/Homebrew/cmd/update.sh: line 13: /usr/local/Library/ENV/scm/git: No such file or directory

/usr/local/Library/Homebrew/cmd/update.sh: line 13: /usr/local/Library/ENV/scm/git: No such file or directory

/usr/local/Library/Homebrew/cmd/update.sh: line 13: /usr/local/Library/ENV/scm/git: No such file or directory

/usr/local/Library/Homebrew/cmd/update.sh: line 13: /usr/local/Library/ENV/scm/git: No such file or directory

Error: update-report should not be called directly!

依然报错  再执行一遍brew update

✗ brew update

执行结果类似如下

Updated 1 tap (homebrew/core).

==> Cleaning up /Library/Caches/Homebrew…

Removing: /Library/Caches/Homebrew/autojump-22.3.0.el_capitan.bottle.tar.gz.incomplete… (24KB)

Removing: /Library/Caches/Homebrew/autojump-22.3.0.tar.gz… (51.7KB)

Removing: /Library/Caches/Homebrew/zsh-completions-0.17.0.tar.gz… (216.0KB)

==> Migrating /Library/Caches/Homebrew to /Users/SY_jinjinzhou/Library/Caches/Homebrew…

==> Deleting /Library/Caches/Homebrew…

………………

查看Ruby版本 安装ruby

 ✗ rvm list known

 ✗ rvm install 2.4

执行结果如下 

Searching for binary rubies, this might take some time.

No binary rubies available for: osx/10.11/x86_64/ruby-2.4.0.

Continuing with compilation. Please read ‘rvm help mount’ to get more information on binary rubies.

Checking requirements for osx.

Installing requirements for osx.

Updating system……

Installing required packages: autoconf, automake, libtool, pkg-config, coreutils, libyaml, readline, libksba, openssl@1.1……….

Certificates in ‘/usr/local/etc/openssl@1.1/cert.pem’ are already up to date.

Requirements installation successful.

Installing Ruby from source to: /Users/SY_jinjinzhou/.rvm/rubies/ruby-2.4.0, this may take a while depending on your cpu(s)…

ruby-2.4.0 – #downloading ruby-2.4.0, this may take a while depending on your connection…

% Total    % Received % Xferd  Average Speed  Time    Time    Time  Current

Dload  Upload  Total  Spent    Left  Speed

9 11.9M    9 1159k    0    0    659      0  5:17:58  0:29:58  4:48:00    0Warning: Transient problem: timeout Will retry in 2 seconds. 3 retries left.

等待安装

如果报错如下

……

There was an error(56).

Checking fallback: https://ftp.ruby-lang.org/pub/ruby/2.4/ruby-2.4.0.tar.bz2

No fallback URL could be found, try increasing timeout with:

echo “export rvm_max_time_flag=20” >> ~/.rvmrc

There has been an error fetching the ruby interpreter. Halting the installation.

重新执行✗ rvm install 2.4

    原文作者:鹊之燕小窝
    原文地址: https://www.jianshu.com/p/498bb42b4ecb
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞