How to prevent Homebrew from installing a certain formula dependency? - homebrew

How to prevent Homebrew from installing a certain dependency formula when installing any future formulae? On my mac, python is provided by conda and I don't want duplicate pythons. Every time I install a python-dependent formula it gets automatically installed.

First, have a look the dependencies you need for the formula. (use brew deps --tree xpdf for a tree view)
brew deps -n formula
dep1
dep2
Then install the dependencies you want manually.
brew install dep1
And finally install the formula using --ignore-dependencies.
brew install --ignore-dependencies formula

#Pau's answer worked for me. One thing to add is that brew deps
will show all dependencies including optional and already installed ones so it made it hard for me when there were more than a dozen.
I ended up using brew info
brew info openjdk
#... basic info
==> Dependencies
Build: autoconf ✘, pkg-config ✔
Required: giflib ✔, harfbuzz ✔, jpeg-turbo ✔, libpng ✔, little-cms2 ✔
==> Requirements
Build: Xcode ✘
Required: macOS >= 10.15 ✔
#... more info
Then the key part of the answer that #Pau pointed out is to install with
brew install --ignore-dependencies openjdk

Related

Why is my `brew list` gets populated b unknown libraries and how do I get rid of them?

My mac is 1 month old, i've been installing all I can with brew and brew cask to keep things in order, to be able to uninstall unnecessary software completely. Brew cask list seems ok, only the libraries I have actually isntalled are listed. I've installed maybe ~10 libraries with brew install. Why is my list looks like this now??? How do I get rid of the unnecessary libraries without breaking stuff?
adns gettext lame libgpg-error libtiff mongodb-community openjpeg readline theora yarn
aom giflib leptonica libidn2 libunistring mongodb-community-shell openssl#1.1 ripgrep uchardet z
cairo glib libarchive libksba libusb mujs opus rtmpdump unbound zimg
flac gmp libass libogg libvidstab ncurses p11-kit rubberband vapoursynth zsh
fontconfig gnutls libassuan libpng libvorbis nettle pcre sdl2 webp zsh-completions
freetype graphite2 libbluray libsamplerate libvpx node pcre2 snappy x264 zsh-git-prompt
frei0r harfbuzz libevent libsndfile little-cms2 node#10 pinentry speex x265 zsh-syntax-highlighting
fribidi icu4c libffi libsoxr lua#5.1 npth pixman sqlite xvid
gdbm jpeg libgcrypt libtasn1 lzo opencore-amr python tesseract xz
Some formulae require, or depend on others. You can see which other formulae formula X depends on with:
brew deps X
You can see which other formulae need formula X with:
brew uses X --installed
You can see formulae which no-one depends on with:
brew leaves
In general, you can try removing any formula because it will not remove anything that is required by something else unless you use:
brew rm --ignore-dependencies ...

mariadb with rails: can't install libmysqlclient-dev

I have mariadb-10.1 installed on a stock 64bit Ubuntu 15:10.
I have libmysqlclient18 succesfully installed, but I get errors when trying to install libmysqlclient-dev.
steve#steve:~$ dpkg -s libmysqlclient18
Package: libmysqlclient18
Status: install ok installed
Priority: optional
Section: libs
Installed-Size: 10
Maintainer: MariaDB Developers <maria-developers#lists.launchpad.net>
Architecture: amd64
Source: mariadb-10.1
Version: 10.1.13+maria-1~wily
Replaces: libmysqlclient18 (<< 10.1.13+maria-1~wily)
Depends: libmariadbclient18 (= 10.1.13+maria-1~wily)
Description: Virtual package to satisfy external depends
This is an empty package that provides an updated "best" version of
libmysqlclient18 that does not conflict with the libmariadbclient18
package.
.
MariaDB is a fast, stable and true multi-user, multi-threaded SQL database
server. SQL (Structured Query Language) is the most popular database query
language in the world. The main goals of MariaDB are speed, robustness and
ease of use.
Homepage: http://mariadb.org/
steve#steve:~$ sudo apt-get install libmysqlclient-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies.
libmysqlclient-dev : Depends: libmysqlclient18 (= 5.6.28-0ubuntu0.15.10.1) but 10.1.13+maria-1~wily is to be installed
E: Unable to correct problems, you have held broken packages.
Can anyone suggest how to resolve this?
Thanks :-)
Steve
You have to install libmariadbclient-dev instead of libmysqlclient-dev when using MariaDB
sudo apt-get install libmariadbclient-dev
While installing libmariadbd-dev or libmariadbclient-dev package is the easiest way, in some OS's or package managers it is not available.
For example on a mac with homebrew this is not available, I found a workaround though.
To install gem mysql2 on a mac you need mariadb-connector-c in homebrew. This package conflicts with Mariadb symlinks so you need to do run the following in the terminal:
brew unlink mariadb
brew install mariadb-connector-c
Inside the rails project directory, execute:
bundle install (or gem install mysql2)
brew uninstall mariadb-connector-c
brew link mariadb

homebrew check binary package availability

