First of all, MAC comes with ruby, which is managed by rvm. If you install a new version with homebrew, you may encounter problems when upgrading cocoapods. Obviously, you have upgraded to the latest version with homebrew, and the page configures the environment variables. Why still can't upgrade cocoapods?
Because the system defaults to
To use a bubble display, use a third-party library on git
Executing the pod install command reports an error:
$ pod install
Analyzing dependencies
[!] Unable to satisfy the following requirements:
- `LFKit/Component/LFBubbleView` required by `Podfile`
None of your spec sources contain a spec satisfying the dependency: `LFKit/Component/LFBubbleView`.
You have either:
* out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.
Then, I followed the prompts and entered the command:
$pod update --verbose
Update all pods
Preparing
Updating local specs repositories
Updating spec repo `master`
[!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down
There was a lot of vomit in the back.
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-core-1.3.1/lib/cocoapods-core/github.rb:105:in `rescue in modified_since_commit'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-core-1.3.1/lib/cocoapods-core/github.rb:100:in `modified_since_commit'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-core-1.3.1/lib/cocoapods-core/source.rb:445:in `unchanged_github_repo?'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-core-1.3.1/lib/cocoapods-core/source.rb:334:in `update'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/sources_manager.rb:88:in `block (2 levels) in update'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/user_interface.rb:64:in `section'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/sources_manager.rb:87:in `block in update'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/sources_manager.rb:86:in `each'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/sources_manager.rb:86:in `update'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/installer/analyzer.rb:237:in `block in update_repositories'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/installer/analyzer.rb:235:in `each'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/installer/analyzer.rb:235:in `update_repositories'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:150:in `block in resolve_dependencies'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/user_interface.rb:64:in `section'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:149:in `resolve_dependencies'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:116:in `install!'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/command/update.rb:81:in `run'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/lib/cocoapods/command.rb:52:in `run'
/Users/username/.rvm/gems/ruby-2.4.1@global/gems/cocoapods-1.3.1/bin/pod:55:in `<top (required)>'
/Users/username/.rvm/rubies/ruby-2.4.1/bin/pod:23:in `load'
/Users/username/.rvm/rubies/ruby-2.4.1/bin/pod:23:in `<main>'
The main meaning is that either your network has a problem, or GitHub is down.
The execution of the pod update command is unsuccessful, and naturally the latest cocoapods library index cannot be updated.
From the prompt information, my ruby is 2.4.1, and the cocoapods version is 1.3.1, which is relatively new.
The last discovery is that Github removed some low encryption standard protocols on February 23, 2018, including TLSv1/TLSv1.1, diffie-hellman-group1-sha1, diffie-hellman-group14-sha1, related links are here : Weak cryptographic standards removed , see GitHub's official announcement.
There is already a solution on stackoverflow: the general process is:
$ which openssl
/usr/bin/openssl
$ openssl version
OpenSSL 0.9.8zh 14 Jan 2016
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew update
$ brew install openssl
$ brew upgrade openssl
`` If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
$ echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile
$ which openssl
/usr/local/opt/openssl/bin/openssl
$ openssl version
OpenSSL 1.0.2n 7 Dec 2017
$ brew install rbenv ruby-build
//这里可能 会跟你自己安装ruby的方式冲突,请看文章最后, 建议用 rvm 就用rvm, 用rbenv 就卸载rvm 再安装 rbenv,二选一
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
$ source ~/.bash_profile
$ rbenv install --list
Available versions:
1.8.5-p52
1.8.5-p113
1.8.5-p114
1.8.5-p115
1.8.5-p231
1.8.6
:
2.5.0-rc1
2.5.0
2.6.0-dev
:
$ rbenv install 2.5.0
$ rbenv versions
* system (set by /Users/username/.rbenv/version)
2.5.0
$ ruby --version
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
$ rbenv global 2.5.0
但是我按照这些方法还是不行,原因可能是,我安装或升级pods时用的是 rvm管理的,再次升级安装,它会自动用用ruby 2.4.1 。而不会用brew安装的 2.5.1 。
使用命令:$ ruby --version
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
发现确实是 bash 引用的还是 ruby 2.4.1
最后我觉得应该把 rvm 管理的系统ruby升级:
安装rvm
列出ruby可安装版本 rvm list known
安装一个需要的ruby版本 rvm install 2.5.0
$ brew upgrade openssl
但是在
rvm install 2.5.0 命令执行过程中发现, 他自动 升级了homebrew, 然后升级了 openssl到1.1 总之,这个 github加密升级的东西是搞定了。
Updating Homebrew...
==> Upgrading 3 outdated packages, with result:
coreutils 8.28_1 -> 8.29, [email protected] 1.1.0f -> 1.1.0h, automake 1.15.1 -> 1.16.1
==> Upgrading [email protected]
==> Downloading https://homebrew.bintray.com/bottles/[email protected]_sie
######################################################################## 100.0%
==> Pouring [email protected]_sierra.bottle.tar.gz
CocoaPods 1.5.0 is available.
To update use: `sudo gem install cocoapods`
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.5.0
Pod installation complete! There are 11 dependencies from the Podfile and 11 total pods installed.
关于ruby 多版本的问题以后再做探讨,似乎有一个管理多版本ruby的第三方库。