Homebrew / homebrew-bundle

📦 Bundler for non-Ruby dependencies from Homebrew, Homebrew Cask and the Mac App Store.
MIT License
5.29k stars 284 forks source link

brew bundle install not updating out of date casks #563

Closed Okeanos closed 4 years ago

Okeanos commented 4 years ago

I noticed recently that running brew update and brew bundle install will not update some casks, even though they are outdated.

Using the following Brewfile:

tap "adoptopenjdk/openjdk"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/core"
cask "adoptopenjdk/openjdk/adoptopenjdk11"
cask "adoptopenjdk/openjdk/adoptopenjdk8"

yields:

$ brew tap
adoptopenjdk/openjdk
homebrew/bundle
homebrew/cask
homebrew/core
$ brew update
Already up-to-date.
$ brew bundle install
Using homebrew/cask
Using adoptopenjdk/openjdk
Using adoptopenjdk/openjdk/adoptopenjdk8
Using adoptopenjdk/openjdk/adoptopenjdk11
Homebrew Bundle complete! 2 Brewfile dependencies now installed.

When trying to confirm the veracity of this, the following comes to light:

$ brew bundle check --verbose
The Brewfile's dependencies are satisfied.
$ brew cask outdated
adoptopenjdk11 (11,0.3:7) != 11.0.4,11
adoptopenjdk8 (8,212:b03) != 8,222:b10

Which is confirmed when inspecting the casks in question:

$ brew cask info adoptopenjdk/openjdk/adoptopenjdk8
adoptopenjdk8: 8,222:b10
https://adoptopenjdk.net/
/usr/local/Caskroom/adoptopenjdk8/8,212:b03 (97.7MB)
From: https://github.com/adoptopenjdk/homebrew-openjdk/blob/master/Casks/adoptopenjdk8.rb
==> Name
AdoptOpenJDK 8
==> Artifacts
OpenJDK8U-jdk_x64_mac_hotspot_8u222b10.pkg (Pkg)
$ brew cask info adoptopenjdk/openjdk/adoptopenjdk11
adoptopenjdk11: 11.0.4,11
https://adoptopenjdk.net/
/usr/local/Caskroom/adoptopenjdk11/11,0.3:7 (181.4MB)
From: https://github.com/adoptopenjdk/homebrew-openjdk/blob/master/Casks/adoptopenjdk11.rb
==> Name
AdoptOpenJDK 11
==> Artifacts
OpenJDK11U-jdk_x64_mac_hotspot_11.0.4_11.pkg (Pkg)

I would have thought that /lib/bundle/cask_installer.rb#L62 applied here and would have correctly identified the outdated casks as per brew cask outdated? Did I take a wrong turn somewhere?

MikeMcQuaid commented 4 years ago

Hmm, I cannot reproduce this behaviour locally; my 1password-cli was listed in brew cask outdated and I got Installing 1password-cli as expected. Can you figure out a minimal reproduction case i.e. commands I can run/edits I can make that mean you can reproduce it on any machine? Is it possible that those casks could have been updated between you running brew update and you running brew cask outdated?

Okeanos commented 4 years ago

Thanks for looking into this. I have had this issue with these casks in particular on two separate machines actually. Other casks update just fine (as far as I can tell), e.g. vagrant or virtualbox. Would this maybe have anything to do with the casks in question coming from a third party tap?

The commands listed in the initial report were all run within 5 Minutes (multiple times to validate that no updates were in fact applied) after I visited the AdoptOpenJDK/homebrew-openjdk repository and noticed that there were updated available but I hadn't received them.

MikeMcQuaid commented 4 years ago

Would this maybe have anything to do with the casks in question coming from a third party tap?

Yes, it could do. Could you try and create a minimally reproducible Brewfile based on that?

Okeanos commented 4 years ago

With the two casks installed previously in the outdated versions with brew cask:

adoptopenjdk11 (11,0.3:7)
adoptopenjdk8 (8,212:b03)

Using the following minimal new Brewfile:

tap "adoptopenjdk/openjdk"
cask "adoptopenjdk/openjdk/adoptopenjdk11"
cask "adoptopenjdk/openjdk/adoptopenjdk8"

has the following results:

