Skip to content

Fix path handling in scripts/build-challenge-map-graphql.mjs to support Windows (double C:/ bug) #592

@NewtonLC

Description

@NewtonLC

Problem:
When running node scripts/build-challenge-map-graphql.mjs on Windows, the script fails with an error:

Error building challenge map: Error: ENOENT: no such file or directory, mkdir 'C:\C:\Users\newto\dev\classroom\data'
    at async mkdir (node:internal/fs/promises:859:10)
    at async buildChallengeMapFromGraphQL (file:///C:/Users/newto/dev/classroom/scripts/build-challenge-map-graphql.mjs:161:5) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'mkdir',
  path: 'C:\\C:\\Users\\newto\\dev\\classroom\\data'
}

The script is incorrectly generating a path with two C:/ prefixes (e.g., C:\C:\Users...).

Expected Behavior:

  • The script should correctly resolve file paths on all platforms (Windows, macOS, Linux).
  • Directory creation and path handling should work regardless of the user's operating system, without duplicating path roots.

Steps to Reproduce:

  1. On a Windows machine, run node scripts/build-challenge-map-graphql.mjs.
  2. Observe the ENOENT error with the double C:/ path.

Suggested Solution:

  • Use Node.js's built-in path module (path.join/path.resolve) instead of manual string concatenation to construct file paths.
  • Audit the script for any locations where paths are manually combined, and replace them with cross-platform-safe path handling.

Relevant File:

  • scripts/build-challenge-map-graphql.mjs

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions