Azure / autorest

OpenAPI (f.k.a Swagger) Specification code generator. Supports C#, PowerShell, Go, Java, Node.js, TypeScript, Python
MIT License
4.62k stars 739 forks source link

`Error: Could not read file` when folder contains `#` character #4600

Open JeroenOortwijn opened 2 years ago

JeroenOortwijn commented 2 years ago

Describe the bug When running the autorest --input-file=spec_v2.json --csharp command from the C:\Users\Jeroen\Downloads\Autorest\C# folder, it fails: image

When running the same command from the C:\Users\Jeroen\Downloads\Autorest folder, it works (ignore the errors): image

Expected behavior It should also work when run from the C:\Users\Jeroen\Downloads\Autorest\C# folder.

Additional context Full output with --verbose and --debug switches:

AutoRest code generation utility [cli version: 3.6.2; node: v16.16.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
info    | AutoRest core version selected from configuration: ^3.7.0.
debug   | [1.59 s] Network Enabled: true
debug   | [1.71 s] The most recent installed version is 3.9.0
debug   | [1.72 s] Starting @autorest/core from C:\Users\Jeroen\.autorest\@autorestcore@3.9.0\nodemodules\@autorest\core
info    |    Loading AutoRest core      'C:\Users\Jeroen\.autorest\@autorestcore@3.9.0\nodemodules\@autorest\core\dist' (3.9.0)
verbose | [1.51 s] No configuration found at 'file:///C:/Users/Jeroen/Downloads/Autorest/C%23/'.
verbose | [1.53 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/default-configuration.md'
verbose | [1.59 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/inspect.md'
verbose | [1.61 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/directives.md'
verbose | [1.65 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/pipeline.md'
verbose | [1.67 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/loader-openapi.md'
verbose | [1.72 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/miscellaneous.md'
verbose | [1.75 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/plugin-powershell.md'
verbose | [1.78 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/plugin-azureresourceschema.md'
verbose | [1.81 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/plugin-csharp.md'
verbose | [1.85 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/plugin-go.md'
verbose | [1.87 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/plugin-java.md'
verbose | [1.90 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/plugin-nodejs.md'
verbose | [1.93 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/plugin-php.md'
verbose | [1.96 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/plugin-python.md'
verbose | [1.99 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/plugin-ruby.md'
verbose | [2.02 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/plugin-typescript.md'
verbose | [2.05 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/plugin-validators.md'
verbose | [2.10 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/plugin-az.md'
verbose | [2.13 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/plugin-terraform.md'
verbose | [2.17 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/plugin-azure-functions.md'
verbose | [2.21 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/graphs.md'
verbose | [2.24 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcore@3.9.0/nodemodules/@autorest/core/dist/resources/help-configuration.md'
info    |    Loading AutoRest extension '@autorest/csharp' (latest->3.0.0-beta.20220725.1)
verbose | [2.46 s]    Including extension configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcsharp@3.0.0-beta.20220725.1/nodemodules/@autorest/csharp/readme.md'
verbose | [2.46 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestcsharp@3.0.0-beta.20220725.1/nodemodules/@autorest/csharp/readme.md'
info    |    Loading AutoRest extension '@autorest/modelerfour' (4.23.5->4.23.5)
verbose | [2.66 s]    Including extension configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestmodelerfour@4.23.5/nodemodules/@autorest/modelerfour/readme.md'
verbose | [2.66 s]    Including configuration file 'file:///C:/Users/Jeroen/.autorest/@autorestmodelerfour@4.23.5/nodemodules/@autorest/modelerfour/readme.md'
debug   | [3.92 s] swagger-document/loader-swagger - START inputs = 0
debug   | [3.93 s] openapi-document/loader-openapi - START inputs = 0
debug   | [3.93 s] pipeline-emitter - START inputs = 0
debug   | [3.93 s] configuration-emitter - START inputs = 0
debug   | [3.93 s] pipeline-emitter - END [0.09 s][83 MB]
debug   | [3.93 s] configuration-emitter - END [0.09 s][83 MB]
debug   | [3.93 s] azure:datastore:error Unexpected error trying to read file Error: file:///C:/Users/Jeroen/Downloads/Autorest/C%23/spec_v2.json is not found: File does not exist at the specified endpoint
fatal   | Process() cancelled due to exception : Could not read 'file:///C:/Users/Jeroen/Downloads/Autorest/C%23/specv2.json'. / Error: Could not read 'file:///C:/Users/Jeroen/Downloads/Autorest/C%23/specv2.json'.
    at ReadThroughDataSource.readStrict (C:\Users\Jeroen\.autorest\@autorestcore@3.9.0\node_modules\@autorest\core\dist\src_lib_autorest-corets.js:14999:19)
    at loadSwaggerFile (C:\Users\Jeroen\.autorest\@autorestcore@3.9.0\node_modules\@autorest\core\dist\src_lib_autorest-corets.js:3550:18)
    at loadSwaggerFiles (C:\Users\Jeroen\.autorest\@autorestcore@3.9.0\node_modules\@autorest\core\dist\src_lib_autorest-corets.js:3541:29)
    at C:\Users\Jeroen\.autorest\@autorestcore@3.9.0\node_modules\@autorest\core\dist\src_lib_autorest-corets.js:3564:26
    at ScheduleNode (C:\Users\Jeroen\.autorest\@autorestcore@3.9.0\node_modules\@autorest\core\dist\src_lib_autorest-corets.js:1351:29)
error   |   Error: Could not read 'file:///C:/Users/Jeroen/Downloads/Autorest/C%23/spec_v2.json'.
error   | Autorest completed with an error. If you think the error message is unclear, or is a bug, please declare an issues at https://github.com/Azure/autorest/issues with the error message you are seeing.
debug   | [3.93 s] Shutting Down.
debug   | [3.93 s] Exiting.
timotheeguerin commented 2 years ago

This unfortunatelly seems to be an issue with the underlying library for resolving files https://github.com/TooTallNate/file-uri-to-path/issues/8