I have `/usr/bin/env` in my "Macintosh HD" but not in the recovery partition. Is this normal?

Solution 1:

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.

Solution 2:

Many commands are missing when booted to the Recovery partition. If the macOS, you normally boot to, is in good order, then you can restore access to the missing commands by following the instructions given below.

You can access the missing commands by updating the PATH variable. To do this you will need to know the name of the macOS startup disk. The steps are given below.

  1. Determine the name of your startup disk for macOS. While booted to macOS, select →About this Mac from the menu bar. The startup disk name will be displayed on the popup window. On my Mac, the name is Marlin.
  2. Boot to the Recovery partition.
  3. Open a Terminal window.
  4. Enter the commands given below. Replace Marlin with the name of your startup disk.

    RT="/Volumes/Marlin"
    readonly OLDPATH=$PATH
    export PATH=$OLDPATH:$RT/usr/local/bin:$RT/usr/bin:$RT/bin:$RT/usr/sbin:$RT/sbin
    

In your case, /usr/bin/env is an absolute path, so updating the PATH variable will not remove the error message. However, you can manually select the bash shell and then execute the script.

Instead of using

./refind-install

you could have used

bash
. refind-install
exit

or

bash
source refind-install
exit

Note: I omitted any necessary arguments to refind-install.

The Best Advice for Your Situation

In your case, you would be better off avoiding any additional absolute paths to commands that might exist in the refind-install script. The best way to do this would be to boot to the Recovery partition and execute the following command. This will disable System Integrity Protection (SIP).

csrutil disable

You then can boot back to macOS and run the refind-install script. To enable SIP, enter the following command, then reboot your Mac.

csrutil clear