我一直在尝试更新cocoapod。在这之间,我更新了Ruby和RVM。现在,当我在新的ios项目中尝试pod init
时,显示以下内容
Traceback (most recent call last):
2: from /usr/local/bin/pod:23:in `<main>'
1: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)
我检查了以下内容,
ruby --version
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
rvm list rubies
=* ruby-2.5.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
答案 0 :(得分:2)
请使用以下命令将cocoapods
安装到/usr/local/bin
中,而不要安装到/usr/bin
中:
sudo gem install -n /usr/local/bin cocoapods
您应该先删除cocoapods
,然后再重新安装:sudo gem uninstall cocoapods
答案 1 :(得分:2)
您可能会通过将cocoapods gem安装到当前RVM安装的Ruby中来解决此问题:
import pandas as pd
import ipaddress
import socket
import geocoder
import threading
import csv
list1= []
list2= []
list3= []
list4= []
def makeaddr(a,b,c,d):
return ipaddress.IPv4Address(bytes([a,b,c,d]))
def ip():
for x in range(256):
try:
a = makeaddr(0,0,0,x)
b = makeaddr(0,0,0,x)
b = str(b)
hostb = socket.gethostbyaddr(str(b))
hostname = hostb[0]
g = geocoder.ip(b)
g1 = g.latlng
g2 = g.city
list1.append(a)
list2.append(hostname)
list3.append(g1)
list4.append(g2)
except:
list1.append(a)
def ip1():
for x in range(256):
try:
a = makeaddr(0,0,x,255)
b = makeaddr(0,0,x,255)
b = str(b)
hostb = socket.gethostbyaddr(str(b))
hostname = hostb[0]
g = geocoder.ip(b)
g1 = g.latlng
g2 = g.city
list1.append(a)
list2.append(hostname)
list3.append(g1)
list4.append(g2)
except:
list1.append(a)
def ip2():
for x in range(256):
try:
a = makeaddr(0,x,255,255)
b = makeaddr(0,x,255,255)
b = str(b)
hostb = socket.gethostbyaddr(str(b))
hostname = hostb[0]
g = geocoder.ip(b)
g1 = g.latlng
g2 = g.city
list1.append(a)
list2.append(hostname)
list3.append(g1)
list4.append(g2)
except:
list1.append(a)
def ip3():
for x in range(256):
try:
a = makeaddr(x,255,255,255)
b = makeaddr(x,255,255,255)
b = str(b)
c = 'Host Not Found'
hostb = socket.gethostbyaddr(str(b))
hostname = hostb[0]
g = geocoder.ip(b)
g1 = g.latlng
g2 = g.city
list1.append(a)
list2.append(hostname)
list3.append(g1)
list4.append(g2)
except:
list1.append(a)
threads = []
t1 = threading.Thread(target=ip(),args=())
t2 = threading.Thread(target=ip1(),args=())
t3 = threading.Thread(target=ip2(),args=())
t4 = threading.Thread(target=ip3(),args=())
t1.start()
t2.start()
t3.start()
t4.start()
data = {'IP':list1,'L&L':list3,'City':list4,'DN':list2}
df = pd.DataFrame({key:pd.Series(value) for key, value in data.items() }) #using a dict
print(df)
df.to_csv('csv12345.csv', sep ='\t')
由于您正在使用RVM,因此无需使用gem install cocoapods
来安装或更改有关Ruby的任何命令。使用sudo
安装gems时,是将其安装到系统的Ruby安装中,而不是RVM Ruby中。这可能会导致RVM环境与系统Ruby之间的交互出现问题。
答案 2 :(得分:2)
我遇到了同样的错误。
但是卸载和sudo gem install -n /usr/local/bin cocoapods
对我不起作用。
所以我尝试了rvm list rubies
并发现警告:
Warning! PATH is not properly set up, '/Users/xxx/.rvm/gems/ruby-2.1.3/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.1.3'.
我不知道发生了什么,所以我关注了这个问题:Warning! PATH is not properly set up, usually this is caused by shell initialization files
我做了rvm reset
和rvm version
。警告消失了。
然后我运行sudo gem install -n /usr/local/bin cocoapods
这解决了我的问题。如果有人遇到类似情况,请将其张贴在这里。
答案 3 :(得分:0)
尝试
$ sudo gem install cocoapods
答案 4 :(得分:0)
如果您已经安装了 cocoapods 并且您最近删除或移动了当前文件夹,请再次尝试重新输入路径。也许终端不知道你在哪里了。这解决了我的问题。
答案 5 :(得分:0)
请使用以下命令将 cocoapods 安装到 /usr/local/bin 而不是 /usr/bin 中:
sudo gem uninstall cocoapods
sudo gem install -n /usr/local/bin cocoapods