149

Struggling to find good Homebrew documentation (or tutorial)...

In the mean time I need to reinstall ImageMagick that was installed with Homebrew (brew install imagemagick) and not sure if I should first brew uninstall imagemagick or go ahead and brew install imagemagick --disable-openmp --force over the existing installation?!?

what does --force actually do? is it effectively a uninstall followed by a new install with new parameters?

Meltemi
  • 6,807
  • 11
  • 30
  • 30

2 Answers2

147

Homebrew now has a brew reinstall command, added February 2013. It simply does an uninstall followed by an install.

Nelson
  • 2,519
  • 2
  • 20
  • 16
  • 9
    `brew reinstall` appears to be rather dangerous, since it currently does not preserve installed options. – Aron Ahmadia Dec 17 '13 at 02:42
  • 13
    I feel like it would generally be more useful to not preserve them. A package could break because of your install options, and ignoring those on reinstall could potentially fix an issue in some cases. – Nick McCurdy Jul 08 '14 at 07:40
  • 4
    can i do reinstall with options? – ryanwinchester Jun 16 '15 at 20:21
  • 17
    Both `brew reinstall` and `brew upgrade` now silently preserve previously specified options. **I vociferously hate this.** Ideally, `brew` would at least provide an option for disabling this dubious functionality. It doesn't. The only reproducible means of reinstalling packages is to manually uninstall and reinstall said packages. The Gentoo USE flag-style approach of persisting options to an editable file (e.g., `~/Library/Homebrew/options.conf`) would be vastly preferable. I always know _exactly_ what options I want, Homebrew. (But thanks for trying to help and failing.) – Cecil Curry Nov 24 '15 at 04:52
  • 12
    well I learned a new word today – cambunctious Mar 28 '18 at 23:53
  • When referring to options, is this the options (config files) for the packages, or for Homebrew??? Thanks – Jason Dec 29 '20 at 00:43
  • Looks like reinstall preserves options these days: https://github.com/Homebrew/brew/issues/5327#issuecomment-439495923 (though main formulae don't have options anymore :) ) – rogerdpack Feb 23 '22 at 19:45
  • @AronAhmadia It looks like it now preserves the installed options. I have just ran `brew reinstall` for `DBeaver` and my db connections were flawlessly preserved. – Pathros Apr 03 '22 at 19:30
126

The --force option for the install action just overwrites any existing files on disk if the packages you're trying to install already exist. It doesn't remove files from disk like the uninstall action does.

I'd do the brew uninstall imagemagick first before doing an install. With brew I find the simplest approach is often the best: I want to reinstall something then I should remove it first with uninstall and put it back with install. The homebrew sandboxing does a very good job of making for clean uninstalls from your system.

If you wanted to uninstall it by hand you'd just need to look in /usr/local/bin for any files that linke to ../Cellar/imagemagick and delete those symlinks. Then delete /usr/local/bin/imagemagick and it's gone. You may be left with some dependency packages that also need removal, but the core imagemagick package will have been deleted. To see what imagemagick depends on if you want to do further cleanup run:

$ brew info imagemagick
imagemagick 6.7.1-1
http://www.imagemagick.org
Depends on: jpeg, libtiff, little-cms, jasper
Not installed

Some tools will complain unless the ghostscript fonts are installed to:
  /usr/local/share/ghostscript/fonts

http://github.com/mxcl/homebrew/commits/master/Library/Formula/imagemagick.rb
Ian C.
  • 6,073
  • 3
  • 29
  • 29
  • I can't seem to rebuild (a full rebuild, from the source) a package, have had this trouble for as long as I can remember using brew: https://gist.github.com/hydrostarr/9766139 . What might I be doing wrong, if anything? – Johnny Utahh Mar 25 '14 at 16:52
  • This is very out of date. See the answer below from @Nelson. – Django Reinhardt Jan 21 '17 at 15:34
  • 1
    @DjangoReinhardt in spite of the appearance of `brew reinstall` I still think it's objectively better to `brew uninstall` and then `brew install` again. See discussion on @Nelson's answer for why. – Ian C. Jun 02 '17 at 20:20