Installing MacOs brew without sudo

In trying to setup the proxmark3 environment I ran into a frustrating problem, it was setup to be installed with brew… oh no.

My current MacOs version is MacOs BigSur 11.1, so this works with that version, Intel anyway, I don’t have an Apple silicon machine to test with, but it could require some tweaks to work.

I have used brew before and I have always had issues with how it works and where it puts files, and the way that the brew developers were uploading analytics was kinda sneaky as in this post.

https://news.ycombinator.com/item?id=11566720

Yeah this is a while ago, but, how the dev team of brew, being open source and all appealing to developers and the open source community would be a little sneaky about this was not cool.  Not to drag on this topic, but I really don’t think brew needs sudo access to my whole computer, just last month I completly wiped and reinstalled MacOs (latest version too) to rid myself of all the development “junk” that I just allowed to be installed anywhere… yeah development software will turn your computer into a trash can of random files and junk eventually if you don’t carefully watch it.

According to brew itself it says it does not require sudo, but it STILL wants sudo access to install… meh.

https://superuser.com/questions/655113/understanding-homebrew-no-sudo-philosophy-and-questioning-faq

Anyway, being forced into a corner to install brew to install the proxmark3 development tools I decided I would play it safe, I created a new non-admin user account called “proxmark3” to play it safe, and installed brew on that account without sudo with the following script, I had to modify it slightly though which I will explain here.  Original is below.

https://gist.github.com/skyl/36563a5be809e54dc139

I have zipped it up and archived it incase it disappears or changes.  I haven’t tested all possible setups, so you might need to install XCode or other support files before this will work correctly too.

https://www.drassal.net/filestore/brew_without_sudo_20210205.zip

You will notice I blew away a couple if conditions, for some reason it was not detecting the macos version correctly so I just chose for it and deleted the if statements that checked for the macos version.  It will put the executeables under your hold folder in /home/proxmark3/usr, etc.  For some reason the create directory fails so just make them yourself if you get an error.

Also, with how I tweaked the script it defaults to /home/prosmark3 for the home directory, edit as necessary.  Set the execute permission using

mkdir /user/proxmark3/usr
mkdir /user/proxmark3/usr/local
chmod u+x install.rb
./install.rb

After installation is done run the following command to get everything up to date.  We also need to set the path.  Remember to either set the path each time you open a terminal and want to use brew things, or put it somewhere to auto execute each time terminal opens.  I couldn’t get .bash_profile to work for me.

PATH=”$PATH:/Users/proxmark3/usr/local/bin”
brew doctor

This will take a while to run, after it finishes enjoy running brew without sudo!!!

Back to playing with the proxmark3!

1 thought on “Installing MacOs brew without sudo”

Leave a Reply

Your email address will not be published. Required fields are marked *