Cannot avoid brew update

It seems impossible to prevent brew updating everything, with a disastrous consumption of credits. The documentation says it won’t update “by default”, but it does so, even when asked nicely not to.

The homebrew section is:

          update: false
            - homebrew/cask-versions # for openjdk
            - ant
            - openjdk@8

This may be new-ish behaviour. Or is it related to a change in the particular dependencies I need? I am running on Xcode11.6.

The build works, it just takes 19 minutes of which this is 17 I could do without:

Try adding:


On the Travis before_install hook.

Montana Mendy
Travis CI Staff

Thanks @Montana , but AFAICT the homebrew update goes off before it gets to that section. (I cancelled it at the 7 minute mark, but well after it was obviously doing the update.)

Or have I put it in the wrong place? Is the a global hook outside the OSX job scope? If Travis CI could put such a statement in the preamble to the homebrew add-on, it would conform again to its documentation.

Hey @jeff5,

It’s not as simple as removing the brew update command, in a lot of ways it’s because brew is so very helpful that it implicitly runs update on the next brew install. I’m going to try and reproduce the problem and get you a working .travis.yml example as soon as possible.

Try the following in the interim:


Montana Mendy
Travis CI Staff

Hi @Montana ,

You didn’t answer my concern:

So I tried that, but it didn’t make a difference, I think for that reason.

What does make a difference is to define those same things as environment variables using env: . That does in fact suppress the update.

Unfortunately, now it doesn’t find the package for Java 8. Perhaps there’s no alternative to the update after all.

I was able to skip (seemingly) brew update - I have a private repository, with some of the .travis.yml looking like this, this is a private project so I can’t post it in it’s entirety, I hope this gives you a starting foundation, your current .travis.yml is a bit messy.

dist: focal
language: java
  - brew cleanup -s
    - $HOME/Library/Caches/Homebrew
    - /usr/local/Homebrew
  provider: script
    all_branches: true
    condition: $TRAVIS_BRANCH =~ ^v?\d+\.\d+\.\d+$
  - USER=$(dirname $TRAVIS_REPO_SLUG)
  - PROJ=$(basename $TRAVIS_REPO_SLUG)

I think the problem you’re having was solved sometime in 2019, look here. I understood your concern, I was just trying another fix, I’ll fix up your .travis.yml tomorrow (if you can wait that long - and this isn’t pressing).

I recommend you looking at the foundation I provided from one of my private repos that work, and the link I provided.

Montana Mendy
Travis CI Staff

1 Like

@Montana : thanks for your persistence. No, not pressing – I’ll be on other work for a while, except for odd hours.

The messy .travis.yml is intended to launch 5 jobs across 3 OSes. It’s the result of much trial-and-error testing. I’m happy with the Linux and Windows jobs, and the “common part” is just a smoke test while I get the setup right.

A well-written alternative with the same intention would be interesting to read, but no hurry.

Hey @jeff5,

Great to hear, I’ll get on that as soon as possible for you.

@Montana the build seems broken though. I suspect that this Github repo is no longer up to date.

1 Like