Skip to content

Switching drivers.ios.deviceSet back gets stuck on a leftover seed, and the refusal's advice breaks iOS #1296

Closed

Description

@V3RON

What happened

Switching drivers.ios.deviceSet between simlock and default gets stuck, and following the error's own advice makes it worse.

  1. After leasing on deviceSet: default and switching back to simlock, iOS is refused (doctor reason device-set-changed): "Refusing the ios device set: Simlock's sources set at ~/.simlock/devices/ios-sources still holds 1 simulator(s) (D2A158F3-…). Set drivers.ios.deviceSet back to default, run simlock nuke --delete-devices and simlock doctor --purge-orphans, then switch again…". On simlock, nuke --delete-devices, doctor --purge-orphans --yes, doctor --fix and cleanup do nothing for it, because the iOS driver does not start.
  2. Deleting that seed by hand with xcrun simctl --set … delete (which the refusal also suggests) breaks iOS leases: PROVISION_FAILED, simctl clone D2A158F3… Invalid device. nuke logs "nuke could not delete a seed … Invalid device", and doctor keeps listing the seed. Only deleting its ios_source_data row from state.db by hand fixed it.

What you expected

The refusal says the steps that work: set default again, run nuke and purge there, then switch. A seed already gone from simctl counts as deleted, so nuke drops its record and iOS works again.

How to reproduce

  1. simlock config set ios.simulator.headless false, simlock config set drivers.ios.deviceSet default, restart, lease and release an iOS device.
  2. simlock config set drivers.ios.deviceSet simlock (and headless true), restart: iOS refused as above.
  3. Delete the named seed with xcrun simctl --set ~/.simlock/devices/ios-sources delete <udid>, restart, lease iOS: PROVISION_FAILED.

Environment

Simlock 0.5.0 package at main 14a3f826b, macOS 27.0.1 arm64, Xcode 27.1, Android emulator 37.2.13. Found in the 0.6 release E2E run on 2026-11-05. iOS only.

Logs and evidence

From a read of the code:

  • Under simlock, IosSimctlDriver.create (src/drivers/ios/index.ts:391) calls refuseDefaultSourcesLeftovers (src/drivers/ios/device-set-leftovers.ts:35-49) and throws, so no iOS driver exists. Nuke (src/core/nuke-service.ts:134-160) and doctor only reach drivers that started.
  • destroySource (src/drivers/ios/index.ts:856-871) runs simctl delete through #deleteSeedSimulator (index.ts:1117-1120). For a missing UDID it throws "Invalid device", which skips deleteRow (index.ts:870). The row stays ready and readyRows (src/drivers/ios/source-data.ts:112) picks it as the seed to clone.
  • The refusal messages (device-set-leftovers.ts:30,46) tell users to delete seeds with simctl delete by hand.
  • The same refusal for the simlock → default direction (seeds in devices/ios/sources) works as documented with nuke --delete-devices, but a seed there does not show in simlock simctl list devices.

Written by an agent.

Activity

  1. added
    bug:new
    platform:ios
    on Nov 5, 2026
  2. self-assigned this
    on Nov 5, 2026
  3. V3RON commented on Nov 5, 2026

    @V3RON
    ContributorAuthor

    Written by an agent.

  4. V3RON commented on Nov 5, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    Defect, confirmed: a seed row whose simulator simctl no longer knows is never deleted, so nuke keeps it and provision keeps cloning it. The refusal's main steps (set default, nuke, purge, switch) work; only its hand-delete step leads here.

    src/drivers/ios/index.test.ts, new case destroySource drops the row of a seed simctl no longer knows (Invalid device) on bug/1296-repro. Exit code and stderr are real simctl output for an unknown UDID, recorded against an empty scratch set.

    pnpm exec vitest run --project unit src/drivers/ios/index.test.ts -t destroySource
    
    AssertionError: promise rejected "DriverCrashError: simctl delete 00000000-…" instead of resolving
    Caused by: DriverCrashError: simctl delete …aa exited with code 148: Invalid device: …aa
     ❯ IosSimctlDriver.#deleteSeedSimulator src/drivers/ios/index.ts:1119:5
    

    Root cause

    src/drivers/ios/index.ts:1119: #deleteSeedSimulator treats every non-zero simctl delete as a failure, so destroySource (index.ts:869-870) throws before deleteRow. The row stays ready. findReadySeed (source-data.ts:109) then returns it on every provision, and simctl clone fails with Invalid device (the PROVISION_FAILED in the issue). findReadySeed ignores set_path too, so a row left from the other deviceSet is cloned with the wrong --set.

    Simplest fix

    In #deleteSeedSimulator, treat exit 148 with stderr Invalid device: as already deleted, so the row is dropped. Then nuke --delete-devices clears the row under either set. A sketch passes the whole file.

    Alternatives rejected

    • Skip simctl when <sources set>/<udid> is missing: breaks the existing "busy" case, which plants no folder, and adds a second notion of "gone".
    • Filter findReadySeed by set_path: the leftover row then stays forever.
    • Remove only the hand-delete advice: rows already in this state would still break iOS.

    Risk

    • Without a nuke, the first lease after a hand delete still fails. Self-healing in provision (an Invalid device from clone drops the row and makes a new seed) is a separate decision.
    • The refusal texts (device-set-leftovers.ts:27,45,67) should say to run nuke after a hand delete.
    • Matching stderr text: #destroySeed (stale seed) and saveSource cleanup share the changed path; check both.

    Written by an agent.

  5. removed their assignment
    on Nov 5, 2026
  6. added
    bug:ready
    and removed
    bug:new
    on Nov 5, 2026
  7. self-assigned this
    on Nov 5, 2026
  8. V3RON commented on Nov 5, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1303 (#1296)
    Parked: none
    Waiting: none
    Decided: none

    Written by an agent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:readyplatform:ios

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions