初次使用简书写文章,格式略乱,轻喷~~~~
网络不好慎用!!!!
网络不好慎用!!!!
网络不好慎用!!!!
1.打开终端
2 移除现有 Ruby 默认源 输入以下指令
$gem sources --remove https://rubygems.org/
3.使用新的源 输入以下指令
$gem sources -a https://ruby.taobao.org/
4.验证新源是否替换成功 输入以下指令
$gem sources -l
5.安装 CocoaPods
$sudo gem install cocoa pods
//–––––––––––那么问题来了——没遇到的自动跳过————————————
错误提示1
Error installing cocoapods: activesupport requires Ruby version >= 2.2.2.
解决方案 :
1、安装 RVM baby 版本管理器
$curl -L get.rvm.io | bash -s stable
//________等安装完成 出现下面这行提示以下___________
In case of problems: https://rvm.io/helpandhttps://twitter.com/rvm_io
执行
$source ~/.bashrc
$source ~/.bash_profile
测试是否安装正常
$rvm -v
//________提示以下___________
rvm 1.27.0 (latest) by Wayne E. Seguin, Michal Papis[https://rvm.io/]
2、用RVM升级Ruby查看当前ruby版本
$ruby -v
$rvm list known
//________提示以下___________
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.8]
[ruby-]2.2[.4]
[ruby-]2.3[.0]
[ruby-]2.2-headruby-head
# for forks use: rvm install ruby-head---url https://github.com/github/ruby.git --branch 2.2
# JRuby
jruby-1.6[.8]
jruby-1.7[.23]
jruby[-9.0.5.0]
jruby-head
# Rubinius
rbx-1[.4.3]
rbx-2.3[.0]
rbx-2.4[.1]
rbx[-2.5.8]
rbx-head
# Opal
opal
# Minimalistic ruby implementation - ISO 30170:2012
mruby[-head]
# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]
# GoRuby
goruby
# Topaz
topaz
# MagLev
maglev[-head]
maglev-1.0.0
# Mac OS X Snow Leopard Or Newer
macruby-0.10
macruby-0.11
macruby[-0.12]
macruby-nightly
macruby-head
# IronRuby
ironruby[-1.1.3]
ironruby-head
//___________________
安装ruby 2.2.2 执行
$rvm install 2.2.2
干货1:安装ruby遇到" Installing Homebrew - Brew Command Not Found"命令找不到解决方案:
Check XCode is installed or not.
$gcc --version
$ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$brew doctor
$brew update.
完成后 执行
$ruby -v
//–––––打印输出–––––––
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
6 继续安装 CocoaPods
$sudo gem install cocoa pods
//______安装成功提示如下______
Done installing documentation for nap, fourflusher, escape, colored, concurrent-ruby, thread_safe, tzinfo, i18n, activesupport, claide, xcodeproj, molinillo, cocoapods-try, netrc, cocoapods-trunk, cocoapods-stats, cocoapods-search, cocoapods-plugins, cocoapods-downloader, cocoapods-deintegrate, fuzzy_match, cocoapods-core, cocoapods after 21 seconds,23 gems installed
$pod setup
备注:苹果系统升级 OS X EL Capitan 后安装改为:
$sudo gem install -n /usr/local/bin cocoapods
$pod setup
干货2:CocoaPods无限卡在Setting up CocoaPods master repo解决方案:
对于初次使用CocoaPods的同学,即使你不使用pod setup命令,在你初次执行pod install命令时,系统也会自动执行pod setup。而由于网络不稳定的原因,不挂VPN是不可能成功执行pod setup的。(我大天朝的墙啊~~~~)
$ pod repo remove master
$ git clone https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/master
$ pod repo update
7 更新 gem
$sudo gem update --system
8 新建工程,并在终端用 cd 指令到文件夹内
$pod search 第三方
9 新建 Podfile 文件
$ touch Podfile
10 编辑 Podfile 文件,并写入要添加的第三方库(cocoapod1.0.1版本Podfile文件的内容格式要求发生了变化,必须指出指出所用第三方库的target)
platform:ios, '8.0'
#use_frameworks!个别需要用到它,比如reactiveCocoa
target 'XXXApp' do
pod 'AFNetworking', '~> 2.3.1'<-------第三方
end
11 导入第三方库
$pod install --no-repo-update
网友评论
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
ps:本人没有用RVM baby 版本管理器
Checked in 'GEM_PATH=/Users/haibocai/.rvm/gems/ruby-2.3.0:/Users/haibocai/.rvm/gems/ruby-2.3.0@global', execute `gem env` for more information
from /Users/haibocai/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/dependency.rb:320:in `to_spec'
from /Users/haibocai/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
from /usr/local/bin/pod:22:in `<main>'
老是卡在这一步,请问大神是什么原因啊
$ ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin16]
然后运行sudo gem install cocoa pods 提示
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
求解答
yum -y install openssl-devel
yum -y install openssl
进入ruby 源码目录下的ext/openssl 目录:
cd /usr/local/src/ruby-2.2.3/ext/openssl/
执行 ruby ./extconf.rb :
[root@server openssl]# ruby extconf.rb
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for assert.h... yes
checking for openssl/ssl.h... yes
..........................................................................中间略..........................................................................
checking for EVP_CTRL_GCM_GET_TAG in openssl/evp.h... yes
creating extconf.h
creating Makefile
将ruby 源码目录下的include 目录软链接到 / 目录下:
[root@server openssl]# ln -s /usr/local/src/ruby-2.2.3/include /
编译安装:
make && make install
然后就好了!
再运行:
gem install redis
即可正常运行!!
CocoaPods 1.1.0.rc.2 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.1.0.rc.2
Setup completed
出来了这些东西是怎么回事可以了吗
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 184 100 184 0 0 239 0 --:--:-- --:--:-- --:--:-- 239
100 22865 100 22865 0 0 5158 0 0:00:04 0:00:04 --:--:-- 10709
Downloading https://github.com/rvm/rvm/archive/1.27.0.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.27.0/1.27.0.tar.gz.asc
我安装rvm的时候无限卡在这个地方了,请问大神是什么原因啊
楼主 这是什么情况
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master
Cloning into 'master'...
error: RPC failed; curl 56 SSLRead() return error -9806
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
这是什么情况
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.11/x86_64/ruby-2.2.2.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
About to install Homebrew, press `Enter` for default installation in `/usr/local`,
type new path if you wish custom Homebrew installation (the path needs to be writable for user)
:
求解
Unable to download data from https://ruby.taobao.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://ruby.taobao.org/specs.4.8.gz)
activesupport requires Ruby version >= 2.2.2.
localhost:~ zzz$ $curl -L get.rvm.io | bash -s stable
-bash: -L: command not found
localhost:~ zzz$
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
Failed during: /usr/bin/sudo /usr/bin/xcode-select --install
Requirements installation failed with status: 1.
打印的ruby版本 还是之前的2.0.0版本???
$ sudo xcode-select --switch /Library/Developer/CommandLineTools/
Password:
$ git
usage: git [--version] [--help] [-C <path>] [-c name=value]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
Done.
==> /usr/bin/sudo /bin/rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
==> Installing the Command Line Tools (expect a GUI popup):
==> /usr/bin/sudo /usr/bin/xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
Failed during: /usr/bin/sudo /usr/bin/xcode-select --install
Requirements installation failed with status: 1.