Skip to content

Can't use absolute paths on windows #1113

Closed

Description

@cartwrightluke

This fails:
PS G:\Protocol> node G:\quicktype\dist\cli\index.js --src G:\ Protocol\Schema\Protocol_0.1.schema --src-lang schema --out G:\Protocol\Schema\Protocol_0.1.cs --lang cs
Error: Cannot infer name for schema g:\Protocol\Schema\Protocol_0.1.schema.

This works:
PS G:\Protocol> node G:\quicktype\dist\cli\index.js --src Schema\Protocol_0.1.schema --src-lang schema --out Schema\Protocol_0.1.cs --lang cs

Activity

  1. virtuoushub commented on Nov 20, 2018

    @virtuoushub

    As a workaround. have you tried:

    node G:\quicktype\dist\cli\index.js --src G:/Protocol/Schema/Protocol_0.1.schema --src-lang schema --out G:\Protocol\Schema\Protocol_0.1.cs --lang cs
    

    Difference being, --src G:\Protocol\Schema\Protocol_0.1.schema => --src G:/Protocol/Schema/Protocol_0.1.schema

    I have noticed this makes a difference when running on Windows.

  2. skornel02 commented on May 20, 2020

    @skornel02
    Contributor

    The error is thrown in the JSONSchemaInput.ts file: line #1040 and is caused by the URI implementation.
    The library 'urijs' library parses the absolute path and the drive letter is mistaken for a protocol, and therefore fails to deduct a filename which in-turn causes the code to fail.

    Difference being, --src G:\Protocol\Schema\Protocol_0.1.schema => --src G:/Protocol/Schema/Protocol_0.1.schema

    I have noticed this makes a difference when running on Windows.

    In my testing this did not make a difference.

    Using relative source is a good workaround, but the unit tests use absolute path, and will cause windows systems to fail json scheme fixtures

  3. schani commented on Jul 20, 2026

    @schani
    Member

    I retested this on current master (built from source at 662ad5b) using a drive-style Windows path:

    node dist/index.js --src 'G:/Protocol/Schema/Protocol_0.1.schema' --src-lang schema --lang cs

    This now works and produces valid output instead of throwing "Cannot infer name for schema". The root cause skornel02 diagnosed was correct: urijs was misparsing the drive letter as a URI scheme, leaving the filename empty. Paths are now routed through a dedicated Windows path handler (WindowsPaths.ts, added for #2869) that converts drive-style paths to proper file:/// URIs before they reach the schema resolver, so the name is inferred correctly. This fix will be in the next release. If you can still reproduce the failure on a current build, please reopen or comment with the exact command and quicktype version you used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions