如何在Travis CI中的MacOS中更改Homebrew的Ruby版本?
试图在before_install
运行如何在Travis CI中的MacOS中更改Homebrew的Ruby版本?
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install python3; fi
,我结束了
/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'.
您的选择似乎是要么使用
brew update
brew install whatever
或
HOMEBREW_NO_AUTO_UPDATE=1 brew install whatever
的在travis documentation的建议不要做brew update
如果它似乎不是ne当brew的ruby需求发生变化时,eded似乎给你带来了随机破坏的风险...
对于.NET Core项目:您可以避免在不使用Travis的默认.NET Core的情况下使用brew,而应使用Microsoft安装它。 NET核心sh脚本。我曾经有mono
和dotnet
版本定义集,我发现在切换到sh脚本后不需要。我可以通过删除这两个定义来修复Homebrew must be run under Ruby 2.3!
错误(虽然在安装.NET核心之前,我必须在Linux上更新libunwind8
)。
下面是完整的.travis.yaml,用于在osx和linux上运行.NET核心项目测试。
language: csharp
before_install:
- if [ "$OS" = "linux" ]; then sudo apt-get install libunwind8; fi
script:
- wget https://dot.net/v1/dotnet-install.sh && chmod +x dotnet-install.sh
- ./dotnet-install.sh --version 1.1.4 --install-dir $HOME/.dotnet
- $HOME/.dotnet/dotnet restore
- $HOME/.dotnet/dotnet test YOUR_CSPROJ_FILE_PATH
matrix:
include:
- os: linux
dist: trusty
env: OS=linux
- os: osx
osx_image: xcode9
env: OS=osx
branches:
only:
- master
我可以用--version 2.0.0来证实这一点,因为我的项目需要2.0 .NET Core SDK。感谢分享这个解决方案。 –
- 酿造更新
- 冲泡安装红宝石打造
- 酿造安装rbenv
- rbenv安装[version_required]
- rbenv全球[version_required]
我成功在macOS中更改Homebrew的Ruby版本,创建一个个人访问toke N于GitHub上,并设置它在我的Mac为:
https://github.com/settings/tokens/new?scopes=gist,public_repo&description=Homebrew
然后设置与令牌:
export HOMEBREW_GITHUB_API_TOKEN="your_new_token"
如果您已经拥有此令牌集,你可以这样清除它们:
printf "protocol=https\nhost=github.com\n" | git credential-osxkeychain erase
之前运行
我有一个类似的问题安装mutt。我正在阅读以下内容,不知道是否相关https://discuss.circleci.com/t/homebrew-must-be-run-under-ruby-2-3-runtimeerror/17232/6 –
看起来像你正在使用rvm来管理Ruby的版本。是对的吗? – zee