Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider moving downloaded jar cache directory outside of the package directory #666

Open
segevfiner opened this issue Oct 6, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@segevfiner
Copy link

🐛 Bug Report:

Describe the bug

Due to storing the downloaded jar inside <package>/versions, they will get wiped out whenever openapi-generator-cli gets reinstalled, this can cause a lot of unnecessary slow redownloads of the jar and quite a bit of unnecessary load on the downloads server.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Run openapi-generator-cli
  2. Make some dependencies change which will cause the package to be reinstalled. (Depends on packaging tool, yarn 1.x seems to do so for every change)
  3. The jars in <pacakage>/versions will be wiped out.

Expected behavior

The jars to remain, so they only have to ever be downloaded once per host.

Screenshots

If applicable, add screenshots to help explain your problem.

Operation System (please complete the following information):

  • OS: macOS
  • Version 12.6

Package System (please complete the following information):

  • Yarn Version 1.22.19

Additional context

There are standard paths for caching such files. Be it a folder under the npm-cache or ${XDG_CACHE_HOME:-$HOME/.cache}

@segevfiner segevfiner added the bug Something isn't working label Oct 6, 2022
@segevfiner segevfiner changed the title [BUG] Consider moving downloaded jar cache directory outside of the package directory Consider moving downloaded jar cache directory outside of the package directory Oct 7, 2022
@jayvdb
Copy link

jayvdb commented Oct 17, 2022

Note this will also help if openapi-generator-cli is installed as a system tool, and then run by a user, in which case the user doesnt have permission.
i.e.

$ openapi-generator-cli  generate ...
Download 6.2.0 ...
Download failed, because of: "EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@openapitools/openapi-generator-cli/versions'"
Download 6.2.0 ...
Download failed, because of: "EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@openapitools/openapi-generator-cli/versions'"
/usr/local/lib/node_modules/@openapitools/openapi-generator-cli/main.js:685
                error ? reject(new Error(stderr)) : resolve(stdout);
                               ^

Error: Error: Unable to access jarfile /usr/local/lib/node_modules/@openapitools/openapi-generator-cli/versions/undefined.jar

    at /usr/local/lib/node_modules/@openapitools/openapi-generator-cli/main.js:685:32
    at ChildProcess.exithandler (node:child_process:420:5)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1091:16)
    at Socket.<anonymous> (node:internal/child_process:449:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:313:12)

Node.js v18.10.0

@hassmal
Copy link

hassmal commented Mar 5, 2024

This is already possible with the config of storageDir. Here is our json file, works like a charm:

{
  "$schema": "../../node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "7.2.0",
    "storageDir": "./some/path",
    "generators": {
      "web": {
        "generatorName": "typescript-angular",
        "inputSpec": "./src/spec-v1.json",
        "output": "../../dist/apps/api-definition/web",
        "config": "./typescript-angular-config.yaml"
      }
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants