How to revert Homebrew to a previous state after an update - homebrew

I installed an app, which triggered an update of Homebrew and apparently also of some apps. Now I am unable to get some apps running, for example MySQL.
Some apps complain about not finding libicuuc.70.dylib after icu4c71.1 has been apparently installed by the update cycle.
I would like to revert the whole Homebrew installation to the point before the update was triggered to get my apps running again and to find out what went wrong. I can rely on TimeMachine.
Which directories do I have to replace through a backup?
I have the following directories in /usr/local :
/usr/local/bin
/usr/local/Caskroom
/usr/local/Cellar
/usr/local/etc
/usr/local/Frameworks
/usr/local/Homebrew
/usr/local/include
/usr/local/lib
/usr/local/opt
/usr/local/remotedesktop
/usr/local/sbin
/usr/local/share
/usr/local/var

At the end I resorted to restoring the complete /usr/local directory from a Timemachine backup and got all homebrew installed applications running again.
I did the following:
delete the content in /usr/local.
enter Time Machine and go to a specific time in the past, where the system was still running
selected all the files and directories and restored them
The var directory gets generated automatically by the system, once it is deleted, but it there where no conflicts. At first I tried to restore with out deleting the content of /usr/local before restoring it, but I got an error and the restore did not complete. After deleting it before the restore everything went through.
I still do not know what broke my system and would like to know more about Homebrew. In the time I am using homebrew it changed a lot the way it works and consequently my experience and the unexpected results I get sometimes.

Related

Uninstalling Homebrew

I uninstalled Homebrew on my MAC, but got this message at the end:
The following possible Homebrew files were not deleted:
/opt/homebrew/SECURITY.md
/opt/homebrew/etc/
/opt/homebrew/share/
/opt/homebrew/var/
You may wish to remove them yourself.
I was able to remove the first item, but when I tried to remove the remaining three with "rmdir," I kept getting the "_____ is a directory" output. What am I missing?
Thanks.
Apparently, rmdir only works if the directory is empty, looking at this linux man page. You could try to remove them using rm -rf <path to folder> instead.
Maybe not an answer, but seems these folder are left on purpose. They are not part of the Homebrew package manager itself. But config, file, cache, etc content generated by brew-installed package.
Especially, make sure you have a backup of these settings before you remove it with rm -rf.

Is it possible to change the default app directory for home-brew casks to an external hard drive?

I am running out of space on my laptop, and I was wondering if it would be possible to change the default directory of installing casks on an external hard drive so that I can use the internal hard drive just for the OS and important files.
I guess you can overwrite the environment variable HOMEBREW_CASK_OPTS or you can use the --appdir=/my/path option. You can get more information with the command man brew-cask and there is a nice markdown documentation in the cask repository. Otherwise the executables can be found in the Applications folder.
EDIT:
Sometimes it helps to run a cleanup to delete the old versions:
brew cleanup
brew cask cleanup

Has /usr/local/Library/Contributions/ been deprecated?

For some time I've had a
/usr/local/Library/Contributions/
directory on my system and have been loading at least a brew_bash_completion.sh from it with
source $(brew --repository)/Library/Contributions/brew_bash_completion.sh
in my .bash_profile.
But suddenly I have no /usr/local/Library/Contributions/ directory at all!
Has this directory been moved or deprecated by Homebrew? What is the current best way to get support for brew bash completion?
The Homebrew completion script is at /usr/local/etc/bash_completion.d/brew (or, more generally, $(brew --prefix)/etc/bash_completion.d/brew). This change was made on April 3rd in commit edf000e when some parts of Homebrew were re-organized.

Install ruby using rbenv's downloaded file

I need to install ruby 2.0.0-p645 and I use rbenv. I tried downloading it by running
rbenv install 2.0.0-p645
But the internet in my college keeps dropping every few minutes, so the transfer was always closing with some 11MB remaining.
To counter that, I saw the url from where rbenv was downloading, and used wget to download the source file that rbenv was downloading. (using wget -c for resuming every time the connection closed).
Now I have the file, is there a way to install that ruby version now?
The file's link on cloudfront that I have on my machine.
Yes. Put the downloaded file into ~/.rbenv/cache. You might need to create the directory first. Then run your rbenv install command again. Here is the link to the documentation for this: https://github.com/rbenv/ruby-build#package-download-caching
To summarize, for future reference:
Download the file using wget
Create a cache folder in ~/.rbenv/ if it doesn't exist already.
Rename the downloaded file to ruby-x.y.z-pabc.tar.gz. Extract it and move it to ~/.rbenv/cache/
Run rbenv install x.y.z-pabc
For me, the following steps work.
1 Download the file using `wget/curl or any other way`
2. Create a `cache` folder in `~/.rbenv/` if it doesn't exist already.
3. Move the downloaded file to `~/.rbenv/cache/`
4. Run `rbenv install x.y.z` (ex. rbenv install 2.7.1`)
The difference from the above answer was,
- do not need to change file name
- do not need to extract
- if file rename to something random (ex. x.y.z-pabc) it show ruby-build: definition not found: x.y.z-pabc
Hope this can help someone.

How can I fix user dir permissions for my Cydia app?

I am having an issue with my application hosted on Cydia.
Users are complaining that the app crashes on startup.
The app uses CoreData, I thought it had something to do with this.
Weird thing is that it works fine using simulator or on my device when testing.
But as soon as it is installed through Cydia it crashes.
Turns out that using "Fix User Dir Permissions" from SBSettings fixes this issue.
Now what can I do about this?
I just had a discussion with the repository guys at BigBoss about this.
I never really got a clear answer, but it looks to me like when Cydia installs your application, it doesn't necessarily set the ownership (explicitly) for your application. That seems bizarre to me. In my case, they were test-installing my app, and seeing that it was owned by user/group = { 1000 / 100 }, which was the linux user id and group id from the machine I was preparing my .deb package on!
I can also see this same behavior if I build a .deb package, deploy it to my own local test repository, and install it with Cydia (pointing at my own repo).
In any case, I explained this to them, and they did something to fix it (without anything more from me).
However, one other option is to manually fix permissions in your post install script. In your .deb package, you would have this folder and file structure:
DEBIAN/control
DEBIAN/postrm
DEBIAN/postinst
DEBIAN/preinst
If you put this in your postinst script, I think it should fix this immediately, without having to go into SBSettings afterwards:
#!/bin/bash
chown -R root.wheel /Applications/MyAppName.app/
exit 0
You can do more than that in the script, if you need other directories created, for example. But, the above will at least suffice to change ownership on the .app directory itself.
This BigBoss link recommends creating additional directories in your app's code, and points out that the installer runs as root, while your app normally runs as user mobile. Depending on what you're doing, it may be better to fix ownership/permissions in postinst (root) or in the app (mobile).

Categories

Resources