DeterminateSystems / nix-installer

Install Nix and flakes with the fast and reliable Determinate Nix Installer, with over 2 million installs.
GNU Lesser General Public License v2.1
2k stars 50 forks source link

Uninstaller: error deleting APFS volume <auto generated issue. almost> #988

Open ink-splatters opened 3 months ago

ink-splatters commented 3 months ago

Error

Uninstaller is broken and never succeeds. It's easy reproducible on latest macOS with volume encryption enabled (I didn't try not to encrypt Nix volume)

Possible issue

you can't delete a volume to which you have open file descriptors

Possible solution

Force-unmounting a volume prior to deletion has always worked for me, unless volume was used by kernel

Error: 
   0: Error reverting
   0: Action `create_apfs_volume` errored
      Failed to execute command with status 1 `"/usr/sbin/diskutil" "apfs" "deleteVolume" "Nix Store"`, stdout: Started APFS operation
      Deleting APFS Volume from its APFS Container
      Unmounting disk4s5
      The volume "Nix Store" on disk4s5 couldn't be unmounted because it is in use by process 18543 (zsh)

      stderr: Error: -69888: Couldn't unmount disk

Metadata

key value
version 0.19.0
os macOS
arch aarch64
cole-h commented 3 months ago

We already run diskutil unmount force [disk] (https://github.com/DeterminateSystems/nix-installer/blob/3cd59da03b1096fb826ebe8f14768beaf9ec038a/src/action/macos/unmount_apfs_volume.rs#L121-L124), and that's where this is failing. As far as I'm aware, that's the only way to force unmount a volume -- is that right?