试着跑
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install python3; fi
在 before_install
,我最终得到了
/usr/local/Homebrew/Library/Homebrew/brew.rb:12:in \`<main>': Homebrew must be run under Ruby 2.3! (RuntimeError)
The command "if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install python3; fi" failed and exited with 1 during .
Your build has been stopped.
/Users/travis/.travis/job_stages: line 166: shell_session_update: command not found
所以我假设这里的问题是 ruby
是2.0版,我用 ruby --version
确认了 . 有趣的是,我的构建突然停止工作,没有任何改变.travis.yml .
那么我该如何实际更改Ruby版本呢?
可能重要的是,在 git clone
运行之前,我得到这个:
$ rvm use
Warning! PATH is not properly set up, '/Users/travis/.rvm/gems/ruby-2.0.0-p648/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.0.0-p648'.
5 回答
brew更新
brew install ruby-build
brew安装rbenv
rbenv install [version_required]
rbenv global [version_required]
您的选择似乎要么使用
要么
travis documentation中的建议不要
brew update
如果它没有't seem to be needed seems to leave you at risk of random breakage when brew'的ruby要求被改变了......对于.NET Core项目:您可以通过不使用Travis ' default .NET Core but installing it using the Microsoft'的.NET核心sh脚本来避免使用brew . 我以前设置了
mono
和dotnet
版本定义,切换到sh脚本后我发现这些定义是不需要的 . 通过删除这两个定义,我能够修复Homebrew must be run under Ruby 2.3!
错误(尽管我在进行.NET核心安装之前必须在Linux上更新libunwind8
) .这是在osx和linux上运行.NET核心项目测试的完整.travis.yaml .
我成功地在macOS中更改了Homebrew的Ruby版本,在GitHub上创建了一个个人访问令牌,并在我的Mac上将其设置为:
https://github.com/settings/tokens/new?scopes=gist,public_repo&description=Homebrew
然后设置令牌:
在
brew install package_name
之前运行brew update