denoland/deno · error

Unable to fix import changes: {:#}

Error message

Unable to fix import changes: {:#}

What it means

During workspace/willRename of files, the LSP asks tsc for import-rewriting edits, then post-processes them with fix_ts_import_changes_for_file_rename so import specifiers that referenced the old file path are corrected; this wraps a failure of that fix-up step. Causes include mapping the returned text changes through the line index of importing modules that changed concurrently, and URIs that fail to parse or resolve against the snapshot.

Source

Thrown at cli/lsp/ts_server.rs:1183

              continue;
            }
            let changes = ts_server
              .get_edits_for_file_rename(
                snapshot.clone(),
                &module,
                &uri_to_url(&Uri::from_str(&rename.new_uri).unwrap()),
                token,
              )
              .await?;
            let changes = fix_ts_import_changes_for_file_rename(
              changes,
              &rename.new_uri,
              &module,
              language_server,
              token,
            )
            .map_err(|err| {
              anyhow!("Unable to fix import changes: {:#}", err)
            })?;
            if !changes.is_empty() {
              changes_with_modules
                .extend(changes.into_iter().map(|c| (c, module.clone())));
            }
          }
        }
        file_text_changes_to_workspace_edit(
          changes_with_modules.iter().map(|(c, m)| (c, m.as_ref())),
          &snapshot,
          token,
        )
      }
    }
  }

  pub async fn provide_inlay_hint(
    &self,

View on GitHub (pinned to 9ad36f7a2c)

Solutions

  1. Save all files that import the one being renamed, then repeat the rename.
  2. Retry the rename once edits settle — snapshot races clear on the next attempt.
  3. Run "Deno: Restart Language Server" if file renames consistently fail to update imports.
  4. Update Deno; check the wrapped error after the colon in the language server output.
Defensive patterns

Strategy: fallback

Try / catch

// willRename failures should not block the file rename itself: proceed
// without automatic import rewrites and warn.
try {
  const edit = await client.sendRequest('workspace/willRename', params);
  if (edit) await client.applyEdit(edit);
} catch (err) {
  if (String(err?.message).includes('Unable to fix import changes')) {
    showWarning('File renamed; update importing specifiers manually.');
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Renaming or moving a file in the IDE while modules that import it are dirty or were just edited; the import-change fix-up then fails to map edits through a stale line index.

Common situations: Dragging files in the explorer with many unsaved importers; renaming a file inside a workspace mid-refactor; intermittent during rapid multi-file edits.

Related errors


AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20). Data as JSON: /api/errors/93b93f21cc499e3f. Report an issue: GitHub.