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

Support for changing the cache location #11263

Open
dhess opened this issue Aug 1, 2021 · 0 comments
Open

Support for changing the cache location #11263

dhess opened this issue Aug 1, 2021 · 0 comments

Comments

@dhess
Copy link

dhess commented Aug 1, 2021

Is your proposal related to a problem?

When using create-react-app with Nix-based packagers such as https://github.com/tweag/npmlock2nix, usually these packagers will, by default, createnode_modules as a symlink to the Nix store, which is read-only. Because npm run build tries to write node_modules/.cache, these tools are incompatible with create-react-app (or, more specifically, react-scripts) without some workarounds.

Describe the solution you'd like

I would like to be able to override the create-react-app cache location — for example, to be able to set it to <PROJECT_ROOT>/.cache.

Describe alternatives you've considered

At least some of these Nix-based packagers support copying the Nix store node_modules contents to the project root directory, rather than symlinking it. This works fine, but is a pain to manage, and it's easy to get something wrong; e.g., to have a stale node_modules around after adding, removing, or updating a dependency. The aforementioned https://github.com/tweag/npmlock2nix project takes pains to recreate the node_modules symlink when a dependency is changed, but not a copied node_modules subdirectory.

@dhess dhess changed the title Change cache location Support for changing the cache location Aug 1, 2021
Ma27 added a commit to Ma27/nixpkgs that referenced this issue Oct 1, 2021
ChangeLog: https://github.com/gotify/server/releases/tag/v2.0.22
ChangeLog: https://github.com/gotify/server/releases/tag/v2.0.23
ChangeLog: https://github.com/gotify/server/releases/tag/v2.1.0

While the update only contains a few small features and a few bugfixes,
the change was rather messy for us unfortunately:

* It seems as if `npmjs.org`-packages can't be transformed into
  `pkg___pkg-x.y.z` for Yarn's offline cache. The name
  `https___registry.npmjs.org_caniuse_lite___caniuse_lite_1.0.30001237.tgz`
  isn't the problem because when changing the URL "parser" of `yarn2nix`
  to transform this into `org_caniuse_lite___caniuse_lite_1.0.30001237`
  this doesn't help either.

  Instead, I derived the fix from `gitlab`[1] where `yarn.lock` gets
  patched to make sure that it detects the package in the offline-cache
  properly.

* The frontend is now built with `react-scripts`. This is a problem for
  us because it tries to write into `node_modules/.cache` even though
  `node_modules` is a store-path in the context of `yarn2nix`[2].

  The change isn't pretty, but solves the issue for us.

[1] https://github.com/NixOS/nixpkgs/blob/f007b794c758000a275b00dd0695d2fb155195f0/pkgs/applications/version-management/gitlab/default.nix#L85-L86
[2] facebook/create-react-app#11263
alexdavid added a commit to garnix-io/garn that referenced this issue Oct 11, 2023
Looks like there really isn't any great solution for using CRA with nix.
I think we should consider just removing this example

facebook/create-react-app#11263
alexdavid added a commit to garnix-io/garn that referenced this issue Oct 12, 2023
Looks like there really isn't any great solution for using CRA with nix.
I think we should consider just removing this example

facebook/create-react-app#11263
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant