Deleting usr/local/octave on Mac - macos

I have this folder on my Mac:
usr/loca/octave/3.8.0
It is taking up 2.3 gb. I don't really use octave anymore. Is there a safe way to delete this folder and save space? I ran brew uninstall octave, but that removed a different version of octave.

You should be able to delete anything in /usr/local (as it is specific to user), and run brew doctor to verify if the cleanup is complete.
Even you accidentally delete something undesired, you can always reinstall to get it back.

Related

How to start over with Homebrew?

I recently replaced my Intel Macbook with an M2 Mac, using my Time Machine backup to initialize the hard drive. That, of course, dutifully copied all the Intel code.
I had brewed onto the old system. Today running brew upgrade gives me:
Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
brew bundle dump
So of course I ran brew bundle dump and that didn't give me any more direction. I'm ready to wipe the entire slate clean with something like rm -rf xxx and start over, but I feel like I should be choosy about xxx.
FWIW, brew --version returns:
Homebrew 3.6.5-10-gbde685a
Homebrew/homebrew-core (git revision d6fa8906828; last commit 2022-10-11
Homebrew/homebrew-cask (git revision 576798b72f; last commit 2022-10-12)
Any real help would be welcome (except "switch to macports").
It turns out that just running "brew bundle dump" is only the first step. Follow that wit "brew bundle install --file Brewfile", as explained very clearly in earthly.dev/blog/homebrew-on-m1
Don't rush to follow my advice, or accept my answer. Someone else may give you something better if you are patient...
You should be able to get a list of installed packages in the current setup then it'll be easier to install the same packages in the new one. Try this and see if it looks correct:
brew ls > ~/oldbrewpackages.txt
You need to find where your current casks and stuff are installed. Like this:
brew config
and look for HOMEBREW_PREFIX. Snuffle around in there and see if it looks like where all your packages are.
Next, I would look around for anything to do with homebrew in my login profiles, comment it out by putting a hash (#) at the start of the line, save the file and check you can still start a new Terminal without errors:
grep -i homebrew -/.*
Now, rather than removing all your homebrew stuff under HOMEBREW_PREFIX, I would try renaming it. You may need to turn off "System Integrity Protection" first.
Then if your homebrew stuff is under /opt/homebrew, you could do:
sudo mv /opt/homebrew /opt/homebrew.unused
Then you'll want to reboot.
Now you should be able to install a new homebrew without it detecting the old one... hopefully.
To install your previous packages in your new homebrew, you want:
brew install $(cat -/oldbrewpackages.txt)
If everything looks good and works well, make a backup and then type the command to delete your old stuff, and read it very carefully 3x before hitting Enter
sudo rm -rf /opt/homebrew.unused

Why Homebrew didn't removed Python directory?

I ran brew uninstall python but there's still the directory /usr/local/lib/python2.7.
Why brew didn't removed it? Is it still used? Can I remove it manually?
The folder /usr/local/lib/python2.7 is a directory shared with the system and it isn't owned by Homebrew: as you might now usr/local/Cellar is the proper Homebrew folder (along with several other spurious folders for taps and Cask).
It mainly contains packages (installed using pip).
I wouldn't touch such folder, since it is shared with the Python installation provided by OS X (through XCode Command Line Tools): if for any reasons (but I don't think so since you uninstalled python through Homebrew) you still have pip installed I would recommend to uninstall such packages through pip itself if you want to cleanup some space.

Permission problems with /usr/local/bin and /usr/local/share

I'm using OS X Yosemite in a fresh MacBook. Just installed Homebrew and some essential packages, having moved to this new computer recently.
I noticed that once in a while I get linking errors when I install new brew packages. For some reason, the permissions of /usr/local/bin and /usr/local/share keeps changing back to root:wheel even after I did chmod andchgrp several times to make it FP:admin (FP being my username).
Take note, it fixes the permissions for a time, allowing me to install new brew packages, and changes back to root:wheel automatically at random (at least as per my observation).
Been trying to Google answer to no avail. Any thoughts at what might be wrong with my setup? Appreciate the insights. Thanks!
You using Sophos by chance?
Via https://apple.stackexchange.com/questions/178760/how-to-figure-out-what-is-causing-the-ownership-of-usr-local-to-change-from-my
"I had this exact same issue, and it turns out Sophos auto-update was to blame. I figured this out by running: sudo fs_usage | grep "usr/local"
Running an existing MBP, now on 10.10.5 and this is happening to me seemingly every time I sleep/wake. At least once daily. No clue what's causing this yet.
Claco's answer about Sopho's Anti Virus software led me to fix this problem on my machine. I recommend upgrading Sophos.
My machine is a new 2015 Mac Book Pro (OSX 10.10.5) with Sophos 9.2.8 installed on it at first. Every time I restarted and ran brew doctor I'd get the same warnings about permissions in /usr/local/bin, /usr/local/share, etc. -- even though I reset those permissions each time.
After upgrading to Sophos Anti Virus 9.4.1, setting the permissions again, and restarting, brew doctor finally returns Your system is ready to brew.

I have two folders containing the same files (e.g. glfw,php5*,wget). Should I delete the other (non-Homebrew)?

Initially, I'm looking for a way to get the phpMyAdmin mcrypt working, and since I'm using Homebrew phpMyAdmin, I figured I must do something with Homebrew again.
When I used brew doctor, it reported that I have config scripts in /usr/local/opt/php54/bin/php-config that can confuse software installed via Homebrew.
I deleted the entire php5* folders (It was such a dumb moment for a beginner like me), and brew doctor reported a clear.
My Homebrew folder resides in /usr/local/Cellar. So I have almost identical folders residing in: /usr/local/opt/ and /usr/local/Cellar/
I'm using the Cellar folder. Is it alright to delete all the files inside /usr/local/opt/? What preliminary actions should I do first to ensure no casualty?

OSX Homebrew error: uninitialized constant MACOS

I've searched around a bit and can't seem to find any record of anyone else with this problem.
Whenever I try to run
$ brew update
I am rewarded with
/usr/local/bin/brew:34: uninitialized constant MACOS (NameError)
This isn't my machine and I normally develop on Linux systems so this is all a bit odd to me.
Any help would be greatly appreciated! Please tell me if there is any additional info I should provide. Again, I'm not used to homebrew or OSX.
EDIT
at the request of JameA
xiao:~ patrick$ brew doctor
/usr/local/bin/brew:34: uninitialized constant MACOS (NameError)
xiao:~ patrick$ brew --config
/usr/local/bin/brew:34: uninitialized constant MACOS (NameError)
...Not sure I like this whole "here, use this macbook for the project, it works better" thing...
I'm pretty sure the root cause of this is a failed upgrade attempt to Homebrew 0.9.5 from a much earlier version. Basically, if you run brew update as opposed to sudo brew update a portion of files are updated, while others are not. Here's what worked for me:
Edit /usr/local/bin/brew (it's just a Ruby file, not a compiled binary, so any text editor will do). You'll find a block like:
if MACOS and MACOS_VERSION < 10.5
abort <<-EOABORT.undent
Homebrew requires Leopard or higher. For Tiger support, see:
https://github.com/mistydemeo/tigerbrew
EOABORT
end
Comment this out. Even if you don't know Ruby, you can probably intuit what this is doing—it's checking to see if you have a current version of OSX. Assuming that you do in fact have this version, this sanity check isn't necessary. Brew is still broken, but at least now it will load far enough to give error messages.
Run sudo brew update, spoiler alert: it fails, but this time with a meaningful error message:
$ brew update
error: Your local changes to the following files would be overwritten by merge:
[giant list of files here]
Well, today I learned that brew update is just a wrapper for git pull because anyone who has worked with git knows that error message. We can fix this too.
Switch into the homebrew git repository with cd /usr/local and give the command git reset --hard FETCH_HEAD.
This piece found here.
Give the command sudo brew update. Homebrew should now update successfully and work properly!
Once the system is working again, you can actually kind of see why an error like this would have occurred. For one, usr/local/bin/brew has been completely rewriten and isn't even Ruby anymore, and most of its configuration has been moved into /usr/local/Library/brew.rb which no longer uses the constants MACOS or MACOS_VERSION constants, as they have been replaced by the more object oriented OS.mac and MacOS.version.
The MACOS constant is set in globals.rb. It seems like you may have a borked installation of Homebrew.
Check the output of brew doctor for any suggestions.
If that doesn't help please update with the results of brew --config.
If all else fails you may want to try re-installing Homebrew.
UPDATE:
Since this was a previous user's machine make sure your user is the owner of /usr/local and everything within. Fix it with sudo chown -R $USER /usr/local.
I had a similar issue, when I Killed an install mid-way with Ctrl-D.
Post that whenever I tried installing anything it gave the following error
uninitialized constant Homebrew::CLI::Parser::ARGV_WITHOUT_MONKEY_PATCHING
As a fix, I went to the directory I had where homebrew was installed, and reset the HEAD.
cd /usr/local/Homebrew
git status
git checkout .
And then it started working magically.
I had a similar error with a "borked" installation of brew. I removed the small 5 line block of code in the /usr/local/bin/brew script starting with the MACOS line. That did the trick to allow me to uninstall and eventually reinstall it.
In addition to Matt Korostoff's answer.
On point 3 (resetting the repo), for recent version of Homebrew, the repo is no longer /usr/local, do cd "$(brew --repo)" instead.

Resources