DeterminateSystems / nix-installer

Install Nix and flakes with the fast and reliable Determinate Nix Installer, with over 7 million installs.
https://determinate.systems
GNU Lesser General Public License v2.1
2.15k stars 53 forks source link

Parsing of a faulty APFS volume breaks installation #833

Open ches opened 8 months ago

ches commented 8 months ago

Error

Error: 
   0: Planner error
   1: Error executing action
   2: Action `create_nix_volume` errored
   3: Action `create_apfs_volume` errored
   4: Serde("missing field `Encryption`")

Metadata

key value
version 0.16.1
os macos
arch aarch64

This is an edge case, but a real one that happened, so perhaps it's worth improving.

The Encryption field in plist output from diskutil appears to be optional actually, at least in the presence of a faulty disk which the command reports with a successful exit status.

I happen to have a faulty external disk attached, for which diskutil apfs list reports an error string in the Encrypted field where the relevant bit looks like this in the human-readable output (notice the final line):

+-- Container disk5 70967390-346F-4062-B600-D559E11B9625
    ====================================================
    APFS Container Reference:     disk5
    Size (Capacity Ceiling):      999994101760 B (1000.0 GB)
    Capacity In Use By Volumes:   613823676416 B (613.8 GB) (61.4% used)
    Capacity Not Allocated:       386170425344 B (386.2 GB) (38.6% free)
    |
    +-< Physical Store disk4s2 435B27E3-03BD-4B4B-942B-DB6C74E514FB
    |   -----------------------------------------------------------
    |   APFS Physical Store Disk:   disk4s2
    |   Size:                       999994101760 B (1000.0 GB)
    |
    +-> Volume disk5s1 E04BD327-E0C1-4B31-BE82-97F4D68DD072
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk5s1 (No specific role)
    |   Name:                      Heen (Case-insensitive)
    |   Mount Point:               Not Mounted
    |   Capacity Consumed:         104920772608 B (104.9 GB)
    |   Sealed:                    No
    |   FileVault:                 No
    |
    +-> Volume disk5s3 51A18CB8-3F37-456F-8F00-D11D5B1268AB
        ---------------------------------------------------
        APFS Volume Disk (Role):   disk5s3 (Backup)
        Name:                      Time Machine (Case-sensitive)
        Mount Point:               Not Mounted
        Capacity Consumed:         508695658496 B (508.7 GB)
        Encrypted:                 ERROR -69461

In plist format, I guess given that it isn't certain of a decisive boolean value, the Encryption field just gets omitted altogether:

Long-ish plist snippet ```xml APFSContainerUUID 70967390-346F-4062-B600-D559E11B9625 CapacityCeiling 999994101760 CapacityFree 386170425344 ContainerReference disk5 DesignatedPhysicalStore disk4s2 Fusion PhysicalStores DeviceIdentifier disk4s2 DiskUUID 435B27E3-03BD-4B4B-942B-DB6C74E514FB Size 999994101760 Volumes APFSVolumeUUID E04BD327-E0C1-4B31-BE82-97F4D68DD072 CapacityInUse 104920772608 CapacityQuota 0 CapacityReserve 0 CryptoMigrationOn DeviceIdentifier disk5s1 Encryption FileVault Locked Name Heen Roles APFSVolumeUUID 51A18CB8-3F37-456F-8F00-D11D5B1268AB CapacityInUse 508695658496 CapacityQuota 0 CapacityReserve 0 CryptoMigrationOn DeviceIdentifier disk5s3 Name Time Machine Roles Backup ```

Note that some other volume fields like <FileVault> and <Locked> are also absent, so may want to consider whether all of these can be handled gracefully. (Perhaps it's even normal for fields to vary for Time Machine volumes—the backup role—even if not faulty?)

Hoverbear commented 8 months ago

Oh no, that is surprising and unfortunate. :(