I'm looking for a way to have multiple versions of protoc available on my Mac (Sierra).
On Windows I have my .exe files on the path whereas the filenames contain the version.
On Mac I found (with brew) versions 2.5, 2.6 and 3.1. If I want to have both 2.5 and 2.6 available how would I achieve that?
Thanks
You can install all of them with:
brew install protobuf#2.5 protobuf#2.6 protobuf#3.1
Add protobuf to the list to get the latest version (3.4.1 at the time of this writing).
However formulae with specific versions (those that end with #<version>) aren’t symlinked in standard locations so you’ll need to use their specific prefix to use them, e.g.:
$ `brew --prefix protobuf#2.5`/bin/protoc ...
$ `brew --prefix protobuf#2.6`/bin/protoc ...
$ `brew --prefix protobuf#3.1`/bin/protoc ...
You could also use aliases:
$ alias protoc25="$(brew --prefix protobuf#2.5)/bin/protoc"
$ protoc25 ...
Homebrew does so not to get conflicts between installed versions. The non-fixed formula is correctly symlinked in /usr/local/bin or similar so it works unprefixed:
$ protoc ...
If you use a program that relies on protoc but don’t want to modify it to use a specific version you can add the relevant path to your PATH to ensure it uses it:
$ PATH="$(brew --prefix protobuf#2.5)/bin:$PATH"
$ protoc ... # protoc 2.5
Related
I tried using
brew install yarn#1.7.0 --without-node
or
brew install yarn#1.7.x --without-node
But I get the following error
Error: No available formula with the name "yarn#1.7.0"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
I presume its possible to install different versions of yarn using brew ?
I had the same issue and wanted to install yarn via brew for various reasons. Honestly the only way is to use the actual link to the yarn.rb file in the Homebrew Repo for the version you want. The easiest way to find the .rb file through git is to check out the PRs in Git for yarn in the homebrew repo.
Before doing this though, run brew unlink yarn in order to allow an older version to be installed while keeping the newest version.
Then look up the PR of the version you want, here's a link to make your life easier.
Click the version you want and go to Files Changed tab. Click on View File button. Then click on Raw button and then copy the URL of this raw file
After you get that link, type in your terminal brew install [link] and you should be set
You can then use brew list --versions yarn to check your installed versions and brew switch to switch versions. You should have both the latest version you previously had installed and the version you just installed.
Some of the above answers don't seem to work anymore. Here is how I was able to install a specific version in April 2021:
brew unlink yarn#1.6.0 (If you already have a version installed)
brew extract --version 1.22.4 yarn homebrew/cask
brew install yarn#1.22.4
yarn -v
You can also use yvm, a yarn version manager instead of homebrew to install a specific or multiple versions of yarn
https://yvm.js.org/docs/overview
Enables easy switching between yarn versions, like nvm does for node
Hope this works for you guys.
To reinstall run below.
// Note:(updating homebrew) for Mac users.
brew install -g yarn
if yarn is still not found
brew reinstall yarn
As per official github page https://github.com/yarnpkg/yarn/issues/599 you should use "brew install -g yarn" to install yarn using brew.
PS: I've installed Xcode and gcc before running above command as i ran into few issues when executed above command.
You could also use yarn policies set-version <version>, but it has a caveat; it will "check in your Yarn release within your repository. Once you run it, your configuration will be updated in such a way that anyone running a Yarn command inside the project will always use the version you set - and this transparently."
You might not want to have the Yarn release in your repository.
Official doc
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
If I run some kind of rake command, I get this error message:
rake aborted!
dlopen(/Users/adam/.rvm/gems/ruby-1.9.3-p327/gems/rmagick-2.13.1/lib/RMagick2.bundle, 9): Library not loaded: /usr/local/lib/libfreetype.6.dylib
Referenced from: /usr/local/lib/libMagickCore-Q16.7.dylib
Reason: Incompatible library version: libMagickCore-Q16.7.dylib requires version 16.0.0 or later, but libfreetype.6.dylib provides version 13.0.0 - /Users/adam/.rvm/gems/ruby-1.9.3-p327/gems/rmagick-2.13.1/lib/RMagick2.bundle
...
I am running on RoR 3.2, OSX Lion.
Could anyone help me, please, how to fix this issue? I spent 2 days of googling, reading discussions, but unfortunately with zero success...
Thank you so much!
Using Homebrew I was able to solve it using the following commands:
brew uninstall freetype
brew update
brew install freetype
Update step might be unnecessary. The installation succeeded but with the following warning:
Warning: Could not link freetype. Unlinking...
So one final command:
brew link --overwrite freetype
I have an amazing how-to-install-rmagick that have been working beautifully for me, try to re-install ImageMagick following these steps:
yum install tcl-devel libpng-devel libjpeg-devel ghostscript-devel bzip2-devel freetype-devel libtiff-devel -y (I use CentOS, you can translate the commands to your distro)
Download ImageMagick. Write wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz and press Enter. ImageMagick.tar.gz is created in the current directory.
Unpack the ImageMagick archive. Write tar xczf ImageMagick.tar.gz and press Enter. A new directory, ImageMagick-version, where version is the ImageMagick version number, is created.
Switch to the ImageMagick directory. Write cd ImageMagick-version and press Enter.
Configure the ImageMagick build. Write ./configure --prefix=/usr/local --without-perl and press Enter.
Compile ImageMagick. Write make and press Enter. ImageMagick compiles. This step may take several minutes.
Install ImageMagick to your home directory. Write make install and press Enter.
Remove the installation files. Write rm -r ImageMagick.tar.gz and press Enter.
Add /usr/local/bin to your PATH.
Write echo export PATH="/usr/local/bin:$PATH" >> ~/.bash_profile and press Enter.
Reload your .bash_profile. Write source ~/.bash_profile and press Enter.
Install the RMagick gem.
Write export LD_LIBRARY_PATH=/usr/local/lib and press Enter.
Write export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/ and press Enter.
Install the RMagick gem in your Ruby on Rails application.
Tell me later how it goes.
I found the answer in another post:
Rails 3 - RMagick doesn't find libfreetype.6.dylib using Paperclip
I performed the search and found that there was an older version of libfreetype that was being referenced and newer versions hidden elsewhere. By copying/linking the newer versions into the appropriate directory (/usr/local/lib in my case) the problem was resolved.
Do you use something like Homebrew or MacPorts to manage external library dependencies?
Installing the imagemagick library from there and then install rmagick.
I have a few kegs of the same package in /usr/local/Cellar/libfoo like /usr/local/Cellar/libfoo/1.0.1, /usr/local/Cellar/libfoo/HEAD and /usr/local/Cellar/libfoo/mycopy
How can I brew link to a specific version?
This is probably the best way as of 11.1.2022:
To install a specific version, e.g. postgresql 9.5 you simply run:
$ brew install postgresql#9.5
To list the available versions run a search with #:
$ brew search postgresql#
==> Formulae
postgresql postgresql#11 postgresql#13 postgresql#9.5 qt-postgresql
postgresql#10 postgresql#12 postgresql#9.4 postgresql#9.6 postgrest
==> Casks
navicat-for-postgresql
DEPRECATED in Homebrew 2.6.0 (December 2020):
The usage info:
Usage: brew switch <formula> <version>
Example:
brew switch mysql 5.5.29
You can find the versions installed on your system with info.
brew info mysql
And to see the available versions to install, you can provide a dud version number, as brew will helpfully respond with the available version numbers:
brew switch mysql 0
Update (15.10.2014):
The brew versions command has been removed from brew, but, if you do wish to use this command first run brew tap homebrew/boneyard.
The recommended way to install an old version is to install from the homebrew/versions repo as follows:
$ brew tap homebrew/versions
$ brew install mysql55
For detailed info on all the ways to install an older version of a formula read this answer.
Sadly brew switch is deprecated in Homebrew 2.6.0 (December 2020)
$ brew switch
Error: Unknown command: switch
TLDR, to switch to package version 10:
brew unlink package
brew link package#10
To use another version of a package, for example node:
First, ensure that the specific version is installed using brew list. My package here is node (16) and node#14.
➜ ~ brew list
==> Formulae
node
node#14
➜ ~ node -v
v16.1.0
Unlink the current package: brew unlink node.
➜ ~ brew unlink node
Unlinking /usr/local/Cellar/node/16.1.0... 7 symlinks removed.
Link the correct version
➜ ~ brew link node#14
Linking /usr/local/Cellar/node#14/14.16.1_1... 3857 symlinks created.
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/usr/local/opt/node#14/bin:$PATH"' >> ~/.zshrc
➜ ~ node -v
v14.16.1
Homebrew removed brew switch subcommand in Homebrew 2.6.0. Get it back from here.
brew tap laggardkernel/tap
brew switch --help
name#version formula
There's mainly two ways to switch to an old version of an app.
If it's a bigger version change. Homebrew may have created a versioned package in the repo. Like go, go#1.10, they are two different formulae, installed into two different locations.
# install the old one
brew install go#1.10
# link the executable into /usr/local/bin, or /opt/homebrew/bin
brew link --overwrite --force go#1.10
brew switch
But not every package has a versioned variant. If you just upgraded to the new version and the old one is still in your system, skip step 1, 2.
In this situation, search in the homebrew-core repo and download the specific formula. e.g. mysql 8.0.23
Download the raw file, and install from it brew install /path/to/downloaded/mysql.rb.
Now both the latest and the old 8.0.23 (same formula mysql) exist, switch (link out) the old version with brew switch mysql 8.0.23
brew info mysql will list all the old version still exist.
Step 1, 2 could be replaced by brew extract, but that requires user maintain its own tap. I won't cover it here, just search it if you're interested.
If you have installed, for example, php 5.4 it could be switched in the following way to php 5.5:
$ php --version
PHP 5.4.32 (cli) (built: Aug 26 2014 15:14:01)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
$ brew unlink php54
$ brew switch php55 5.5.16
$ php --version
PHP 5.5.16 (cli) (built: Sep 9 2014 14:27:18)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
brew switch libfoo mycopy
You can use brew switch to switch between versions of the same package, if it's installed as versioned subdirectories under Cellar/<packagename>/
This will list versions installed ( for example I had Cellar/sdl2/2.0.3, I've compiled into Cellar/sdl2/2.0.4)
brew info sdl2
Then to switch between them
brew switch sdl2 2.0.4
brew info
Info now shows * next to the 2.0.4
To install under Cellar/<packagename>/<version> from source you can do for example
cd ~/somewhere/src/foo-2.0.4
./configure --prefix $(brew --Cellar)/foo/2.0.4
make
check where it gets installed with
make install -n
if all looks correct
make install
Then from cd $(brew --Cellar) do the switch between version.
I'm using brew version 0.9.5
In case brew switch produces an error (in this example trying to switch to node version 14):
> brew switch node 14
Error: Calling `brew switch` is disabled! Use `brew link` #-versioned formulae instead.
The correct way switching versions would be :
> brew link --overwrite node#14
if #simon's answer is not working in some of the mac's please follow the below process.
If you have already installed swiftgen using the following commands:
$ brew update
$ brew install swiftgen
then follow the steps below in order to run swiftgen with older version.
Step 1: brew uninstall swiftgen
Step 2: Navigate to: https://github.com/SwiftGen/SwiftGen/releases
and download the swiftgen with version: swiftgen-4.2.0.zip.
Unzip the package in any of the directories.
Step 3:
Execute the following in a terminal:
$ mkdir -p ~/dependencies/swiftgen
$ cp -R ~/<your_directory_name>/swiftgen-4.2.0/ ~/dependencies/swiftgen
$ cd /usr/local/bin
$ ln -s ~/dependencies/swiftgen/bin/swiftgen swiftgen
$ mkdir ~/Library/Application\ Support/SwiftGen
$ ln -s ~/dependencies/swiftgen/templates/ ~/Library/Application\ Support/SwiftGen/
$ swiftgen --version
You should get: SwiftGen v0.0 (Stencil v0.8.0, StencilSwiftKit v1.0.0, SwiftGenKit v1.0.1)
Is it possible to run in a verbose mode where it doesn't actually install the package, but just details from where and how it will be install the package?
You can run brew outdated to see a list of outdated packages that will be upgraded when running brew upgrade.
The closest you'll find is to show the dependencies of the package you're trying to install:
$ brew deps ruby
Will list the packages of ruby. You can then use:
$ brew list
to see which packages you have installed. From these two commands, you will be able to tell which packages will be installed by brew install ruby
I've used gentoo linux quite a bit in the past, and their portage system has a nice 'pretend' option for installing packages, the closest I've found for brew is:
brew list (package name)
brew list ruby gives me:
/usr/local/Cellar/ruby/1.9.2-p0/bin/tilt
/usr/local/Cellar/ruby/1.9.2-p0/bin/testrb
/usr/local/Cellar/ruby/1.9.2-p0/bin/ruby
/usr/local/Cellar/ruby/1.9.2-p0/bin/ri
/usr/local/Cellar/ruby/1.9.2-p0/bin/rdoc
/usr/local/Cellar/ruby/1.9.2-p0/bin/rake
/usr/local/Cellar/ruby/1.9.2-p0/bin/rackup
/usr/local/Cellar/ruby/1.9.2-p0/bin/irb
/usr/local/Cellar/ruby/1.9.2-p0/bin/gem
/usr/local/Cellar/ruby/1.9.2-p0/bin/erb
/usr/local/Cellar/ruby/1.9.2-p0/include/ruby-1.9.1/ (21 files)
/usr/local/Cellar/ruby/1.9.2-p0/lib/libruby.1.9.1.dylib
/usr/local/Cellar/ruby/1.9.2-p0/lib/ruby/ (998 files)
/usr/local/Cellar/ruby/1.9.2-p0/lib/ (3 other files)
/usr/local/Cellar/ruby/1.9.2-p0/share/man/ (5 files)
/usr/local/Cellar/ruby/1.9.2-p0/share/ri/ (9522 files)
But I'm guessing you're looking for more info than this?
The brew install --dry-run feature was recently added.
brew install --dry-run vim
==> Would install 1 formula:
vim
==> Would install 5 dependencies for vim:
lua berkeley-db perl libyaml ruby