由于Xcode12的推出,为了把Ci升级到最新版本,Ci机器Mac OS系统需要升级到最新的10.15.x,之前是10.14.x,两年多没升级了。苹果大爷在隐私和权限方面的控制已经接近疯狂,各种限制。10.15 比10.14又严格了很多。
以下我们列几点在升级遇到的问题,仅供参考~
1、无法检查到软件更新
10.14.5系统,在检查更新系统时可能会出现无法检查到10.15.x的系统,需要关闭代理或者断网重连下网络。
多试几次,系统升级大概需要40分钟左右。
2、升级Xcode12系统
在执行xcode-select --install的时候报出"不能安装该软件,因为当前无法从软件更新服务器获得"这样的错误。
命令行可能的报错信息
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
图形界面:
这个时候也不要慌,直接去developer.apple.com/download/mo… Line Tools,下载对应版本安装后就可以了
2、Ruby
报错信息
/Users/ci/Documents/iDroid/run.sh: /usr/local/bin/bundle: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory
由于10.14系统默认是Ruby v2.3,10.15系统默认是Ruby v2.6,导致找不到2.3的目录文件
解决命令:
sudo gem update --system
如果失败,报了权限问题换成
sudo gem update -n /usr/local/bin --system
重新安装ruby
brew reinstall ruby
3、Bundle
因为依赖问题,需要先卸载旧版本的Bundle,再安装,更新一下配置
#卸载
sudo gem uninstall bundler
#安装
sudo gem install bundler
4、Cocoapods
pod update 失败
这里还是之前旧版本依赖于Ruby 2.3的问题,cocopods的依赖库没有更新导致的。需要我们先卸载cocoapods,再安装
sudo gem uninstall cocoapods
sudo gem install cocoapods -n /usr/local/bin
5、Fastlane
#重新安装
brew reinstall fastlane
可能会报错,根据报错提示信息,覆盖之前的版本
brew link --overwrite fastlane
6、mysql2
安装mysql2稍微麻烦些
sudo gem install mysql2 -v 0.5.3 -- --with-mysql-config=/usr/local/Cellar/mysql/8.0.15/bin/mysql_config --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include --platform=ruby
安装完成后需要在加入环境变量官方文档链接
Add the path of the openssl lib dir to the $LIBRARY_PATH environement variable. You could do this by adding export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/ to your .bash_profile, .zshrc, etc. (If you used something other than homebrew to install openssl you'll need to replace /usr/local/opt/openssl/ with the path to where openssl is installed on your machine)
7、openssl@1.1
报错信息:
LoadError: dlopen(/Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle, 0x0009): dependent dylib '/usr/local/opt/openssl/lib/libssl.1.0.0.dylib' not found for '/usr/local/Cellar/mysql/8.0.12/lib/libmysqlclient.21.dylib' - /Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle
重新安装openssl@1.1
brew reinstall openssl@1.1
或者把旧的openssl 拷贝过去,以便能找到链接
原因:由于升级了最新的openssl@1.1后找不到libssl.1.0.0.dylib
解决方法:从别的目录下find / -name libssl.1.0.0.dylib 把找到的这个文件复制到/usr/local/opt/openssl/lib/这个目录下就可以了
#copy 之前先把权限设置下,否则会报错
sudo spctl --master-disable
8、启动后台服务
报错:
/Users/ci/Documents/iDroid/server
Traceback (most recent call last):
2: from app.rb:4:in `<main>'
1: from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- sinatra (LoadError)
解决办法:在后台服务目录下执行
#1、尝试
bundle install --path vendor/cache
#2、在1失败的情况下,再执行
sudo gem install sinatra-contrib -n /usr/local/bin
$ mkdir ~/data
2、查看刚刚创建的目录
//进入到~/data目录
$ cd ~/data
//查看目录路径,下面会用到
$ pwd
/Users/ci/data
3、指定MongoDB数据库路径
//这里的路径需要换成你自己电脑上面的路径
$ sudo mongod --dbpath=/Users/ci/data
这样就可以了,有的回答是需要先将我们电脑的安全模式关闭,再创建/data/db文件夹,然后再打开电脑的安全模式,这种方式太麻烦啦。
直接在我们的用户目录(也就是∼ \sim∼/)下面创建文件夹~/data作为默认数据库目录就可以∼ \sim∼
10、PHP服务无法访问
operation not permitted
解决办法
看到PHP服务访问权限问题, 一开始以为是PHP配置的问题,请了PHP大佬来帮忙查了好久,后来才知道原来不是PHP的问题,还是万恶的Mac OS权限问题。
这是因为一些mac用户在升级系统之后,电脑启用了SIP(System Integrity Protection),增加了rootless机制,导致即使在root权限下依然无法修改文件,在必要时候为了能够修改下面的文件,我们只能关闭该保护机制
1)重启,过程中按住 command+R,进入保护模式
2)打开terminal终端,输入
csrutil disable
11、Bundle env
报错信息:找不到对应xxx的插件问题
###### Jenkins 任务名称:iOS_EBusiness ######
/Library/Ruby/Site/2.6.0/bundler/spec_set.rb:86:in `block in materialize': Could not find CFPropertyList-3.0.2 in any of the sources (Bundler::GemNotFound)
from /Library/Ruby/Site/2.6.0/bundler/spec_set.rb:80:in `map!'
from /Library/Ruby/Site/2.6.0/bundler/spec_set.rb:80:in `materialize'
from /Library/Ruby/Site/2.6.0/bundler/definition.rb:170:in `specs'
from /Library/Ruby/Site/2.6.0/bundler/definition.rb:237:in `specs_for'
from /Library/Ruby/Site/2.6.0/bundler/definition.rb:226:in `requested_specs'
在对应工程目录下执行命令:
bundle install --path vendor/cache
bundler: failed to load command: fastlane (/Users/ci/.jenkins/workspace/iOS返还/vendor/cache/ruby/2.6.0/bin/fastlane)
Bundler::GemNotFound: You have requested:
cocoapods = 1.10
The bundle currently has cocoapods locked at 1.9.3.
Try running `bundle update cocoapods`
If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:290:in `block in verify_gemfile_dependencies_are_found!'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/resolver.rb:258:in `each'
有版本号冲突的问题,先删除工程目录下的 Gemfile 和 Gemfile.lock,再执行命令,最好不要用bundle install或者bundle update,大概率是无效的。