cocoaPods 安装

gem install 时出现下列错误:

  1.  
    ERROR: While executing gem ... (Gem::FilePermissionError)
  2.  
    You don't have write permissions for the /usr/bin directory.

看到这个错误,很多时候都以为是权限不够导致的,其实 gem 的镜像问题也会导致这个错误。

解决:

最新镜像 https://gems.ruby-china.com/,点击可查看详细的文档

查看当前镜像终端命令,确保只有最新的这一个镜像:

  1.  
    gem sources -l
  2.  
    *** CURRENT SOURCES ***
  3.  
     
  4.  
    https://rubygems.org/
  1.  
    移除当前镜像:
  2.  
    gem sources -r https://rubygems.org/
  3.  
     
  4.  
    删除操作执行的结果:
  5.  
    https://rubygems.org/ removed from sources
  6.  
     
  7.  
    添加最新的镜像:
  8.  
    gem sources -a https://gems.ruby-china.com/
  9.  
     
  10.  
    执行的结果:
  11.  
    https://gems.ruby-china.com/ added to sources

如果切换了镜像还是不行的话,尝试使用以下方式安装:

  1.  
    使用下面语句安装出错:
  2.  
    gem install fir-cli 或者 sudo gem install fir-cli
  3.  
     
  4.  
    使用下面语句安装成功:
  5.  
    sudo gem install -n /usr/local/bin fir-cli
  6.  
     
  7.  
    这句话的作用是:
  8.  
    安装fir-cli这个命令工具到bin目录下
  9.  
     
  10.  
    或者是 先给与bin目录读写权限:
  11.  
    sudo chmod -R 755 /usr/bin/
  12.  
    不行的话 用 sudo chmod -R 777 /usr/bin/
  13.  
     
  14.  
    权限 755 表示该文件所有者对该文件具有读、写、执行权限
  15.  
    权限 777 是可读可写可执行最大的权限

2018-05-07

拉取项目之后,使用 pod install 拉取第三方代码的时候出现下面错误

[!] The version of CocoaPods used to generate the lockfile (1.5.0) is higher than the version of the current executable (1.3.1). Incompatibility issues may arise.

更新cocoaPods,终端输入:sudo gem install cocoapods

之后,又出现了下面的错误:

  1.  
    ERROR: While executing gem ... (Gem::FilePermissionError)
  2.  
    You don't have write permissions for the /usr/bin directory.

终端输入:sudo gem install -n /usr/local/bin cocoapods

输入密码,执行结果如下图:

这次终于解决了,再次在终端输入pod install 时,出现了下图结果,说明cocoaPods可以正常使用了:

posted @ 2020-12-08 08:49  第三维  阅读(435)  评论(0编辑  收藏  举报