janhq/jan · warning · Error

settings:general.couldNotRelocateToRoot

settings:general.couldNotRelocateToRoot

Error message

settings:general.couldNotRelocateToRoot

What it means

Thrown in confirmDataFolderChange (general.tsx:167) when the user-selected path for the Jan data folder is a filesystem root (isRootDir returns true). The guard prevents relocating app data into C:\, D:\, or /, which would scatter thousands of files across the root and break relative paths. Message is i18n key 'settings:general.couldNotRelocateToRoot'.

Source

Thrown at web-app/src/routes/settings/general.tsx:167

    })

    if (selectedPath === janDataFolder) return
    if (selectedPath !== null) {
      setSelectedNewPath(selectedPath as string)
      setIsDialogOpen(true)
    }
  }

  const confirmDataFolderChange = async () => {
    if (selectedNewPath) {
      try {
        await serviceHub.models().stopAllModels()
        serviceHub.events().emit(SystemEvent.KILL_SIDECAR)
        setTimeout(async () => {
          try {
            // Prevent relocating to root directory (e.g., C:\ or D:\ on Windows, / on Unix)
            if (isRootDir(selectedNewPath))
              throw new Error(t('settings:general.couldNotRelocateToRoot'))
            await serviceHub.app().relocateJanDataFolder(selectedNewPath)
            setJanDataFolder(selectedNewPath)
            // Only relaunch if relocation was successful
            window.core?.api?.relaunch()
            setSelectedNewPath(null)
            setIsDialogOpen(false)
          } catch (error) {
            console.error(error)
            toast.error(
              error instanceof Error
                ? error.message
                : t('settings:general.failedToRelocateDataFolder')
            )
          }
        }, 1000)
      } catch (error) {
        console.error('Failed to relocate data folder:', error)
        // Revert the data folder path on error

View on GitHub (pinned to fad3f12a14)

Solutions

  1. Select a named subfolder on the target drive, e.g. D:\JanData instead of D:\.
  2. The UI shows this as a toast; pick a non-root path and confirm again.
  3. If migrating to a new drive, create the target folder first in your file manager, then select it.

Example fix

// before
if (isRootDir(selectedNewPath))
  throw new Error(t('settings:general.couldNotRelocateToRoot'))
// after: validate before showing the confirm dialog, disable the Confirm button
const isRoot = isRootDir(selectedNewPath)
// <Button disabled={isRoot}>{t('settings:general.confirm')}</Button>
{isRoot && <p className="text-warning">{t('settings:general.couldNotRelocateToRoot')}</p>}
Defensive patterns

Strategy: validation

Validate before calling

function isSafeDataFolder(p: string): boolean {
  return p.trim().length > 0 && !isRootDir(p)
}
// before confirmDataFolderChange runs:
if (!isSafeDataFolder(selectedNewPath)) {
  // disable Confirm button, show inline warning
  return
}

Type guard

function isNonRootPath(p: unknown): p is string {
  return typeof p === 'string' && p.trim().length > 0 && !isRootDir(p)
}

Try / catch

try {
  await serviceHub.app().relocateJanDataFolder(selectedNewPath)
} catch (e) {
  // the root-dir guard throws before this; other relocation errors land here
  toast.error(e instanceof Error ? e.message : t('settings:general.failedToRelocateDataFolder'))
}

Prevention

When it happens

Trigger: User opens the data-folder picker and selects a drive root (Windows C:\ or D:\, Unix /). isRootDir(selectedNewPath) returns true and the throw fires before relocateJanDataFolder runs.

Common situations: User wants the data on a different drive and picks the drive letter root instead of a named subfolder; accidental root selection in the native directory picker; user misunderstanding that any folder is acceptable but the root is not.

Related errors


AI-assisted analysis of janhq/jan@fad3f12a14 (2026-08-12). Data as JSON: /api/errors/9372560fad13762e. Report an issue: GitHub.