Skip to content

[attest] ParseError: "A Scope already named Array already exists" when used with arktype@2.2.0 #1617

@yamcodes

Description

@yamcodes

Report a bug

🔎 Search Terms

"Scope already named Array already exists", "attest parse error Array", "arktype attest conflict", "pnpm dual-package hazard @ark/schema"

🧩 Context

  • ArkType version: 2.2.0
  • TypeScript version (5.1+): 6.0.3
  • Other context you think may be relevant (JS flavor, OS, etc.):
    • Package Manager: pnpm@11.0.8 (workspaces enabled)
    • OS: MacOS
    • Runner: Vitest v4.1.5

🧑‍💻 Repro

This issue occurs when using @ark/attest@0.56.0 alongside arktype@2.2.0 in a pnpm workspace. The root cause is a dual-package hazard because @ark/attest has a hard dependency on arktype@2.1.28.

Reproduction Steps:

  1. Create a pnpm workspace.
  2. Add arktype@2.2.0 and @ark/attest@0.56.0 to a package.
  3. Configure vitest with globalSetup: ["@ark/attest/setup"].
  4. Run vitest.

Expected Result:
Tests run successfully.

Actual Result:
The test runner fails during initialization with the following error:

ParseError: A Scope already named Array already exists
 ❯ throwError ../../node_modules/.pnpm/@ark+util@0.56.0/node_modules/@ark/util/out/errors.js:5:11
 ❯ throwParseError ../../node_modules/.pnpm/@ark+util@0.56.0/node_modules/@ark/util/out/errors.js:10:43
 ❯ new BaseScope ../../node_modules/.pnpm/@ark+schema@0.56.0/node_modules/@ark/schema/out/scope.js:90:13
 ❯ new InternalScope ../../node_modules/.pnpm/arktype@2.2.0/node_modules/arktype/out/scope.js:10:8
 ❯ InternalScope.scope ../../node_modules/.pnpm/arktype@2.2.0/node_modules/arktype/out/scope.js:100:43
 ❯ InternalScope.module ../../node_modules/.pnpm/arktype@2.2.0/node_modules/arktype/out/scope.js:101:49
 ❯ ../../node_modules/.pnpm/arktype@2.2.0/node_modules/arktype/out/keywords/Array.js:14:31

Playground Link: https://arktype.io/playground (Note: This is a dependency resolution issue, so it may not be directly reproducible in the single-package browser playground).

// Repro involves multiple packages/resolutions
// But at a code level, simply importing both in the same environment triggers it:

import { type } from "arktype"
import { attest } from "@ark/attest"

// Error occurs during module evaluation of keywords/Array.js 
// when the second copy of @ark/schema tries to register the 'Array' scope.

Proposed Solution

Update @ark/attest to use peerDependencies for arktype or ensure it is compatible with the latest major/minor releases to avoid duplicate internal @ark/* package registrations in hoisted environments.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status

To do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions