-
Notifications
You must be signed in to change notification settings - Fork 587
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
[rush] PNPM doesn't use global store #1414
Comments
Rush puts its store inside the repo folder to make sure everything an install/build job creates on disk can be cleaned up by simply deleting the repo folder. This is important for ensuring that CI machines that don't get wiped between builds don't run out of disk space. I totally understand your scenario, though. It seems like making this behavior different for the local dev scenario makes sense. We'll need to design this, though. @Js-Brecht - From a user's perspective, how would you expect this to be configured? |
Ah, I understand the reasoning now. @iclanton To me, it would make sense to have a
I only included number 3 to remain consistent with pnpm, which allows you to specify your own store location on the command line. Could let it use the rush |
I also encountered this. |
FWIW, I wound up hacking out the line in |
It should be fine. Would someone want to implement this as a configurable option? I feel like it's a pretty easy work item. We just need to decide how it is specified. For example as an environment variable or as a rush.json setting. |
@octogonz I wouldn't mind, when I have a little free time in the next couple days. I still like the idea of using a |
Could be a property under Property could be
|
Some more thoughts about the design:
|
Is the distinction necessary, if it's Or do you mean put
Works for me. I assume
I assume that a cli parameter/environment variable will override the store path, no matter if While on the subject of paths, I have one question: Where should relative paths be relative to? I assume the default, or user-defined, So, considering workspace located at
Using
Number 1 sounds like the best option to me. If the user put the store path in the
Wouldn't |
I tend to prefer names like But I don't feel super strongly about this; it's just something to consider.
I was thinking something maybe like this: "pnpmOptions": {
/**
* Specifies the location of the PNPM store. There are three possible values:
*
* - "local" - use the "common/temp/pnpm-store" folder in the current repo
* - "global" - use PNPM's global store, which has the benefit of being shared
* across multiple repo folders, but the disadvantage of less isolation for builds
* (e.g. bugs or incompatibilities when two repos use different releases of PNPM)
* - "path" - use the location specified by "pnpmStorePath"
*
* The default value is "local".
*/
"pnpmStore": "local",
/**
* This setting is only used when the "pnpmStore" setting is "path". It specifies a custom
* path for the PNPM store, resolved relative to the root folder containing rush.json.
*
* It is not recommended to store an absolute path in the rush.json file.
* For machine-specific overrides, use the RUSH_PNPM_STORE_PATH environment
* variable instead.
*/
"pnpmStorePath": "common/temp/something-else"
}
I agree that people would generally assume it's resolved relative to the If you believe that potentially people would legitimately want more one than base folder to resolve against, we do have a convention of supporting tokens in paths. With this design you could do
That seems reasonable.
I was referring to this issue:
Also, I believe |
I noticed that already PNPM writes the store choice into a file: node_modules/.modules.yaml hoistedAliases: {}
included:
dependencies: true
devDependencies: true
optionalDependencies: true
independentLeaves: false
layoutVersion: 2
packageManager: pnpm@3.5.0
pendingBuilds: []
registries:
default: 'https://registry.npmjs.org/'
shamefullyFlatten: false
skipped: []
store: 'D:\.pnpm-store\2' # <----------------- Maybe it's safe for Rush to rely on that. |
This does feel more natural, instead of trying to shift context when you're setting up the store path. It shouldn't be hard to resolve relative to the root, and since it is less of a mental hurdle, that's the route I'll take.
I agree, that does seem a bit much; better to keep it simple. This could always be added down the road if it seems like there's demand for it. If the user decides they want to put their store in the temp folder (and let's say they've explicitly overridden the
I think that it could be handled internally, by setting the Changing store locations using --forceUsing a custom store: PS D:\temp> pnpm install --store .\pnpm-store @types/node
PS D:\temp> cat .\node_modules\.modules.yaml
...
store: 'D:\temp\pnpm-store\2'
... PS D:\temp> fsutil hardlink list .\node_modules\@types\node\package.json
\temp\pnpm-store\2\registry.npmjs.org\@types\node\12.12.8\node_modules\@types\node\package.json
\temp\node_modules\.pnpm\registry.npmjs.org\@types\node\12.12.8\node_modules\@types\node\package.json Changing to a different store errors as expected: PS D:\temp> pnpm install @types/node
ERROR Unexpected store location
The dependencies at "D:\temp\node_modules" are currently linked from the store at "D:\temp\pnpm-store\2".
pnpm now wants to use the store at "D:\.pnpm-store\2" to link dependencies.
If you want to use the new store location, reinstall your dependencies with "pnpm install --force".
You may change the global store location by running "pnpm config set store-dir <dir>".
(This error may happen if the node_modules was installed with a different major version of pnpm) Notice the output here: PS D:\temp> pnpm install @types/node --force
WARN using --force I sure hope you know what you are doing
Recreating D:\temp\node_modules # <------------------------------
Packages: +1
+
Resolving: total 1, reused 0, downloaded 1, done
dependencies:
+ @types/node 12.12.8 PS D:\temp> cat .\node_modules\.modules.yaml
...
store: 'D:\.pnpm-store\2' # Changed from 'D:\temp\pnpm-store\2'
... And then checking the hardlinks again, to make sure they are linked to the correct store. PS D:\temp> fsutil hardlink list .\node_modules\@types\node\package.json
\.pnpm-store\2\registry.npmjs.org\@types\node\12.12.8\node_modules\@types\node\package.json
\temp\node_modules\.pnpm\registry.npmjs.org\@types\node\12.12.8\node_modules\@types\node\package.json Two caveats:
Feels like an executive decision to me, since I'm more inclined to streamline the process. If making it more explicit is what you want, then that is what I'll do. |
I'm fine with keeping it simple. The underlying requirements I had in mind were:
As far as how we satisfy these requirements, you'll probably have a better sense from trying out the commands. I think we have enough to proceed with an implementation. 👍 Let us know if you need any help debugging Rush or figuring out how to add config options. Thanks @Js-Brecht ! |
🎈 This feature was published with Rush 5.21.0. Thanks @Js-Brecht for implementing it! |
Is this a feature or a bug?
- [x] Other: Issue with behavior
Please describe the behavior.
PNPM does not use the global store location. Instead, it creates a new store in
common\temp\pnpm-store
. This essentially defeats one of the best features of PNPM; having a global store saves a lot of time, because packages do not have to be downloaded for every project... As it is now, in order to start a new spfx repo using rush, I have to download 1300+ packages, even though I already have them installed on my system. I understand these packages will be shared with all of the projects in the repo, but that is already the case when using PNPM. Can't Rush manage dependency versions and such across the repo without needing its own store??I have already had to wipe out the
common\temp
directory a couple times just because Rush would throw an error after adding a new project (about not having a dependency key), so each time thatcommon\temp\pnpm-store
gets deleted, I have to download 1300+ packages again.Why does rush need a brand new store, and is there a way to disable that, without hardcoding the store location into the configuration? Hardcoding a path to the store is not an option for me. I work across several different machines, and the store is not always in the same location, since I use Linux and Windows, and the development environment is in different locations/partitions on each machine.
The text was updated successfully, but these errors were encountered: