I have `/usr/bin/env` in the “Macintosh HD” but not in the recovery partition. Is this normal

bashefipartitionrecoveryterminal

I'm working on a MacBook Air, that's currently booting to macOS High Sierra 10.13.6. It also has an Ubuntu 16.04 partition, that I am currently trying to reach.

I was trying reinstall rEFInd, which due to SIP is done from the recovery partition. It failed because;

-bash: ./refind-install: /usr/bin/env: bad interpreter: No such file or directory

Which was thrown by the #!/usr/bin/env bash at the top of the install script.

I had a look and indeed there is no /usr/bin/env in my recovery partition. There is one on the main partition. This is the terminal in the recovery partition:

[-bash-3.2# ls /usr/bin/env
ls: /usr/bin/env: No such file or directory
[-bash-3.2# ls /Volumes/Macintosh\ HD/usr/bin/env
/Volumes/Macintosh\ HD/usr/bin/env

Now the end goal it to reinstall rEFInd (I had it before, but updating macOS changed the boot order so it no longer boots correctly), but my question right now is: Is it normal to not have /usr/bin/env in the recovery partition?

The fact that the rEFInd script expects it to be there makes me wonder if I have broken something.

Best Answer

Is it normal to not have /usr/env/bin in the recovery partition?

Yes, it's perfectly normal for /usr/bin/env to not be in the recovery partition.

If you were to mount the Recovery partition and open the BaseSystem.dmg container to search for the file, you'll find that it doesn't exist.

$ diskutil list

 #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                    209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh              999.3 GB   disk0s2
   3:                 Apple_Boot Recovery HD            650.0 MB   

So, disk0s3 is the one we want to mount

$ sudo mkdir /Volumes/RecoveryHD
$ sudo mount -t HFS /Volumes/RecoveryHD

Now, open the recovery system image BaseSystem.dmg.

$ open /Volumes/RecoveryHD/com.apple.recovery.boot/BaseSystem.dmg

A GUI will pop up on the screen with a Finder window.

Finder Window

Traverse to the /usr/bin and you'll notice that env is not there.

enter image description here

It's important to remember that the Recovery partition is a slimmed down version of the actual base system. To make rEFInd work correctly, it needs to be done on the boot partition, not from the recovery partition. So, in the end, you didn't mess anything up.