Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

brew upgrade for HEAD formulas fails with error: already installed #13197

Closed
jasonblewis opened this issue Jul 4, 2012 · 20 comments
Closed

brew upgrade for HEAD formulas fails with error: already installed #13197

jasonblewis opened this issue Jul 4, 2012 · 20 comments

Comments

@jasonblewis
Copy link

brew upgrade formula on a formula that was initially installed with the --HEAD option fails with:

Error: formula-HEAD already installed

There is no clear way to upgrade a formula installed with --HEAD other than uninstalling and re-installing. Example:

jason@woodhouse:/usr/local/Library/Formula$ brew install --HEAD wol
==> Cloning https://github.com/kylef/wol.git
Cloning into /Users/jason/Library/Caches/Homebrew/wol--git...
remote: Counting objects: 13, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 13 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (13/13), done.
==> make
/usr/local/Cellar/wol/HEAD: 4 files, 24K, built in 16 seconds
jason@woodhouse:/usr/local/Library/Formula$ brew upgrade wol
Error: wol-HEAD already installed
jason@woodhouse:/usr/local/Library/Formula$ brew upgrade --HEAD wol
Error: wol-HEAD already installed
jason@woodhouse:/usr/local/Library/Formula$

Max Howell suggested that this should either be fixed or the error message improved and requested I open this ticket.

@mistydemeo
Copy link
Member

The error has changed since specs landed, but it's actually odder now:

wget: stable 1.14, HEAD
http://www.gnu.org/software/wget/
/usr/local/Cellar/wget/HEAD (46 files, 2.1M) *

But:

brew upgrade wget
Error: wget-1.14 already installed

Which of course it isn't.

Ping @jacknagel

@jacknagel
Copy link
Contributor

You can't upgrade a HEAD installation; it takes precedence over the stable version.

This error is generated in formula_installer.rb.

@jacknagel
Copy link
Contributor

(But the error is misleading now that all specs are on a level playing field, yes.)

@jacknagel
Copy link
Contributor

The issue with the error is that Formula#version is called, but the stable spec is active because --HEAD was not passed. I'm a little confused why this used to return HEAD in the first place without passing --HEAD, but I'm sure I'm missing something.

The correct way to get the installed version would be something like f.linked_keg.version, which doesn't exist in core yet, but does in my versions overhaul.

@jacknagel
Copy link
Contributor

I have a fix for the error message at the tip of my specs branch: https://github.com/jacknagel/homebrew/tree/specs

It depends on the other work in that branch.

It doesn't address the original issue here, but at least the weirdness that Misty reported should be resolved.

@ghost ghost assigned jacknagel Aug 18, 2012
@jacknagel
Copy link
Contributor

Working my way towards a resolution on this one; (hopefully) fixed a couple other bugs in upgrade.

@pepijndevos
Copy link
Contributor

Any news on this? There is still no good way to update --HEAD builds.

@zen0wu
Copy link

zen0wu commented May 24, 2013

Any progress? It's kind of surprising that homebrew cannot upgrade HEAD formula

@MikeMcQuaid
Copy link
Member

We'll tell you when there's any progress here. We'd welcome patches from anyone else who wants to try though.

@mblair
Copy link
Contributor

mblair commented Jun 3, 2013

In the meantime, to upgrade a HEAD formula, just brew reinstall --HEAD [formula].

@sjackman
Copy link
Member

As a workaround hack, could brew upgrade --HEAD formula be a synonym for brew reinstall --HEAD formula?

@FlorianFranzen
Copy link
Contributor

Are you planing to give brew the ability to mark --HEAD versions outdated if there are new versions in the repository the code came from?

@samueljohn
Copy link
Contributor

@FloFra not planned as far as I know, because we would need to record the "normal" version that was present when a --HEAD is installed. Not sure what is the best idea here. Probably installing --HEAD versions means you'll have to take care of when you update yourself.
But I see your point that a notice when a HEAD version formula gets a regular version update.

@FlorianFranzen
Copy link
Contributor

@samueljohn That is not what I meant. I want a way to not only update specific head formulas, I also want to be able to easily check if there is a new head version available (so if a head version can be updated).

@mblair
Copy link
Contributor

mblair commented Jul 15, 2013

@FloFra Here's my solution:

I keep a local directory called ~/rebuild_src/ that contains clones of every project I run from HEAD (Ruby, oh-my-zsh, Go, Emacs and MacVim at the moment). I've got an update script that I run every morning that basically does a git fetch; git diff --exit-code master origin/master (or the equivalent, depending on the upstream project's default branch and VCS). When there's a diff, it merges the changes and calls brew reinstall --HEAD [formula] (or rbenv install --force 2.1.0-dev, or whatever).

I'm not convinced it'd be useful for Homebrew to do all of this for us.

@sjackman
Copy link
Member

If the version number of the installed formula were the git hash rather than simply HEAD, it shouldn't be too difficult for Homebrew to do upgrade HEAD formulae.

@jacknagel
Copy link
Contributor

If the version number of the installed formula were the git hash rather than simply HEAD,

There are multiple problems with that, the biggest being that the hashes do not sort like regular version strings, and the second biggest being that not all HEAD builds are from git or even from a VCS.

I've considered something like HEAD-#{Time.now.to_i}, though that has its own set of problems.

I also want to be able to easily check if there is a new head version available (so if a head version can be updated).

We would have to query the remote to detect this. That means special code for every download strategy (all of the VCS strategies plus regular tarball downloads, because HEAD can point to anything), plus potential per-site code to handle edge cases. I don't think it's worth that much added complexity (not to mention how slow it would make brew outdated if we had to go over the network for every HEAD installation).

@FlorianFranzen
Copy link
Contributor

What if brew outdated just gets a --HEAD flag? This flag would then check for updates for head installs depending on download strategy (e.g. svn status -u git remote update; git status), similar to what @mblair suggested.

@jacknagel
Copy link
Contributor

The desire for this feature is known, but it requires nontrivial architectural changes to Homebrew, which is why it is not available at this time.

@jacknagel jacknagel removed their assignment Nov 27, 2014
@apjanke apjanke modified the milestone: Clear out Legacy May 3, 2016
@apjanke
Copy link
Contributor

apjanke commented May 3, 2016

Closing this out as not doable for the time being, but would welcome a PR over at homebrew/brew in the future.

@apjanke apjanke closed this as completed May 3, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests