mac os 如何更新Ruby

1 、執(zhí)行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

大致過程是 執(zhí)行? 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!


依然報錯? 再執(zhí)行一遍brew update

? brew update

執(zhí)行結果類似如下

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

執(zhí)行結果如下?

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.

重新執(zhí)行? rvm install 2.4

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容