janhq/jan · error · Error

Model already exists

Error message

Model ${modelId} already exists

What it means

import() checks whether providerPath/models/<modelId>/model.yml already exists before importing. If the model directory is already present, it refuses to overwrite and throws this error to protect the existing model configuration.

Solutions

  1. Delete the existing model directory (providerPath/models/<modelId>) or call the extension's delete method before importing
  2. Choose a different, unique modelId
  3. Check existence first (fs.existsSync on the model.yml path) and skip or update instead of importing
  4. If the earlier import failed mid-way, remove leftover files then retry

Example fix

// before
await mlx.import('mlx-community/Llama-3-8B', opts) // throws if it exists
// after
const existing = await mlx.getModels().then(ms => ms.some(m => m.id === 'mlx-community/Llama-3-8B'))
if (!existing) await mlx.import('mlx-community/Llama-3-8B', opts)
Defensive patterns

Strategy: validation

Validate before calling

import fs from 'path-browserify'
const configPath = await joinPath([await mlx.getProviderPath(), 'models', modelId, 'model.yml'])
if (await fs.existsSync(configPath)) return // or update/delete first

Try / catch

try {
  await mlx.import(modelId, opts)
} catch (e) {
  if (String(e).includes('already exists')) {
    await mlx.delete(modelId)
    await mlx.import(modelId, opts)
  } else throw e
}

Prevention

When it happens

Trigger: Calling MlxExtension.import(modelId, opts) when a model with the identical modelId was previously imported and its model.yml still exists on disk.

Common situations: Re-running an import script twice; re-importing after a partial/cancelled download that still left model.yml; name collision between an org/repo id and an existing local model; upgrading a model without deleting the old directory.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


AI-assisted analysis of janhq/jan@7205d770c1 (2026-09-17). Data as JSON: /api/errors/f2235e03a624bdfb. Report an issue: GitHub.

Appendix: source

Thrown at extensions/mlx-extension/src/index.ts:618

        savePath: newModelConfigPath,
      })
    )
  }

  override async import(modelId: string, opts: ImportOptions): Promise<void> {
    if (!isValidModelId(modelId))
      throw new Error(
        `Invalid modelId: ${modelId}. Only alphanumeric and / _ - . characters are allowed.`
      )

    const configPath = await joinPath([
      await this.getProviderPath(),
      'models',
      modelId,
      'model.yml',
    ])
    if (await fs.existsSync(configPath))
      throw new Error(`Model ${modelId} already exists`)

    const sourcePath = opts.modelPath

    if (sourcePath.startsWith('https://')) {
      // Download from URL to mlx models folder
      const janDataFolderPath = await getJanDataFolderPath()
      const modelDir = await joinPath([
        janDataFolderPath,
        'mlx',
        'models',
        modelId,
      ])
      const localPath = await joinPath([modelDir, 'model.safetensors'])

      const downloadManager = window.core.extensionManager.getByName(
        '@janhq/download-extension'
      )

View on GitHub (pinned to 7205d770c1)