Because the `dir, err := raw.join("devices", false, pid)` line inside the `if !c.DeviceAccess` scope introduces a *new* variable `err` shadowing the return value one, so the defer function doesn't reference the err you want it to otherwise.