Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save uyjulian/105397c59e95f79f488297bb08c39146 to your computer and use it in GitHub Desktop.
Save uyjulian/105397c59e95f79f488297bb08c39146 to your computer and use it in GitHub Desktop.

How to install Homebrew package manager on Steam Deck

(See also installing Distroboxm, which is included in SteamOS 3.5 and newer: https://distrobox.it/ )
(See also installing Nix package manager: https://determinate.systems/posts/nix-on-the-steam-deck )

You can install Homebrew (a package manager for macOS and Linux) without disabling the read-only partition with sudo steamos-readonly disable.
The package manager can be used alongside Flatpaks. Some software is only available on Flathub, and some software is only available on Homebrew.

  1. Switch to desktop mode (hold power button until a menu appears, then select "Switch to desktop mode")
  2. Click the logo at the bottom left, go to System, then go to Konsole
  3. Set a password (needed for sudo access):
    passwd
  4. Install Homebrew using the steps here: https://brew.sh/
    Don't install any additional libraries from pacman or brew yet. Also, do not append to .bash_profile yet, otherwise it will break Steam.
  5. Add to .bash_profile with a check to make sure it is running in Konsole:
    echo 'if [ $(basename $(printf "%s" "$(ps -p $(ps -p $$ -o ppid=) -o cmd=)" | cut --delimiter " " --fields 1)) = konsole ] ; then '$'\n''eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"'$'\n''fi'$'\n' >> ~/.bash_profile
  6. In Konsole's menu bar, go to Settings -> Manage Profile
  7. Press "New"
  8. Check "Default Profile"
  9. Set "Command" to /bin/bash -l (that is a lowercase l, not a number 1)
  10. Click OK twice
  11. Add brew environment to current context:
    eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
  12. Install glibc (the important thing is headers). This is needed in order to compile software.
    brew install glibc
  13. Install GCC:
    brew install gcc
@uyjulian
Copy link
Author

uyjulian commented Aug 3, 2022

Step 12, or removing the glibc dependency from the podman formula, should work around that issue.

@markstinson
Copy link

That worked. Skipping Step 12 (not installing glibc). podman is now installed. I'll have to circle back to checking on this brew-podman and distrobox.

When brew install podman one of the hangups was related to the qemu dep of gtk3. I was like, WTH ?!? no linux distro I'm aware of has a GUI library as dep for qemu -- but apparently brew does -- how very unnecessary. My baseline brew install is about 700MB with just mc installed. After podman nearly 4.8GB. It installs all of X11, wayland and metric ton of unnecessary garbage.

So I'm afraid if I pull down qemu.rb (and podman.rb) remove the depends_on gtk3, that when I brew install podman it will pull the distro qemu.rb (not my tailored qemu.rb without gtk3) and install the missing gtk3.

After my endevours for podman wrap up, I might put in a RFE to remove qemu.rb depends_on gtk3. That's like saying, if you need bash, you need to also install xterm, konsole, gnome-terminal, etc. The depends_on gtk3 should not be for basic qemu but separate installable qemu front-ends/utils.

worse case scenarios:

  • give up brew as it's being so excessive & unnecessarily wasteful.
  • install the Arch packages installed into an alternate path. (this will likely be my next test)
  • download/cache all the brew packages then manually install the absolutely necessary while removing all cruft -- then never updating my franken-brew.
  • figure something else out (as I don't really want to set up my compiler build-chain.)

Man, Open Source is a lot of work. ;-D

@samparhizkar
Copy link

samparhizkar commented Oct 7, 2022

@uyjulian Thanks alot for creating this guide. This works on Konsole. But I was looking to use npm, which I installed using brew. I just can't access it within vscode's internal terminal. What would be the workaround for that?

@markstinson
Copy link

markstinson commented Oct 7, 2022

@uyjulian Thanks alot for creating this guide. This works on Konsole. But I was looking to use npm, which I installed using brew. I just can't access it within vscode's internal terminal. What would be the workaround for that?

For my podman situation, https://github.com/89luca89/distrobox has an extras script to install https://github.com/mgoltzsche/podman-static as well. I no longer need neither rwfus or homebrew (though it still has its use-case). podman-static has all the deps compiled into it. Even though built for Apline Linux x64, it runs just fine on SteamOS (Arch).

Your situation is another use-case for the distrobox (and podman-static) on the Steam Deck -- you can have a container of ANY Linux distro to install anything you want, even having X11 support as well.

Alternatively, you might want to check out https://github.com/ValShaped/rwfus . It leverages the SteamOS built-in OverlayFS used by /etc but for managing both pacman content & /usr. Then you could install from the Arch Linux repos.

If neither distrobox/podman-static OR rwfus meets your use-case, you might investigate if someone has already made a nodejs-static (with appropriate npm) -- being a classic NIX static build (deps included), not a UX "static" concept -- to use the same way as podman-static. If it doesn't exist, you would have to build it yourself.

Cheers, M.

@iamWing
Copy link

iamWing commented Oct 30, 2022

I skipped step 12 on my deck and installed glibc & gcc via brew instead. Then installed podman by using brew install podman & brew install gpgme. Now I can use podman for development on my deck.

PS: Despite the podman brew formula requires gpgme as required dependency, podman cannot find the libgpgme.so.11 file if gpgme isn't installed directly by running brew install gpgme.

@ThomasEricB
Copy link

Did the steps as requested however, I can't manage to install GCC,

It says:

==> Pouring gcc--12.2.0.x86_64_linux.bottle.2.tar.gz
Warning: The post-install step did not complete successfully
You can try again using:
  brew postinstall gcc
==> Summary
🍺  /home/linuxbrew/.linuxbrew/Cellar/gcc/12.2.0: 1,623 files, 306.6MB
==> Running `brew cleanup gcc`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

Plus:

(127)(deck@steamdeck ~)$ brew config
HOMEBREW_VERSION: 3.6.17
ORIGIN: https://github.com/Homebrew/brew
HEAD: e76c55e18434c870cca1de7aadf9d5218271fe2d
Last commit: 7 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 3145eebc9d223953120e4acb2ff29a1e3da27866
Core tap last commit: 4 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: :0
HOMEBREW_EDITOR: vim
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.8 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8_1/bin/ruby
CPU: octa-core 64-bit zen
Clang: N/A
Git: 2.38.1 => /bin/git
Curl: 7.85.0 => /bin/curl
Kernel: Linux 5.13.0-valve36-1-neptune x86_64 GNU/Linux
OS: SteamOS Holo (Holo)
Host glibc: 2.36
/usr/bin/gcc: N/A
/usr/bin/ruby: N/A
glibc: N/A
gcc@11: N/A
gcc: 12.2.0
xorg: N/A
(deck@steamdeck ~)$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: No developer tools installed.
Install Clang or run `brew install gcc`.

Warning: You have uncommitted modifications to Homebrew/homebrew-core.
If this is a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be undone
should you later need to do so for some reason.
  cd /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core && git stash -u && git clean -d -f

Uncommitted files:
   M Formula/glibc.rb

Help?

@CykaDelik
Copy link

CykaDelik commented Jan 9, 2023

What does step 11. Add Brew Environment to Current Context mean?

Do I just run that eval command in Konsole?

EDIT: Also, could someone explain to me what went wrong here?

(deck@steamdeck ~)$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Checking for sudo access (which may request your password)...
==> This script will install:
/home/linuxbrew/.linuxbrew/bin/brew
/home/linuxbrew/.linuxbrew/share/doc/homebrew
/home/linuxbrew/.linuxbrew/share/man/man1/brew.1
/home/linuxbrew/.linuxbrew/share/zsh/site-functions/_brew
/home/linuxbrew/.linuxbrew/etc/bash_completion.d/brew
/home/linuxbrew/.linuxbrew/Homebrew

Press RETURN/ENTER to continue or any other key to abort:
[sudo] password for deck:
==> /usr/bin/sudo /bin/chown -R deck:deck /home/linuxbrew/.linuxbrew/Homebrew
==> Downloading and installing Homebrew...
remote: Enumerating objects: 73, done.
remote: Counting objects: 100% (43/43), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 73 (delta 27), reused 36 (delta 25), pack-reused 30
Unpacking objects: 100% (73/73), 99.47 KiB | 692.00 KiB/s, done.
From https://github.com/Homebrew/brew
a73e2c679..8be5846c5 master -> origin/master
HEAD is now at 8be5846c5 Merge pull request #14351 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-1.43.0
error: Not a valid ref: refs/remotes/origin/master
fatal: ambiguous argument 'refs/remotes/origin/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git [...] -- [...]'

@ByToxX
Copy link

ByToxX commented May 13, 2023

I made all of the steps and now Konsole does not opening up anymore...

EDIT: Turns out it was a mistake on my end. Ignore this comment. Homebrew keeps working as expected

@markstinson
Copy link

markstinson commented May 13, 2023

I made all of the steps and now Konsole does not opening up anymore...

You've a couple of options.

  1. Open up the Dolphin file manager and rename /home/linuxbrew to /home/linuxbrew.old. You'll likely need to open Dolphin as the root user/Admin. Then try your Konsole. You'd be moving your fresh linuxbrew out the way.

  2. You might try and install a terminal in the software Discovery app to start diving into via bash. IF a flathub terminal doesn't give you a working terminal, then it's likely the one of the following files is borked: /home/deck/{.bashrc,.bash_profile,.profile} OR their equivalent in /etc/ .

@ByToxX
Copy link

ByToxX commented May 13, 2023

I made all of the steps and now Konsole does not opening up anymore...

You've a couple of options.

  1. Open up the Dolphin file manager and rename /home/linuxbrew to /home/linuxbrew.old. You'll likely need to open Dolphin as the root user/Admin. Then try your Konsole. You'd be moving your fresh linuxbrew out the way.
  2. You might try and install a terminal in the software Discovery app to start di> > I made all of the steps and now Konsole does not opening up anymore...

You've a couple of options.

1. Open up the Dolphin file manager and rename `/home/linuxbrew` to `/home/linuxbrew.old`. You'll likely need to open Dolphin as the root user/Admin. Then try your Konsole. You'd be moving your fresh linuxbrew out the way.

2. You might try and install a [terminal](https://flathub.org/apps/search/terminal) in the software Discovery app to start diving into via bash. _IF_ a flathub terminal doesn't give you a working terminal, then it's likely the one of the following files is borked: `/home/deck/{.bashrc,.bash_profile,.profile}` OR their equivalent in /etc/ .

I've tried the first method and nothing. Konsole keeps closing out. As of the second solution, what do you mean by a: "working" terminal? Like, something like it doesn't recognize the: "brew" command? If you mean that then yes, the Terminal I downloaded from Discover doesn't recognize that command. And also, I tried to see what happens if I enter in the following path: "/home/deck/.local/share/konsole" and moving the: "Profile 1.profile" file to another location such as the Desktop, makes Konsole open without issue. What should I do?

EDIT: Nevermind. Was actually a mistake on my end. I've typed: "/bin/bash -1" instead of: "bin/bash -l". I will update the comment. Sorry for the misunderstanding.

@tony-sol
Copy link

@ThomasEricB sorry for necrobump, but have exactly the same issue
Did you solve the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment