Restoring lost/damaged macOS 10.15 Catalina file associations

Every once in a while, my mac will forget its file associations as well things like default browser, email client, etc. This is super frustrating. What I’ve done in the past was simply set all my file associations back the old fashioned way. That means bringing up the Get Info dialog, picking a new app in the “Open with:” section, and clicking the Change All... button. This is a slow and laborious process and I’m too damn lazy to do that more than once. Well, I recently lost my file associations yet again, so I became determined to find out a way to restore my lost associations rather than manually associate them all over again.

I figured if I can find the location of where these associations are actually stored on disk, I could simply restore this file from a backup and avoid all the “Get Info” hoopla. This proved pretty difficult at the time of this post. Any and all search variations of “mac os file associations stored”, “file associations location”, “file association path” came up mostly useless. But as is so often the case, a kind samaritan at Stack Exchange pointed me in the right direction.

Lri’s post goes into some awesome detail that may be of use to folks, so please do check it out. However I’m plucking out the part that was important to me, posting it on my blog, and sprinkling in some keywords to help future googlers that simply want to restore their file associations (<- those were some keywords right there!). To me, the most important part is the location of where the dang file associations are stored on disk.

On 10.15 Catalina (this may be the case on other versions, but I can only vouch for 10.15), the file associations are stored in this file:

~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist

Simply restore that file from a backup (I used Time Machine) and do a full reboot (not just log out and log in). That did the trick for me!

npm failing with space in file path

I had updated some node stuff on my system one day (macOS 10.13.6). Later, when I went to work on a Laravel project, I discovered somewhere along the line I had broken something. Laravel would not run.

I thought perhaps my packages for this project were messed up so I tried reinstall them via npm install , but that was erroring. After a lot of frustration and research, I narrowed it down to the node-gyp package causing the problems. It appears it doesn’t support spaces in paths (that’s what this conversation was saying at least). The space in question here is the space in my main macOS user home directory path. I have my home directory on a separate drive from my system. That drive is named “User Drive”. node-gyp was trying to write some temp files inside my home dir and the error message was saying something along the lines of can’t find “Drive/myusername/yadayada”. Well, that’s because it’s not “Drive/myusername/yadayada“, it’s “User Drive/myusername/yadayada“!  I find it very odd that a mature software in 2019 would have such an issue ????

The solution

On the main node-gyp page, I found that I can set the temp directory to something other than my space-having home path. I just did this:

export npm_config_devdir=/tmp/.gyp

I was then able to run npm install which fixed my laravel project. All was good again.

CentOS not retrieving IP via DHCP

I downloaded CentOS 5.2 Minimal Installation v1.3 pre-made VMWare virtual machine. After I upgraded CentOS from 5.2 to 5.4 (yum upgrade), my network connection stopped working because it wasn’t getting a dhcp address. Turns out my ifcfg-eth0 file had the wrong “HDADDR”.

Luckily the solution was easy:

  1. Run ifconfig eth0
  2. Make note of the “HWaddr” from it’s output. You’re looking for a hex value that looks something like: 00:0c:29:72:46:d6
  3. Edit /etc/sysconfig/network-scripts/ifcfg-eth0 and make sure the HWADDR in that file is the same as the HWaddr from the ifconfig command

That solved the problem for me