I installed ImageMagick via Homebrew.
However, due to a bug I have with my current configuration, I need to adjust the compile flags for the formula and reinstall it.
How can I accomplish this?
Remove the existing version.
$ brew rm imagemagick
Edit the formula.
$ brew edit imagemagick
This will bring it up in an editor; make sure your $EDITOR variable is set to your preference (for me: TextMate)
Change it, save it, try re-installing it.
Because most installs use pouring/bottles to install a precompiled binary, you will likely see no change unless you "build from source":
$ brew reinstall --build-from-source [...]
You can use --formula /path/to/imagemagick.rb as an additional argument to the above command to ensure brew is installing the formula that was edited.
If you're comfortable with git, you may also want to make a branch first, and do your edits in a branch to guard against data loss.
The accepted answer was the first step, but more was needed for my formula edit to work in February 2023.
If you edit formula foo, but your change is ignored by brew reinstall --build-from-source foo then, add export HOMEBREW_NO_INSTALL_FROM_API=1 to your shell config. It makes Homebrew actually use your revised formula.
Details: Homebrew FAQ: Edit Formula
Also, if you want your revised formula to persist, then run brew pin foo
Details: Homebrew FAQ: Prevent Formula Update/Upgrade
Related
I recently replaced my Intel Macbook with an M2 Mac, using my Time Machine backup to initialize the hard drive. That, of course, dutifully copied all the Intel code.
I had brewed onto the old system. Today running brew upgrade gives me:
Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
brew bundle dump
So of course I ran brew bundle dump and that didn't give me any more direction. I'm ready to wipe the entire slate clean with something like rm -rf xxx and start over, but I feel like I should be choosy about xxx.
FWIW, brew --version returns:
Homebrew 3.6.5-10-gbde685a
Homebrew/homebrew-core (git revision d6fa8906828; last commit 2022-10-11
Homebrew/homebrew-cask (git revision 576798b72f; last commit 2022-10-12)
Any real help would be welcome (except "switch to macports").
It turns out that just running "brew bundle dump" is only the first step. Follow that wit "brew bundle install --file Brewfile", as explained very clearly in earthly.dev/blog/homebrew-on-m1
Don't rush to follow my advice, or accept my answer. Someone else may give you something better if you are patient...
You should be able to get a list of installed packages in the current setup then it'll be easier to install the same packages in the new one. Try this and see if it looks correct:
brew ls > ~/oldbrewpackages.txt
You need to find where your current casks and stuff are installed. Like this:
brew config
and look for HOMEBREW_PREFIX. Snuffle around in there and see if it looks like where all your packages are.
Next, I would look around for anything to do with homebrew in my login profiles, comment it out by putting a hash (#) at the start of the line, save the file and check you can still start a new Terminal without errors:
grep -i homebrew -/.*
Now, rather than removing all your homebrew stuff under HOMEBREW_PREFIX, I would try renaming it. You may need to turn off "System Integrity Protection" first.
Then if your homebrew stuff is under /opt/homebrew, you could do:
sudo mv /opt/homebrew /opt/homebrew.unused
Then you'll want to reboot.
Now you should be able to install a new homebrew without it detecting the old one... hopefully.
To install your previous packages in your new homebrew, you want:
brew install $(cat -/oldbrewpackages.txt)
If everything looks good and works well, make a backup and then type the command to delete your old stuff, and read it very carefully 3x before hitting Enter
sudo rm -rf /opt/homebrew.unused
I am a new mac user,
and I just installed HomeBrew to set up my computer for business use,
but every time I run a brew command,
brew update
is started automatically and takes a lot of time,
I have time to do what I want before it works!
please be indulgent with me and teach me a way to solve my problem
I want to clarify that I do not have a network problem because everything works correctly on this side.
Thank you.
Add the following config into your shell init files. (.bash_profile for Bash, .zshrc for ZSH)
export HOMEBREW_NO_AUTO_UPDATE=1
HOMEBREW_NO_AUTO_UPDATE: If set, Homebrew will not auto-update before running brew install, brew upgrade or brew tap.
I'm trying to enable copying to OSX's clipboard in vim and most resources I have found say that I need a version of vim with +clipboard. These resources also indicate that this should be as easy as running brew install vim, however, I am stuck with -clipboard even after updating. Any suggestions as to how to force this feature? Do I even need it to achieve the desired behavior?
a brew update brew install vim should give you vim with +clipboard.
However your path probably still points to the old vim. Try that:
alias vim="/usr/local/bin/vim"
probably this will also work: (Not anymore, see the Update)
brew install vim --with-override-system-vim
Addition: I recommend to install it with brew install vim --with-client-server so you will have +xterm_clipboard.
Alternativly you could install macvim which should have all these features already in:
brew install macvim --with-override-system-vim
Update
--with-override-system-vim was removed. The best solution in my opinion is to just add macvim in front of your PATH:
PATH="/Users/user/Applications/MacVim.app/Contents/MacOS/Vim:${PATH}"
export PATH
You can test if vim points to the right instance with which vim
I installed bash via brew to check out version 4. I would like to remove this. I cannot use my npm packages correctly and am at a standstill. Wondering how to remove an installation from homebrew?
Have you tried brew uninstall bash?
If that doesn't work for you, you could try removing the actual files, usually /usr/local/Cellar/bash/ and /usr/local/bin/bash. This should get you at least far enough to be using your old bash binaries, from where you could do any further cleanup.
I'm on OS X 10.7 with Vim 7.3.
I'd like to install the breakindent patch.
Here's a way to do it on Linux with apt-get:
Compiling VIM with breakindent patch.
How do I do this? I suppose it will involve building Vim via Homebrew (which is OK with me).
Use Mercurial to get the latest Vim source code:
$ hg clone https://vim.googlecode.com/hg/ vim
$ cd vim
Grab the patch.
Apply the patch as indicated in the linked thread:
$ patch -p1 < /path/to/breakindent.patch
Configure Vim with the options you need (python/ruby support, custom location, etc.):
$ ./configure --with-features=huge <other options>
Build and install:
$ sudo make && make install
I just modified the Homebrew formula for MacVim to optionally add that patch. If you want to try it out, you can download the formula at https://gist.github.com/4108848 and plunk it in /usr/local/Library/Formula; then install using brew install --with-breakindent-patch macvim.
(EDIT: I used to have a link to my GitHub fork of Homebrew here, but I've decided to delete that fork unless I actually submit anything to Homebrew. The old formula could optionally add a patch that's been added to the main Vim since then.)
As of June 25th 2014, VIM includes the breakindent patch by default – finally :-)
For more info, see https://retracile.net/blog/2014/07/18/18.00
If you're installing from Homebrew, use:
brew install macvim --with-features=huge --override-system-vim --HEAD