remix-run/remix · error · AssertionError

expected error to be ${describeExpectedError(args[0])}, got

Error message

expected error to be ${describeExpectedError(args[0])}, got ${stringify(result.error)}

What it means

When a sqlite db command is run with `--connection-env VAR`, `overrideConnection` reads the database filename from `process.env[VAR]` and throws if it's undefined or empty — the CLI cannot know which file to open. `:memory:` is the one special allowed value for an in-memory database; other values are resolved against the invocation cwd.

Source

Thrown at packages/assert/src/lib/expect.ts:488

            actual: result.error,
            operator: `resolves.${matcher}`,
          })
        }
        let m = createMatchers(result.value, negated) as any
        m[matcher](...args)
      } else {
        if (result.resolved) {
          throw new AssertionError({
            message: `expected promise to reject, but it resolved with: ${stringify(result.value)}`,
            actual: result.value,
            operator: `rejects.${matcher}`,
          })
        }
        // For rejects.toThrow we check the error against the expected matcher.
        if (matcher === 'toThrow') {
          let pass = checkErrorMatch(result.error, args[0])
          if (negated ? pass : !pass) {
            throw new AssertionError({
              message:
                (negated ? 'expected not ' : 'expected ') +
                `error to be ${describeExpectedError(args[0])}, got ${stringify(result.error)}`,
              actual: result.error,
              expected: args[0],
              operator: `rejects.toThrow`,
            })
          }
          return
        }
        let m = createMatchers(result.error, negated) as any
        m[matcher](...args)
      }
    }
  }

  return {
    toBe: buildMatcher('toBe'),

View on GitHub (pinned to 9696913134)

Solutions

  1. Set the variable before running: `DATABASE_FILE=./data/app.db remix db migrate --connection-env DATABASE_FILE`
  2. Source your `.env` first or configure CI to export it
  3. Align the var name in remix.json/flags with what's actually exported

Example fix

# before
remix db migrate --connection-env DATABASE_FILE
# after
DATABASE_FILE=./data/app.db remix db migrate --connection-env DATABASE_FILE
Defensive patterns

Strategy: validation

Validate before calling

if (process.env.DATABASE_FILE === undefined || process.env.DATABASE_FILE === '') {
  throw new Error('DATABASE_FILE must be set (e.g. ./data/app.db)');
}
run(['remix','db','migrate','--connection-env','DATABASE_FILE'])

Type guard

function envIsSet(name: string): boolean {
  let v = process.env[name];
  return v !== undefined && v !== '';
}

Prevention

When it happens

Trigger: Running `remix db <command> --connection-env DATABASE_FILE` (or with a config using a connection env) where `process.env.DATABASE_FILE` is unset or exported as `''`.

Common situations: `.env` not loaded before running the CLI in local shells or CI; env var name mismatches between environments; secrets configured in the pipeline but not exported into the step.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of remix-run/remix@9696913134 (2026-08-27). Data as JSON: /api/errors/7a860759150fa793. Report an issue: GitHub.