Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is HomeBrew compatible with Debian GNU/Linux?

I have a BeagleBone Black board. The OS is Debian GNU/Linux version 9. Can you use HomeBrew to install Python? Or is HomeBrew only for Mac OS?

like image 787
Intrastellar Explorer Avatar asked Oct 14 '25 07:10

Intrastellar Explorer


1 Answers

Let's start with this last part of the question:

Or is HomeBrew only for Mac OS?

Stack Overflow's timestamp shows that this question was asked March 7, 2019. A short while before that, a reasonable answer to that would have been, “yes, Homebrew is intended for macOS, but Linuxbrew is a fork of Homebrew that does what the name implies: modifies Homebrew to work on Linux”.

However, on February 2, 2019 -- a little over a month before the question was asked -- Homebrew announced version 2.0.0. In the announcement on their blog, they opened with this sentence:

Today I’d like to announce Homebrew 2.0.0. The most significant changes since 1.9.0 are official support for Linux and Windows 10 (with Windows Subsystem for Linux), brew cleanup running automatically, no more options in Homebrew/homebrew-core, and removal of support for OS X Mountain Lion (10.8) and older.

and further explained:

Homebrew on Linux was previously called “Linuxbrew”. You can install it in your home directory, so it does not require sudo, and use it to install software that your host distribution’s package manager does not provide. Homebrew on Linux uses its own repository for formulae: Homebrew/linuxbrew-core

https://brew.sh/2019/02/02/homebrew-2.0.0/

Then, on February 20, 2019, the README.md file this message was added to the top of the README.md file at the root of the Linuxbrew github repository:

Linuxbrew has been merged into Homebrew

Linuxbrew/brew has been merged into Homebrew/brew! Existing installations of Linuxbrew will be automatically migrated to Homebrew. Linuxbrew/brew will no longer be updated. See the Homebrew documentation of Linuxbrew and the Homebrew 2.0.0 blog post.

https://github.com/Linuxbrew/brew/pull/942/files

So in short, yes. As of a short while before this question was posted, Homebrew officially supports Linux. Debian GNU/Linux version 9, the specific distribution mentioned in the question, is included in that. But before you could use it to to install python, you would most likely need to install Homebrew itself, as it isn't installed on a Debian system by default.

Debian 9 even includes a 'linuxbrew-wrapper' package, which would have been built well before linuxbrew was merged into homebrew.

https://packages.debian.org/stretch/linuxbrew-wrapper

Will it work well now, given the merge of linuxbrew back into homebrew? Well, I have an up-to-date Debian 9 VM in front of me, so let's give it a try:

$ sudo apt install linuxbrew-wrapper
[...]
The following additional packages will be installed:
  fonts-lato libruby2.3 rake ruby ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert ruby-test-unit
  ruby2.3 rubygems-integration zip
Suggested packages:
  ri ruby-dev bundler
The following NEW packages will be installed:
  fonts-lato libruby2.3 linuxbrew-wrapper rake ruby ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert
  ruby-test-unit ruby2.3 rubygems-integration zip
0 upgraded, 13 newly installed, 0 to remove and 0 not upgraded.
Need to get 6,447 kB of archives.
After this operation, 27.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
[...]
$ 

So is it installed now? Let's ask dpkg:

$ dpkg --status linuxbrew-wrapper
Package: linuxbrew-wrapper
Status: install ok installed
[...]
Description: Homebrew package manager for Linux
 Linuxbrew is a fork of Homebrew, the Mac OS package manager, for Linux.
[...]
 This package provides Linuxbrew install scripts instead of linuxbrew itself.
Homepage: http://linuxbrew.sh/

So it installed the package, but the package is a 'wrapper' with install scripts, and the package still has the old linuxbrew description. What happens if we try to run brew?

$ type brew
brew is /usr/bin/brew
$ brew

========================================================================
For the convenience of using linuxbrew it is recommended to update the
following environment variables after installing linuxbrew.

  PATH, MANPATH, INFOPATH 

Set HOMEBREW_BOTTLE_DOMAIN environment variable if you prefer some
homebrew mirror as your upstream.

(example: /usr/share/doc/linuxbrew-wrapper/examples/profile)
========================================================================
==> This script will install:
/home/parallels/.linuxbrew/bin/brew
/home/parallels/.linuxbrew/Library/...
/home/parallels/.linuxbrew/share/doc/homebrew
/home/parallels/.linuxbrew/share/man/man1/brew.1
/home/parallels/.linuxbrew/share/zsh/site-functions/_brew
/home/parallels/.linuxbrew/etc/bash_completion.d/brew
/home/parallels/.cache/Homebrew/