$ brew tap
adoptopenjdk/openjdk
homebrew/bundle
homebrew/cask
homebrew/cask-drivers
homebrew/core
$ brew update
Updated 3 taps (homebrew/core, homebrew/cask and homebrew/bundle).
==> New Formulae
//...
==> Updated Formulae
//...
$ brew bundle
Using adoptopenjdk/openjdk
Using adoptopenjdk/openjdk/adoptopenjdk11
Using adoptopenjdk/openjdk/adoptopenjdk8
Homebrew Bundle complete! 3 Brewfile dependencies now installed.
$ brew bundle check --verbose
The Brewfile's dependencies are satisfied.
$ brew cask outdated
adoptopenjdk11 (11,0.3:7) != 11.0.4,11
adoptopenjdk8 (8,212:b03) != 8,222:b10
MikeMcQuaid commented 4 years ago

Can I see your brew bundle --verbose output?

Okeanos commented 4 years ago

Of course, here you go – still using the minimal Brewfile mentioned above.

$ brew bundle --verbose
Skipping install of adoptopenjdk/openjdk tap. It is already installed.
Using adoptopenjdk/openjdk
Using adoptopenjdk/openjdk/adoptopenjdk11
Using adoptopenjdk/openjdk/adoptopenjdk8

Also for good measure:

$ brew --version
Homebrew 2.1.11
Homebrew/homebrew-core (git revision 06579; last commit 2019-10-03)
Homebrew/homebrew-cask (git revision 0f7e78; last commit 2019-10-03)
Okeanos commented 4 years ago

Is there anything further I can help with? Either by providing additional information or by trying to debug "things" locally? I am by no means an expert in Ruby but I am not averse to getting my hands dirty to try and get this fixed :)

MikeMcQuaid commented 4 years ago

@Okeanos Sorry, I've been too busy to dive in here. You could play around with the cask*files in https://github.com/Homebrew/homebrew-bundle/blob/master/lib/bundle/ and that might help you towards a PR or figuring out what's wrong to make it easier for me to make one.

Blackjacx commented 4 years ago

I've the same issue... I have to dump a Brewfile, extract the casks and use then as input for brew cask upgrade. This works:

function brew-upgrade-all() {

  # update homebrew  
  brew update
  # create working dir
  temp=$(mktemp -d)
  brewfile="$temp/Brewfile"
  echo "Created temporary directory at $temp"
  # create a Brewfile of all installed formulas, casks, taps, mas
  brew bundle dump --describe --file="$brewfile"
  # upgrade all software from the created Brewfile
  brew bundle -v --file="$brewfile"
  # upgrade casks since the approach with the brewfile doesnt work
  brew cask upgrade $(sed -n -e '/^cask "/p' "$brewfile" |cut -d \" -f2)
  # cleanup old versions
  brew cleanup
  # check if the system is ready to brew
  brew doctor
}
Blackjacx commented 4 years ago

brew cask outdated is empty for me.

MikeMcQuaid commented 4 years ago

I've the same issue

Everyone who follows the reproduction instructions will have the same issue. That's why it's open.

You'll need to either wait for it to get fixed by someone (likely me) or try to work on a fix yourself.

Okeanos commented 4 years ago

I actually wanted to take a look at debugging/understanding and maybe fixing the issue but I am not too familiar with Ruby on its own and at the same time the repository doesn't appear to have development instructions (that I can see). So sorry for the lack of feedback there :/

MikeMcQuaid commented 4 years ago

brew cask outdated is empty for me.

@Blackjacx Then it's not the same bug and should be reported to Homebrew/cask.

MikeMcQuaid commented 4 years ago

@Okeanos I still can't reproduce this even by installing the exact casks/taps you've mentioned here. This may have been fixed by another change or it may be something specific about your machine.

If you manage to figure it out the places to look are https://github.com/Homebrew/homebrew-bundle/blob/c38345160e24b252afc1ca0a44daa3ff7dea0c89/lib/bundle/cask_installer.rb#L52-L65 and perhaps https://github.com/Homebrew/homebrew-bundle/blob/c38345160e24b252afc1ca0a44daa3ff7dea0c89/lib/bundle/cask_dumper.rb#L12-L23.

Sorry!

Okeanos commented 4 years ago

@MikeMcQuaid No worries, thanks for taking the time and dealing with my reports! I'll keep this in mind and will update if anything changes.

Blackjacx commented 4 years ago

By the way, in my case brew update-reset && brew update before brew bundle install helped!