zed-industries/zed · error

Unable to open target: {}

Error message

Unable to open target: {}

What it means

Raised in `open_target` when `ShellExecuteW(None, "open", target, ...)` returns a value <= 32, the Win32 convention for failure (SE_ERR_* codes such as file-not-found, no-association, or access-denied). The message embeds `std::io::Error::last_os_error()`; target may be a URL or a path being opened with the OS default handler.

Source

Thrown at crates/gpui_windows/src/platform.rs:1300

    pub(crate) invalidate_devices: Arc<AtomicBool>,
    /// Shared with [`WindowsPlatformState::draw_coordinator`] and every other window.
    pub(crate) draw_coordinator: Rc<DrawCoordinator>,
}

struct PlatformWindowCreateContext {
    inner: Option<Result<Rc<WindowsPlatformInner>>>,
    raw_window_handles: std::sync::Weak<RwLock<SmallVec<[SafeHwnd; 4]>>>,
    validation_number: usize,
    main_sender: Option<PriorityQueueSender<RunnableVariant>>,
    main_receiver: Option<PriorityQueueReceiver<RunnableVariant>>,
    directx_devices: Option<DirectXDevices>,
    dispatcher: Option<Arc<WindowsDispatcher>>,
}

fn has_package_identity() -> bool {
    let mut package_full_name_length = 0;
    let result = unsafe {
        windows::Win32::Storage::Packaging::Appx::GetCurrentPackageFullName(
            &mut package_full_name_length,
            None,
        )
    };
    if result == ERROR_INSUFFICIENT_BUFFER {
        true
    } else if result == APPMODEL_ERROR_NO_PACKAGE {
        false
    } else {
        log::warn!("failed to determine whether the process has package identity: {result:?}");
        false
    }
}

fn open_target(target: impl AsRef<OsStr>) -> Result<()> {
    let target = target.as_ref();
    let ret = unsafe {
        ShellExecuteW(

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Map the SE_ERR_* return code to a human-readable message instead of the raw OS error.
  2. Check the target exists/is a valid URL before invoking ShellExecuteW.
  3. Handle SE_ERR_NOASSOC by falling back to 'open with' or an explicit application.
  4. Call SetLastError(0) before ShellExecuteW so last_os_error is reliable.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/gpui_windows/src/platform.rs:1229 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20). Data as JSON: /api/errors/6daeb0becc097a83. Report an issue: GitHub.