Is there a brew command to check if the formula I want to install is available as binary or I have to install it from source.
As corollary, if I need to install a particular formula by recompiling it with brew install --build-from-source XXXX all the packages on which that particular formula depend will be rebuilt from source too?
Thanks
brew info <formula> will tell you if a given formula is bottled (= compiled) for your system, e.g.:
$ brew info postgresql | head -n 1
postgresql: stable 9.5.1 (bottled)
You can get more info by using --json=v1:
# bottled formula
$ brew info --json=v1 postgresql | jq '.[0].bottle'
{
"stable": {
"revision": 0,
...
}
}
# non-bottled formula
$ brew info --json=v1 docker-machine-nfs | jq '.[0].bottle'
{}
if I need to install a particular formula by recompiling it with brew install --build-from-source XXXX all the packages on which that particular formula depend will be rebuilt from source too?
Only the dependencies you don’t already have will be built from source.

How can I force homebrew to recompile?

I'm trying to install wxWidgets on Mac OS X 10.9. It's already installed, but I'm having the problem described here. Someone suggested to add ENV.append_to_cflags "-stdlib=libc++". I did, but I'm not able to recompile the code.
$ brew install wxmac
Warning: wxmac-3.0.0 already installed
$ brew edit wxmac
=> ok, modifications done, now I want to recompile and reinstall
$ brew uninstall wxmac
Uninstalling /usr/local/Cellar/wxmac/3.0.0...
$ brew install wxmac
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/wxmac- 3.0.0.mavericks.bottle.2.tar.gz
Already downloaded: /Library/Caches/Homebrew/wxmac-3.0.0.mavericks.bottle.2.tar.gz
==> Pouring wxmac-3.0.0.mavericks.bottle.2.tar.gz
🍺 /usr/local/Cellar/wxmac/3.0.0: 775 files, 41M
How can I force homebrew to recompile?
Homebrew is installing wxmac in bottle form (a pre-compiled binary of wxmac). To build from source, add the --build-from-source flag when calling brew install:
$ brew install --build-from-source wxmac
To rebuild all installed FORMULAE from source:
$ brew list | xargs brew reinstall --build-from-source

Homebrew: List only installed top level formulas

I'm looking for a way to show only the formulas I installed without the installed dependencies.
I want to have a list of all the programs I actually installed, without all noise of the dependencies.
I do know about brew list which lists all installed formulas.
I also know that brew graph gives me a dependency graph in the graphviz
Or in other words: I want to have the minimal set of formulas to reinstall my system.
Use brew leaves: show installed formulae that are not dependencies of another installed formula.
$ brew deps --installed
tmux: pkg-config libevent
q:
gdbm:
libxml2:
asciidoc: docbook
libevent:
pkg-config:
pcre:
docbook:
zsh: gdbm pcre
readline:
emacs: pkg-config
This seems to give us a list of all installed formulae including their dependencies. We can build a list of all formulae and a list of all dependencies and subtract the dependencies from the list of formulae, this should give us a list of formulae which are not dependencies of other formulae:
$ cat brew-root-formulae.sh
#!/bin/sh
brew deps --installed | \
awk -F'[: ]+' \
'{
packages[$1]++
for (i = 2; i <= NF; i++)
dependencies[$i]++
}
END {
for (package in packages)
if (!(package in dependencies))
print package
}'
.
$ ./brew-root-formulae.sh
zsh
asciidoc
libxml2
readline
tmux
q
emacs
Is this the output you are after?
The question is quite old, but actually only this answer resolves the issue. However, it's more like a workaround. But there's one more solution available out-of-the-box in brew:
brew bundle dump --file -
From docs:
brew bundle dump:
Write all installed casks/formulae/images/taps into a Brewfile in the
current directory.
and the flag:
--file
Read the Brewfile from this location.
Use --file=- to pipe to stdin/stdout.
As a result we get e.g.:
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-fonts"
tap "homebrew/core"
tap "homebrew/services"
tap "jesseduffield/lazydocker"
tap "jesseduffield/lazygit"
brew "lazydocker"
brew "lazygit"
cask "font-sauce-code-pro-nerd-font"
If you e.g. need a pure list of formulae and casks, without taps, you can just run:
brew bundle dump --file - | grep '^brew\|^cask' | sed 's/.* "\(.*\)".*$/\1/'
and get:
lazydocker
lazygit
font-sauce-code-pro-nerd-font
P.S. If you actually save the output to the file (with brew bundle dump or brew bundle dump --file PATH_TO_FILE), you can easily install all the dependencies from it with brew bundle install:
brew bundle [install]:
Install and upgrade (by default) all dependencies from the Brewfile.
You can specify the Brewfile location using --file or by setting the
HOMEBREW_BUNDLE_FILE environment variable.
this shows installed formulas as a tree.
brew deps --installed --tree
only show dependencies one level down
brew deps --1 --installed --tree
only show installed php formula
brew deps --installed --tree php
opens a website for visualization
brew deps --installed --graph php

Resources