How to handle Homebrew formula dependencies after having installed an older version - boost

For various project-specific reasons, I have downgraded my boost (and boost-python) Homebrew installation to boost159 from boost (aka Boost 1.62.0 as of the writing of this question). The homebrew/versions/boost159 and boost-python159 formulas are keg-only and therefore I had to link them manually:
brew tap homebrew/versions
brew remove --force boost
brew remove --force boost-python
brew install boost159
brew link --force --overwrite boost159
brew install boost-python159
brew link --force --overwrite boost-python159
So far so good. But then, when I want to install some unrelated Homebrew formula that has a dependency on boost, Homebrew tries to brew install boost (Boost 1.62.0) and fails to link it:
[34m==>[0m [1mPouring boost-1.62.0.el_capitan.bottle.tar.gz[0m
[31mError:[0m The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink include/boost/accumulators/accumulators.hpp
Target /usr/local/include/boost/accumulators/accumulators.hpp
is a symlink belonging to boost159. You can unlink it:
brew unlink boost159
To force the link and overwrite all conflicting files:
brew link --overwrite boost
To list all files that would be deleted:
brew link --overwrite --dry-run boost
Possible conflicting files are:
/usr/local/include/boost/accumulators/accumulators.hpp -> /usr/local/Cellar/boost159/1.59.0/include/boost/accumulators/accumulators.hpp
[...]
Is there a way to make other formulas use boost159 instead of boost ? Please note that boost159 must be linked for other parts of the projects (not in my control) to work. That is, I can't leave it unlinked and set build variables instead.
PS. This is all taking place in a CI build actually, making the error much more disruptive.
References
Homebrew install specific version of formula?

Probably you just have to patch your local formulas. In my opinion the whole versions support in brew is an unholy hack and one of the reasons why I do not use brew for build time development dependencies.

Related

How do I install the latest developer package for wine with homebrew? (wine-3.0-rc2)

When I type in:
brew install wine
That should install Wine 2.0.3, right? (the latest release)
But I want to install a specific version of wine: wine 3.0 rc2
What would the command to do this be if I'm using homebrew? I've tried
brew install wine-devel
But it gives me this error:
Error: No available formula with the name "wine-devel"
Any help? Thanks!
Currently wine-devel has been moved to caskroom/versions. Therefore in order to install wine-devel you have to
Tap caskroom/versions, by running brew tap caskroom/versions
Update homebrew (...just to be sure) by running brew update
Finally install wine-devel by running brew install caskroom/versions/wine-devel
caskroom/versions was moved to homebrew/cask-versions.
The following will work:
brew tap homebrew/cask-versions
brew install homebrew/cask-versions/wine-devel
You will be asked for your password.
Then you should be able to start executables as follows:
wine /path/to/app.exe
I was trying to install wine-devel, but ran into a similar problem. It seems that the answers here may each have been relevant on a different year, as the casks have moved around back and forth. So here's the latest on the situation, and some info on how to handle it in future.
The official instructions (as of 4th April 2020) say to run brew cask install wine-stable. However, that leads to an error:
$ brew cask install wine-stable
Error: Cask wine-staging exists in multiple taps:
homebrew/cask-versions/wine-staging
caskroom/versions/wine-staging
This means that two potential casks were found, each with the same name, yet each on a different repository, and Homebrew was unsure which one to install.
Running this command gave me a clue about what was going on:
$ brew tap caskroom/versions
Error: caskroom/versions was moved. Tap homebrew/cask-versions instead.
So I learned that you can untap third-party repositories, and untapped the one that the message seemed to advise not to tap WINE casks from.
$ brew untap caskroom/versions
Untapping caskroom/versions...
Untapped 156 casks (463 files, 56.7MB).
$ brew cask install wine-stable
... Success!
To install the development version just pass --devel
brew install --devel wine

Directory not empty in installing OpenCV3 with Python3 bindings on macOS

I've been trying to upgrade my OpenCV2 to OpenCV3 on my macOS Sierra 10.12.5, using homebrew and also have its bindings for both Python2 and Python3.
Following the excellent guide at pyimagesearch, I got to run
brew install opencv3 --with-contrib --with-python3 --HEAD
(I first uninstalled OpenCV, just for clarity and to avoid any potential conflicts). Now, the guide explains that --with-contrib is downloading additional stuff, which is good to have; --with-python3 is downloading the bindings for Python3 (those for Python2 are automatically there); --HEAD is pulling the Github branch version rather than the tagged release, which is a workaround to a problem related to the QKIT Apple library.
My problem is I get a
Error: Directory not empty - (/usr/local/Cellar/numpy/1.13.1, /usr/local/Cellar/numpy/1.13.1.tmp)
A brew doctor tells me Numpy is not linked but I'm not exactly sure what'd be the best way to proceed here. Wouldn't want to break something.
At this point, I just tested installing just the bindings for Python2, as in
brew install opencv3 --with-contrib --HEAD
and this leads me to this other problem:
Error: No such file or directory - /private/tmp/opencv3-20170714-55298-snr5jb/3rdparty/ippicv/downloader.cmake,
which is solved with if I instead run
brew install opencv3 --with-contrib
This last one works, I got OpenCV3 for Python2. Apparently I don't have the HEAD issue.
Now though, I still want the bindings for Python3 as well and due to the Numpy error above I'm not sure how to proceed? It seems like it's trying to install Numpy as a dependency, which I have already.
brew install opencv3 --with-contrib --with-python3 --HEAD
Instead of :
brew install opencv3 --with-contrib --with-python3 --without-numpy
and See this :
http://www.pyimagesearch.com/2017/05/15/resolving-macos-opencv-homebrew-install-errors/

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.

Installing GLFW on OSX

I've been all over the internet and I simply cannot find a way to install GLFW for OSX and use it with Xcode. A lot of articles use cmake for this, which I tried to install but I still can't access it from the terminal.
I just need a simple step-by-step guide for installing it because I'm going to lose my mind.
Thanks
I use homebrew to install GLFW. Once brew has been configured, use the commands
brew tap homebrew/versions
brew install --build-bottle --static glfw2
If you are still running into trouble with this and want to use homebrew, change the install command to reflect the newer GLFW version (3 as of this writing)
brew tap homebrew/versions
brew install --build-bottle --static glfw3

Cannot install ruby-1.9.2 in Mac OSX 10.8.1 due to symlink error

First, I tried the common rvm install.
rvm install 1.9.2
However, the following error was shown:
The provided compiler '/usr/bin/gcc' is LLVM based, it is not yet fully supported by ruby and gems, please read `rvm requirements`.
Then I run
rvm requirements
and find these following part of output useful
Right now Ruby requires gcc to compile, but Xcode 4.2 and later no longer ship with gcc. Instead they ship with llvm-gcc (to which gcc is a symlink) and clang, neither of which are supported for building Ruby. Xcode 4.1 was the last version to ship gcc, which was /usr/bin/gcc-4.2.
Xcode 4.1 and earlier:
- Ruby will build fine.
Xcode 4.2 and later (including Command Line Tools for Xcode):
- If you have gcc-4.2 (and friends) from an earlier Xcode version, Ruby will build fine.
- If you don't have gcc-4.2, you have two options to get it:
* Install apple-gcc42 from Homebrew
* Install osx-gcc-installer
Homebrew:
If you are using Homebrew, you can install the apple-gcc42 and required libraries from homebrew/dupes:
brew update
brew tap homebrew/dupes
brew install autoconf automake apple-gcc42
rvm pkg install openssl
This can live side by side with an existing Xcode 4.2+ install or Command Line Tools for Xcode.
so I tried:
brew update
brew tap homebrew/dupes
brew install autoconf automake apple-gcc42
However, I got the following error
Warning: Could not link apple-gcc42. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link apple-gcc42'
==> Summary
/usr/local/Cellar/apple-gcc42/4.2.1-5666.3: 104 files, 75M, built in 23 seconds
kanitw:shell.venturelab.com kanitw$ brew link apple-gcc42
Linking /usr/local/Cellar/apple-gcc42/4.2.1-5666.3... Warning: Could not link apple-gcc42. Unlinking...
Error: Could not symlink file: /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/include/gcc
/usr/local/include is not writable. You should change its permissions.
What would be my best solution? I kinda remember from somewhere that I should not use sudo with brew since I will mess up the whole installation.
You can change /usr/local directory owner
sudo chown -R `whoami` /usr/local
But, if you have mysql installed, you mast fix its owner
sudo chown -R mysql:mysql /usr/local/mysql
You should run brew doctor and then change the permissions accordingly. There might be other issues.
Change the permissions of your /usr/local directory and try again.

Resources