How do I save and version brew packages? - macos

I am used to installing packages and libraries via tools like npm, pip, and gem. These tools allow me to track the installed packages in some form or another (package.json, requirements.txt, or a Gemfile). This can then be checked into a repo and versioned.
I have a dotfiles repo on Github that I like to use as way to version control my machine configuration and I was wondering if there was a way to version control installed brew packages? If so how is this done? Something like brew install --save is what I am hoping for. :)

You’re looking for Homebrew Bundle.
It lets you keep track of installed formulae (packages) in a Brewfile.
You can then dump all the installed formulae in it with brew bundle dump, install all formulae from a bundle with brew bundle, and remove all installed formulae that aren’t listed in the bundle with brew bundle cleanup.
The syntax is very similar to Bundler’s, so it’s easy to edit the file by yourself.
It support both local Brewfiles (e.g. one per project) and a global one (~/.Brewfile).
Install it with:
$ brew tap homebrew/bundle

Here is a simple way for any *nix based system:
#create list of installed packages
brew list | xargs -L1 > Brewfile
# install packages
cat Brewfile | xargs brew
This is not as sophisticated as Homebrew bundle but it does the job if you're in a hurry.

Related

Assign dependencies python version while brew installing

New for homebrew
Now want to install autojump via brew install autojump, which need to install python#3.9 as denpendency. I already have python#3.8 installed via brew and don't want an another version.
python#3.8 also satisfy autojump from it's homgpage
Impossible, that's not how Homebrew works.
Installing autojump with homebrew is basically
Creating a virtual environment with Python#3.9 (Homebrew always chooses the latest Python)
Install autojump package in that environment.
Unless you modify the autojump homebrew formula, You can't reuse python#3.8.
You can try the following
brew install autojump --ignore-dependencies

Homebrew: Install through a config file similar to pip's requirements.txt?

As title, with Python's pip, you could do:
pip install -r requirements.txt
to batch install packages with specified versions.
Does Homebrew have the same system?
I quickly browsed brew's man page and couldn't find obvious switches.
Homebrew Bundle is the preferred way.
brew bundle dump
brew bundle
Yes, there is.
For example you can update brew.txt whatever you want.
brew list > brew.txt
<brew.txt xargs brew install
For specific versions
node 5.5.0
node4-lts 4.3.1

How to link brew-cask make to brew cmake

I did brew cask install cmake, but when I was about to brew install something, brew wants to install cmake.
How can I let brew know that there's already cmake available?
You can’t. Homebrew and Homebrew Cask are separate projects that install things in different ways. Homebrew assumes you don’t have cmake if it’s not installed through Homebrew so it’ll refuse to install even if a cmake binary exists in the PATH. It has no way to ensure this cmake binary is indeed the cmake it’s looking for.
A hacky way would be to edit the formula you want to install (brew edit <formula>); remove the line with depends_on "cmake" => :build; install it (brew install <formula>); then add the line back again.

How to install ImageMagick in Mac for simple task (R)

I have a simple task I want to carry out and after exhausting all resources on google I'm stumped. I think whats hindering me most is installing ImageMagick. When I used my terminal I get errors. All I want to do is make some plots on R and make a GIF out of them. Is there anyone way to confirm ImageMagick is installed?
In general you will need either MacPorts or Homebrew installed first to install ImageMagick. As you stated above it sounds like you don't have Macports installed.
If you don't have either installed, I'm a big fan of homebrew, and so I'll walk your through install with homebrew.
Step 1. First install homebrew:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
as per the homebrew website here.
Once that's done installing you'll then be able to use commands like brew install foo where foo is something you'd like to install. In your example you see port install imagemagick which is the Macports way of installing image magick.
Step 2. Install imagemagick. As per ImageMagick Mountain Lion instructions here:
brew install imagemagick
That command should install imagemagick. A super handy tool with homebrew is brew doctor which analyses all the installs you've done with homebrew to make sure they'll properly setup.

Homebrew (Mac): cannot install libksba or dependency libgpg-error

I'm setting up a new Mac for development with Ruby on Rails. I have installed XCode (including command line tools), Homebrew, and RVM properly. However, when I try to install the 2.0.0 Ruby version via RVM, I keep having to install libksba, which tries to install the dependency libgpg-error. The log tells me it's downloading the file, but it never does anything. I've let it run for 30 minutes before and still doesn't do anything. The file is supposed to be a few hundred KB, so it's not very large...Below is the code I'm running:
$ brew install libksba
==> Installing libksba dependency: libgpg-error
==> Downloading ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.11.tar.bz
This will just sit there and do nothing. Is there another repository where I can download the file from and manually install it? It's frustrating to not be able to develop because of simple dependency errors. Any suggestions would be greatly appreciated.
These are the formulas associated with libksba and libpgp-error: Homebrew Libksba Formula and Homebrew Libgpg-Error. Try first updating Homebrew, since the discrepancy between the version shown in your logs and the one in the repo tells me is outdated:
brew update
brew install libksba
If that doenst work, then you can download it from here:
url 'ftp://ftp.gnupg.org/gcrypt/libksba/libksba-1.3.0.tar.bz2'
url 'ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.11.tar.bz2'
mirror 'http://www.mirrorservice.org/sites/ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.11.tar.gz'
So I found out the problem; my network is running through a 2nd router that was blocking FTP. I skipped the 2nd router and connected to the primary router and brew install libksba worked just fine. Credit goes to fmendez who provided a mirror link that led me to check out the router ports for FTP.
For others coming to this question, the above instructions do work for manually downloading and installing the formulas. I also recommend checking out Homebrew Tips n Tricks for additional help on which commands to run.
You can try the following steps ( Ref from here )
cd /usr/local/src
curl -O ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.9.tar.gz
tar -xvf libgpg-error-1.9.tar.gz
cd libgpg-error-1.9/
./configure
make
make install
cd ..
curl -O ftp://ftp.gnupg.org/gcrypt/libksba/libksba-1.2.0.tar.bz2
tar -xvf libksba-1.2.0.tar.bz2
cd libksba-1.2.0/
./configure
make
make install

Resources