Azure / autorest

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

Having 'Unable to find a valid AutoRest core package' behind proxy, when generating code with last versions #4409

Closed JoaoCampos07 closed 2 years ago

JoaoCampos07 commented 2 years ago

Before filling a bug Describe the bug I installed Autorest in my personal machine and it works fine. However when install it in work machine behind a corpo proxy, i have the following error :

AutoRest code generation utility [cli version: 3.5.1; node: v14.3.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
info    | AutoRest core version selected from configuration: ^3.7.0.
Failure:
Error: Unable to find a valid AutoRest core package '@autorest/core' @ '^3.7.0'.
Error: Unable to find a valid AutoRest core package '@autorest/core' @ '^3.7.0'.
    at selectVersion (C:\Users\[UserName]\AppData\Local\Yarn\Data\global\node_modules\autorest\dist\src_autorest-as-a-service_ts.js:390:23)
    at runNextTicks (internal/process/task_queues.js:62:5)
    at processImmediate (internal/timers.js:429:9)
    at resolveCoreVersion (C:\Users\[UserName]\AppData\Local\Yarn\Data\global\node_modules\autorest\dist\src_autorest-as-a-service_ts.js:583:29)
    at main (C:\Users\[User]\AppData\Local\Yarn\Data\global\node_modules\autorest\dist\app.js:107:33) 

In the error you can see that i using Yarn but is the same when i use NPM, i try yarn because i saw in this issue that could work : Issue 3341

Steps :

  1. I installed Node 14.3.0 with NPM 6.14.5
  2. Configure the proxy globally with :
    npm config edit
  3. Check if autorest is up and running. After this point i see that in my personal machine in C:\Users[UserName].autorest i have the module "@autorest_core@3.7.5", but in my Work machine and i dont have this.
  4. Them when i try to generate some code :
    autorest --input-file=https://petstore3.swagger.io/api/v3/openapi.json --csharp

    I have :

    SourceMapConsumer.initialize is a no-op when running in node.js
    AutoRest code generation utility [cli version: 3.5.1; node: v16.5.0]
    (C) 2018 Microsoft Corporation.
    https://aka.ms/autorest
    info | AutoRest core version selected from configuration: ^3.7.0.
    Failure:
    Error: Unable to find a valid AutoRest core package '@autorest/core' @ '^3.7.0'.
    Error: Unable to find a valid AutoRest core package '@autorest/core' @ '^3.7.0'.
    at selectVersion (C:\Users\[User]\AppData\Roaming\npm\node_modules\autorest\dist\src_autorest-as-a-service_ts.js:390:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at resolveCoreVersion (C:\Users\[User]\AppData\Roaming\npm\node_modules\autorest\dist\src_autorest-as-a-service_ts.js:583:29)
    at main (C:\Users\[User]\AppData\Roaming\npm\node_modules\autorest\dist\app.js:107:33)

I see that at this point i have in my personal pc in ".autorest" dir: @autorest_core@3.7.5 @autorest_csharp@3.0.0-beta.20220128.3 @autorest_modelerfour@4.22.2 But in my work laptop nothing.

I see that all modules were installed and they are in :
C:\Users[User]\AppData\Roaming\npm

The same problem with yarn when in my work pc behind corporate proxy.

Expected behavior Generate csharp client class's from openApi 3.0.2 API contract

Additional context If somebody please can have a look, because i running out of ideas to use this tool

timotheeguerin commented 2 years ago

Hey @JoaoCampos07, just to confirm: If you do yarn add @autorest/core this is working fine and installing the package?

I think that error might be happening before, do you also have the http_proxy and https_proxy environment variables setup?

JoaoCampos07 commented 2 years ago

Hey @timotheeguerin I think i miss something when switching from NPM to yarn. I tryied everthing again from scratch:


npm install -g yarn

yarn config set strict-ssl false

yarn config set proxy http://[Domain+Slahs][User]:[Password]@[ProxyMachine]:[Port]/

yarn config set https-proxy http://[Domain+Slahs][User]:[Password]@[ProxyMachine]:[Port]/

yarn global add autorest

yarn global add @autorest/core

At this point i should have access from anyhere to autorest exe, right ? If yes is not working... :/

timotheeguerin commented 2 years ago

Hey @JoaoCampos07 could you go to this build from this pr and download the autorest-3.5.1.tgz package https://dev.azure.com/azure-sdk/public/_build/results?buildId=1355943&view=artifacts&pathAsName=false&type=publishedArtifacts

image

and then running npm install -g ./autorest-3.5.1.tgz to install that version

Then running again the command you have issue with with --debug --verbose and share the entire log.

JoaoCampos07 commented 2 years ago

@timotheeguerin , I uninstall autorest module with NPM. And them did was you recomended :

autorest --debug --verbose
SourceMapConsumer.initialize is a no-op when running in node.js
AutoRest code generation utility [cli version: 3.5.1; node: v14.3.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
debug   | [0.80 s] Network Enabled: true
debug   | [0.85 s] No @autorest/core (or @microsoft.azure/autorest-core) is installed.
debug   | [0.85 s] latest-installed was not satisfied directly by a previous installation.
debug   | [5.03 s] Error trying to resolve @autorest/core version ^3.0.0: Error: Unable to resolve package '@autorest/core@3.7.6'.
Failure:
Error: Unable to find a valid AutoRest core package '@autorest/core' @ '^3.0.0'.
Error: Unable to find a valid AutoRest core package '@autorest/core' @ '^3.0.0'.
    at selectVersion (C:\Users\[UserName]\AppData\Roaming\npm\node_modules\autorest\dist\src_autorest-as-a-service_ts.js:391:23)
    at runNextTicks (internal/process/task_queues.js:62:5)
    at processImmediate (internal/timers.js:429:9)
    at resolveCoreVersion (C:\Users\[UserName]\AppData\Roaming\npm\node_modules\autorest\dist\src_autorest-as-a-service_ts.js:584:29)
    at main (C:\Users\[UserName]\AppData\Roaming\npm\node_modules\autorest\dist\app.js:107:33)
timotheeguerin commented 2 years ago

Hey @JoaoCampos07, just added a few more logging/fixed an issue with it so it should give the downstream error. Can you try the same steps with this build. https://dev.azure.com/azure-sdk/public/_build/results?buildId=1370441&view=results

This however looks like the manifest resolving library that is failing to get the info from the npm website. Can you confirm you have the HTTP_PROXY and HTTPS_PROXY system environment variables setup(NOT the npm or yarn http_proxy config). That library specify it should respect those environment variables.

JoaoCampos07 commented 2 years ago

@timotheeguerin, after adding the system environment variables looks like is loaded the missing core module :

AutoRest code generation utility [cli version: 3.5.1; node: v14.3.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
installing core... [========================================] 100% | 2/2
SourceMapConsumer.initialize is a no-op when running in node.js
info    |    Loading AutoRest core      'C:\Users\[User]\.autorest\@autorestcore@3.7.6\nodemodules\@autorest\core\dist' (3.7.6)

I miss put --verbose --debug on the first run, sorry about that :/. In the next one it appeared like so:


autorest --debug --verbose
SourceMapConsumer.initialize is a no-op when running in node.js
AutoRest code generation utility [cli version: 3.5.1; node: v14.3.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
debug   | [4.51 s] Network Enabled: true
debug   | [4.98 s] The most recent installed version is 3.7.6
debug   | [4.98 s] requesting current version '3.7.6'
debug   | [4.99 s] Starting @autorest/core from C:\Users\[User]\.autorest\@autorestcore@3.7.6\nodemodules\@autorest\core
SourceMapConsumer.initialize is a no-op when running in node.js
info    |    Loading AutoRest core      'C:\Users\[User]\.autorest\@autorestcore@3.7.6\nodemodules\@autorest\core\dist' (3.7.6)
verbose | [3.42 s] No configuration found at 'file:///C:/Users/[User]/'.
verbose | [3.43 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/default-configuration.md'
verbose | [3.54 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/inspect.md'
verbose | [3.61 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/directives.md'
verbose | [3.66 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/pipeline.md'
verbose | [3.73 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/loader-openapi.md'
verbose | [3.77 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/miscellaneous.md'
verbose | [3.81 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-powershell.md'
verbose | [3.85 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-azureresourceschema.md'
verbose | [3.92 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-csharp.md'
verbose | [4.00 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-go.md'
verbose | [4.06 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-java.md'
verbose | [4.13 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-nodejs.md'
verbose | [4.24 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-php.md'
verbose | [4.30 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-python.md'
verbose | [4.34 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-ruby.md'
verbose | [4.40 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-typescript.md'
verbose | [4.46 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-validators.md'
verbose | [4.55 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-az.md'
verbose | [4.61 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-terraform.md'
verbose | [4.65 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-azure-functions.md'
verbose | [4.70 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/graphs.md'
verbose | [4.75 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/help-configuration.md'
error   | [Exception] No input files provided.

Use --help to get help information or see https://aka.ms/autorest/cli for additional documentation
error   |   Error: [Exception] No input files provided.

Use --help to get help information or see https://aka.ms/autorest/cli for additional documentation
debug   | [5.11 s] Shutting Down.
debug   | [5.12 s] Exiting.

After installing the new build :


autorest --debug --verbose
SourceMapConsumer.initialize is a no-op when running in node.js
AutoRest code generation utility [cli version: 3.5.2-ci.69cb5d7a6; node: v14.3.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
debug   | [2.00 s] Network Enabled: true
debug   | [2.65 s] The most recent installed version is 3.7.6
debug   | [2.65 s] requesting current version '3.7.6'
debug   | [2.66 s] Starting @autorest/core from C:\Users\[User]\.autorest\@autorestcore@3.7.6\nodemodules\@autorest\core
SourceMapConsumer.initialize is a no-op when running in node.js
info    |    Loading AutoRest core      'C:\Users\[User]\.autorest\@autorestcore@3.7.6\nodemodules\@autorest\core\dist' (3.7.6)
verbose | [1.32 s] No configuration found at 'file:///C:/Sources/packages/'.
verbose | [1.33 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/default-configuration.md'
verbose | [1.40 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/inspect.md'
verbose | [1.41 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/directives.md'
verbose | [1.45 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/pipeline.md'
verbose | [1.50 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/loader-openapi.md'
verbose | [1.52 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/miscellaneous.md'
verbose | [1.54 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-powershell.md'
verbose | [1.57 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-azureresourceschema.md'
verbose | [1.60 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-csharp.md'
verbose | [1.64 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-go.md'
verbose | [1.66 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-java.md'
verbose | [1.69 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-nodejs.md'
verbose | [1.74 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-php.md'
verbose | [1.77 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-python.md'
verbose | [1.80 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-ruby.md'
verbose | [1.83 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-typescript.md'
verbose | [1.88 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-validators.md'
verbose | [1.92 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-az.md'
verbose | [1.95 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-terraform.md'
verbose | [1.99 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-azure-functions.md'
verbose | [2.01 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/graphs.md'
verbose | [2.04 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/help-configuration.md'
error   | [Exception] No input files provided.

Use --help to get help information or see https://aka.ms/autorest/cli for additional documentation
error   |   Error: [Exception] No input files provided.

Use --help to get help information or see https://aka.ms/autorest/cli for additional documentation
debug   | [2.15 s] Shutting Down.
debug   | [2.15 s] Exiting.

And them trying to generate some code :

autorest --input-file=https://petstore3.swagger.io/api/v3/openapi.json --verbose --debug
SourceMapConsumer.initialize is a no-op when running in node.js
AutoRest code generation utility [cli version: 3.5.2-ci.69cb5d7a6; node: v14.3.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
debug   | [1.12 s] Network Enabled: true
debug   | [1.78 s] The most recent installed version is 3.7.6
debug   | [1.78 s] requesting current version '3.7.6'
debug   | [1.79 s] Starting @autorest/core from C:\Users\[User]\.autorest\@autorestcore@3.7.6\nodemodules\@autorest\core
SourceMapConsumer.initialize is a no-op when running in node.js
info    |    Loading AutoRest core      'C:\Users\[User]\.autorest\@autorestcore@3.7.6\nodemodules\@autorest\core\dist' (3.7.6)
verbose | [1.53 s] No configuration found at 'file:///C:/Sources/packages/'.
verbose | [1.54 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/default-configuration.md'
verbose | [1.58 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/inspect.md'
verbose | [1.59 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/directives.md'
verbose | [1.64 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/pipeline.md'
verbose | [1.67 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/loader-openapi.md'
verbose | [1.68 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/miscellaneous.md'
verbose | [1.72 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-powershell.md'
verbose | [1.75 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-azureresourceschema.md'
verbose | [1.77 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-csharp.md'
verbose | [1.81 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-go.md'
verbose | [1.83 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-java.md'
verbose | [1.86 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-nodejs.md'
verbose | [1.89 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-php.md'
verbose | [1.92 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-python.md'
verbose | [1.94 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-ruby.md'
verbose | [1.97 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-typescript.md'
verbose | [2.01 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-validators.md'
verbose | [2.06 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-az.md'
verbose | [2.10 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-terraform.md'
verbose | [2.13 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/plugin-azure-functions.md'
verbose | [2.17 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/graphs.md'
verbose | [2.19 s]    Including configuration file 'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/help-configuration.md'
debug   | [2.41 s] swagger-document/loader-swagger - START inputs = 0
debug   | [2.42 s] openapi-document/loader-openapi - START inputs = 0
debug   | [2.42 s] pipeline-emitter - START inputs = 0
debug   | [2.42 s] configuration-emitter - START inputs = 0
debug   | [2.42 s] pipeline-emitter - END [0.03 s][58 MB]
debug   | [2.42 s] configuration-emitter - END [0.03 s][58 MB]
debug   | [2.49 s] azure:datastore:error Unexpected error trying to read file Error: https://petstore3.swagger.io/api/v3/openapi.json is not found: getaddrinfo ENOTFOUND petstore3.swagger.io
C:\Users\[User]\.autorest\@autorest_core@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js - FAILURE Error: Could not read 'https://petstore3.swagger.io/api/v3/openapi.json'.
    at ReadThroughDataSource.readStrict (C:\Users\[User]\.autorest\@autorest_core@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js:14615:19)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at loadSwaggerFile (C:\Users\[User]\.autorest\@autorest_core@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js:3240:18)
    at loadSwaggerFiles (C:\Users\[User]\.autorest\@autorest_core@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js:3231:29)
    at C:\Users\[User]\.autorest\@autorest_core@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js:3254:26
    at ScheduleNode (C:\Users\[User]\.autorest\@autorest_core@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js:1317:33)
C:\Users\[User]\.autorest\@autorest_core@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js - FAILURE Error: Could not read 'https://petstore3.swagger.io/api/v3/openapi.json'.
    at ReadThroughDataSource.readStrict (C:\Users\[User]\.autorest\@autorest_core@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js:14615:19)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at loadOpenAPIFile (C:\Users\[User]\.autorest\@autorest_core@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js:3183:20)
    at loadOpenAPIFiles (C:\Users\[User]\.autorest\@autorest_core@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js:3174:29)
    at C:\Users\[User]\.autorest\@autorest_core@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js:3205:26
    at ScheduleNode (C:\Users\[User]\.autorest\@autorest_core@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-core_ts.js:1317:33)
fatal   | Process() cancelled due to exception : Could not read 'https://petstore3.swagger.io/api/v3/openapi.json'. / Error: Could not read 'https://petstore3.swagger.io/api/v3/openapi.json'.
    at ReadThroughDataSource.readStrict (C:\Users\[User]\.autorest\@autorestcore@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-corets.js:14615:19)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at loadSwaggerFile (C:\Users\[User]\.autorest\@autorestcore@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-corets.js:3240:18)
    at loadSwaggerFiles (C:\Users\[User]\.autorest\@autorestcore@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-corets.js:3231:29)
    at C:\Users\[User]\.autorest\@autorestcore@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-corets.js:3254:26
    at ScheduleNode (C:\Users\[User]\.autorest\@autorestcore@3.7.6\node_modules\@autorest\core\dist\src_lib_autorest-corets.js:1317:33)
error   |   Error: Could not read 'https://petstore3.swagger.io/api/v3/openapi.json'.
debug   | [2.50 s] Shutting Down.
debug   | [2.50 s] Exiting.

Looks like a problem getting the contract. I downloaded that to a file and them i had some issue servers.url field:

fatal   | Process() cancelled due to exception : Server url '/api/v3' cannot be resolved to an absolute url. Update to be an absolute url or load OpenAPI document from host to automatically resolve the url relative to it. / Error: Server url '/api/v3' cannot be resolved to an absolute url. Update to be an absolute url or load OpenAPI document from host to automatically resolve the url relative to it.
    at MultiAPIMerger.resolveServerUrl 
    (...)
error   |   Error: Server url '/api/v3' cannot be resolved to an absolute url. Update to be an absolute url or load OpenAPI document from host to automatically resolve the url relative to it.

So, i changed the contract a bit to include the absolute url, and finally i had :

autorest --input-file=.\pet.json --verbose --debug --output-folder=./Generated
SourceMapConsumer.initialize is a no-op when running in node.js
AutoRest code generation utility [cli version: 3.5.2-ci.69cb5d7a6; node: v14.3.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
debug   | [1.07 s] Network Enabled: true
debug   | [1.15 s] The most recent installed version is 3.7.6
debug   | [1.15 s] requesting current version '3.7.6'
debug   | [1.16 s] Starting @autorest/core from C:\Users\[User]\.autorest\@autorestcore@3.7.6\nodemodules\@autorest\core
SourceMapConsumer.initialize is a no-op when running in node.js
info    |    Loading AutoRest core      'C:\Users\[User]\.autorest\@autorestcore@3.7.6\nodemodules\@autorest\core\dist' (3.7.6)
verbose | [1.20 s] No configuration found at 'file:///C:/Users/[User]/Desktop/autorestTest/'.
verbose | [1.21 s]    Including configuration file (...)
'file:///C:/Users/[User]/.autorest/@autorestcore@3.7.6/nodemodules/@autorest/core/dist/resources/help-configuration.md'
debug   | [1.90 s] swagger-document/loader-swagger - START inputs = 0
debug   | [1.91 s] openapi-document/loader-openapi - START inputs = 0
debug   | [1.91 s] pipeline-emitter - START inputs = 0
debug   | [1.91 s] configuration-emitter - START inputs = 0
debug   | [1.91 s] pipeline-emitter - END [0.02 s][58 MB]
debug   | [1.91 s] configuration-emitter - END [0.02 s][58 MB]
verbose | [1.95 s] Reading OpenAPI 3.0 file file:///C:/Users/[User]/Desktop/autorestTest/pet.json
debug   | [1.96 s] swagger-document/loader-swagger - END [0.06 s][59 MB]
debug   | [1.99 s] openapi-document/loader-openapi - END [0.1 s][68 MB]
debug   | [1.99 s] swagger-document/individual/transform - SKIPPING
debug   | [1.99 s] swagger-document/individual/schema-validator-swagger - SKIPPING
debug   | [1.99 s] swagger-document/identity - SKIPPING
debug   | [1.99 s] swagger-document/individual/identity - SKIPPING
debug   | [2.00 s] openapi-document/openapi-document-converter - SKIPPING
debug   | [2.00 s] openapi-document/individual/transform - START inputs = 1
debug   | [2.01 s] openapi-document/individual/transform - END [0.01 s][68 MB]
debug   | [2.01 s] openapi-document/individual/schema-validator-openapi - START inputs = 1
debug   | [2.28 s] openapi-document/individual/schema-validator-openapi - END [0.26 s][68 MB]
debug   | [2.28 s] openapi-document/individual/identity - START inputs = 1
debug   | [2.29 s] openapi-document/individual/identity - END [0 s][68 MB]
debug   | [2.29 s] openapi-document/transform - START inputs = 1
debug   | [2.29 s] openapi-document/transform - END [0 s][68 MB]
debug   | [2.29 s] openapi-document/semantic-validator - START inputs = 1
debug   | [2.29 s] openapi-document/semantic-validator - END [0 s][69 MB]
debug   | [2.29 s] openapi-document/allof-cleaner - START inputs = 1
debug   | [2.31 s] openapi-document/allof-cleaner - END [0.01 s][69 MB]
debug   | [2.31 s] openapi-document/tree-shaker - START inputs = 1
debug   | [2.36 s] openapi-document/tree-shaker - END [0.05 s][65 MB]
debug   | [2.36 s] openapi-document/multi-api-merger - START inputs = 1
debug   | [2.44 s] openapi-document/multi-api-merger - END [0.07 s][65 MB]
debug   | [2.44 s] openapi-document/components-cleaner - START inputs = 1
debug   | [2.49 s] openapi-document/components-cleaner - END [0.04 s][75 MB]
debug   | [2.49 s] openapi-document/component-modifiers - START inputs = 1
debug   | [2.50 s] openapi-document/component-modifiers - END [0.01 s][77 MB]
debug   | [2.50 s] openapi-document/api-version-parameter-handler - START inputs = 1
debug   | [2.50 s] openapi-document/api-version-parameter-handler - END [0 s][77 MB]
debug   | [2.50 s] openapi-document/profile-filter - START inputs = 1
debug   | [2.50 s] openapi-document/profile-filter - END [0 s][77 MB]
debug   | [2.50 s] openapi-document/model-deduplicator - START inputs = 1
debug   | [2.57 s] openapi-document/model-deduplicator - END [0.06 s][66 MB]
debug   | [2.57 s] openapi-document/compose - START inputs = 1
debug   | [2.61 s] openapi-document/compose - END [0.04 s][80 MB]
debug   | [2.61 s] openapi-document/identity - START inputs = 1
debug   | [2.61 s] openapi-document/identity - END [0 s][80 MB]
debug   | [2.62 s] openapi-document/emitter - START inputs = 1
debug   | [2.62 s] openapi-document/emitter - END [0 s][80 MB]
debug   | [2.62 s] Clearing Folders.
debug   | [2.62 s] Writing Outputs.
info    | Generation Complete
debug   | [2.63 s] Shutting Down.
debug   | [2.64 s] Exiting

After last one, there is no generated code anyhere unfortunately.

timotheeguerin commented 2 years ago

sorry, lost track of this issue, I think the last issue you are having is you don't seem to be loading any generator. See here for the availables one https://github.com/Azure/autorest/tree/main/docs/generate#language-flags (e.g. --typescript for js/ts sdk)

JoaoCampos07 commented 2 years ago

@timotheeguerin , unfortunately i switch pc and i lost your previous build. I cannot get it from your link anymore also. I used the last autorest version and after setting te HTTPS_PROXY and HTTP_PROXY variables, running the console in Admin, i am having :/ :

PS C:\Users\[User]\AppData\Roaming\npm> .\autorest.cmd --debug --verbose
AutoRest code generation utility [cli version: 3.6.0; node: v14.3.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
debug   | [0.46 s] Network Enabled: true
debug   | [3.64 s] No @autorest/core (or @microsoft.azure/autorest-core) is installed.
debug   | [3.64 s] latest-installed was not satisfied directly by a previous installation.
Failure:
Error: Package '@autorest/core' - '3.8.1' failed to install:
  Failed to install package 'https://registry.npmjs.org/@autorest/core/-/core-3.8.1.tgz' -- Error: Process Failed.

Installation logs:

warning: package.json: No license field
info: No lockfile found.
info:  Step: Resolving packages
error: An unexpected error occurred: "https://registry.npmjs.org/@autorest/core/-/core-3.8.1.tgz: self signed certificate in certificate chain".
info: If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\[User]\\.autorest\\@autorest_core@3.8.1\\yarn-error.log".
info: Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Error: Package '@autorest/core' - '3.8.1' failed to install:
  Failed to install package 'https://registry.npmjs.org/@autorest/core/-/core-3.8.1.tgz' -- Error: Process Failed.

Installation logs:

warning: package.json: No license field
info: No lockfile found.
info:  Step: Resolving packages
error: An unexpected error occurred: "https://registry.npmjs.org/@autorest/core/-/core-3.8.1.tgz: self signed certificate in certificate chain".
info: If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\[User]\\.autorest\\@autorest_core@3.8.1\\yarn-error.log".
info: Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

    at ExtensionManager.installPackage (C:\Users\[User]\AppData\Roaming\npm\node_modules\autorest\dist\src_autorest-as-a-service_ts.js:10312:23)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at selectVersion (C:\Users\[User]\AppData\Roaming\npm\node_modules\autorest\dist\src_autorest-as-a-service_ts.js:405:31)
    at resolveCoreVersion (C:\Users\[User]\AppData\Roaming\npm\node_modules\autorest\dist\src_autorest-as-a-service_ts.js:578:29)
    at main (C:\Users\[User]\AppData\Roaming\npm\node_modules\autorest\dist\app.js:98:33)

I had similar error when installing autorest with NPM, before i put the variable strict-ssl=false in NPM Config

Also there is no logs in : C:\Users\[User]\.autorest\@autorest_core@3.8.1\yarn-error.log Actually there is nothing in that folder.

I wonder if it would be possible to create a Portable version like : Autorest.Windows.Portable.2.0.4222. I tried but without sucess.

timotheeguerin commented 2 years ago

Could you try having the equivalent config in yarn yarn config set "strict-ssl" false -g as autorest use yarn instead of npm to install the packages. Add making sure that yarn add @autorest/core is working fine.

It is unfortunately not really possible to create those portable version anymore due to how all the generators are separate extensions and autorest is not a monolith containing everything.

JoaoCampos07 commented 2 years ago

Yeap. That worked :

PS C:\Users\[User]\AppData\Roaming\npm> yarn config set "strict-ssl" false -g

    yarn config v1.22.18
    success Set "strict-ssl" to "false".
    Done in 0.04s

Had some small issue with absolute path described in https://petstore3.swagger.io/api/v3/openapi.json. But i think is irrelevant : PS C:\Users[User]\AppData\Roaming\npm> ./autorest.cmd --input-file="C:\Users[User]\Desktop\Test\swagger.json" --csharp --output="C:\Users[User]\Desktop\Test" AutoRest code generation utility [cli version: 3.6.0; node: v14.3.0] (C) 2018 Microsoft Corporation. https://aka.ms/autorest info | AutoRest core version selected from configuration: ^3.7.0.

There is a new version of AutoRest available (3.6.1).
 > You can install the newer version with with npm install -g autorest@latest

info    |    Loading AutoRest core      'C:\Users\[User]\.autorest\@autorestcore@3.8.2\nodemodules\@autorest\core\dist' (3.8.2)
info    |    Installing AutoRest extension '@autorest/csharp' (latest -> 3.0.0-beta.20220322.3)
installing... [========================================] 100% | 2/2
info    |    Installed AutoRest extension '@autorest/csharp' (latest->3.0.0-beta.20220322.3)
info    |    Installing AutoRest extension '@autorest/modelerfour' (4.22.3 -> 4.22.3)
installing... [========================================] 100% | 2/2
info    |    Installed AutoRest extension '@autorest/modelerfour' (4.22.3->4.22.3)
fatal   | Process() cancelled due to failure
error   |   Error: Server url '/api/v3' cannot be resolved to an absolute url. Update to be an absolute url or load OpenAPI document from host to automatically resolve the url relative to it.
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

`` Changing the absolute path from "/api/v3" to "https://petstore3.swagger.io/api/v3" :

    PS C:\Users\[User]\AppData\Roaming\npm> ./autorest.cmd --input-file="C:\Users\[User]\Desktop\Test\swagger.json" --csharp --output-folder="C:\Users\[User]\Desktop\Test"
    AutoRest code generation utility [cli version: 3.6.0; node: v14.3.0]
    (C) 2018 Microsoft Corporation.
    https://aka.ms/autorest
    info    | AutoRest core version selected from configuration: ^3.7.0.

    There is a new version of AutoRest available (3.6.1).
     > You can install the newer version with with npm install -g autorest@latest

    info    |    Loading AutoRest core      'C:\Users\[User]\.autorest\@autorestcore@3.8.2\nodemodules\@autorest\core\dist' (3.8.2)
    info    |    Loading AutoRest extension '@autorest/csharp' (latest->3.0.0-beta.20220322.3)
    info    |    Loading AutoRest extension '@autorest/modelerfour' (4.22.3->4.22.3)
    warning | PreCheck/BinarySchema | 'The schema paths·11mtveo·pet-petid-uploadimage·post·requestbody·content·application-octet_stream·schema with 'type: string', format: binary' will be treated as a binary blob for binary media types.
        - file:///C:/Users/[User]/Desktop/Test/swagger.json:470:8
    warning | PreCheck/CheckDuplicateSchemas | Checking for duplicate schemas, this could take a (long) while.  Run with --verbose for more detail.
    info    | Autorest completed in 4.49s. 21 files generated.  

Thanks very much, @timotheeguerin for the support, this one took a bit to solve :)