Press RETURN to continue or any other key to abort
==> Downloading and installing Linuxbrew...
[...]
==> Migrating from Linuxbrew/brew to Homebrew/brew
  Linuxbrew/brew has been merged into Homebrew/brew!
  Linuxbrew/brew will no longer be updated.
  Your git remote has been changed from
     https://github.com/Linuxbrew/brew
  to https://github.com/Homebrew/brew
  See the blog post at https://brew.sh/2019/02/02/homebrew-2.0.0/
Updating Homebrew...
[...]
==> Tapping homebrew/core
Cloning into '/home/parallels/.linuxbrew/Library/Taps/homebrew/homebrew-core'...
[...]
Warning: /home/parallels/.linuxbrew/bin is not in your PATH.
==> Installation successful!
==> Next steps
Install the Linuxbrew dependencies:

Debian, Ubuntu, etc.:
  `sudo apt-get install build-essential`

Fedora, Red Hat, CentOS, etc.:
  `sudo yum groupinstall 'Development Tools'`

See http://linuxbrew.sh/#dependencies for more information.

Add to your ~/.bash_profile by running
  echo 'export PATH="/home/parallels/.linuxbrew/bin:$PATH"' >>~/.bash_profile
  echo 'export MANPATH="/home/parallels/.linuxbrew/share/man:$MANPATH"' >>~/.bash_profile
  echo 'export INFOPATH="/home/parallels/.linuxbrew/share/info:$INFOPATH"' >>~/.bash_profile

We recommend you install GCC by running `brew install gcc`.
Run `brew help` to get started
Further documentation: https://git.io/brew-docs
==> Homebrew has enabled anonymous aggregate user behaviour analytics
Read the analytics documentation (and how to opt-out) here:
  https://git.io/brew-analytics
Homebrew 2.0.6
Homebrew/linuxbrew-core (git revision 69e4; last commit 2019-03-31)

Cool, it automatically updated itself to transition from Linuxbrew to Homebrew. Notably, it still uses the directory name ~/.linuxbrew to keep its files. All we need to do to complete in install is:

  • Install any apt dependencies mentioned in the install output. Homebrew builds things from source, and your Linux distribution can provide most of the development toolchain it wants.

  • Updating some 'path' environment variables. Homebrew is adding a new location on your filesystem for installed software, separate from places like /bin and /usr/bin since your OS package manager manages the contents of those directories. Adding Homebrew's install location to these paths allows Hombrew-installed software to be found.

  • brew install gcc. While they've requested most of the development toolchain be supplied by your OS, they've apparently decided it's important to ask you to install a brew-managed compiler. This makes some sense, since the compiler used by your machine to build other homebrew formulae would presumably be in sync with the compiler they're testing with when they publish those formulae.

The original question also asked:

Can you use HomeBrew to install Python?

Let's try it:

$ brew install python
==> Installing dependencies for python: patchelf, pkg-config, gdbm, openssl, gpatch, ncurses, readline, sqlite, xz, bzip2, libffi and zlib
[...]
==> Installing python
==> Downloading https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
[...]
==> Caveats
Python has been installed as
  /home/parallels/.linuxbrew/bin/python3
[...]
See: https://docs.brew.sh/Homebrew-and-Python
[...]
parallels@debian-gnu-linux-vm:~$

Looks like you can!

So, why would you want to bother with using Homebrew to install python when you can do it with apt? Well there's a whole discussion and debate around questions like that but here's the short answer...

The python installed by apt:

$ /usr/bin/python3 --version
Python 3.5.3

The python installed by homebrew:

$ ~/.linuxbrew/bin/python3 --version
Python 3.7.3

3.7.3 is the current python version at the time I'm writing this. Apt-managed packages update on a time scale of months or years. Homebrew-managed packages update on a time scale of days or hours.

Why do we see this dramatic difference between apt and homebrew? Think of homebrew as supplying a system layered on top of the one provided by apt. Lots of OS-level utilities are relying on the apt-managed python install, and the Debian team is being careful not to break them. But maybe you're working on something that needs new features that only the newest python releases have. That's the kind of problem Homebrew is aiming to solve.

like image 105
Charlie Avatar answered Oct 17 '25 18:10

Charlie