puro icon indicating copy to clipboard operation
puro copied to clipboard

Puro unexpectedly modifies PUB_CACHE env variable globally

Open DanTup opened this issue 1 year ago • 4 comments

I was surprised to see paths in C:\Users\danny\.puro\shared\pub_cache showing up in projects where I had not used Puro. It appears that during installation, the PUB_CACHE env variable is changed globally.

This was rather unexpected to me - I don't think tools like this should modify variables that affect projects that aren't using them. It's also unclear to me why Puro can't just use the cache at the default location.

DanTup avatar Jul 03 '24 14:07 DanTup

The reason this was added is because there's unfortunately no other mechanism to tell pub which cache directory to use, particularly when invoked from an IDE (the IntelliJ / vscode plugins bypass the flutter/dart scripts and use the dart sdk directly). Perhaps a mistake in hindsight because it didn't end up fixing issues with pub global activate not being aware of which version of dart they were compiled with, a difficult problem to fix without replacing dart executables in the cache with a custom shim.

pingbird avatar Oct 10 '24 21:10 pingbird

the IntelliJ / vscode plugins bypass the flutter/dart scripts and use the dart sdk directly

For VS Code, I think Puro is already writing a .vscode/settings.json with the SDK path in? If so, it could write dart.env to set the PUB_CACHE for that project too.

If it has to be set globally, it could at least make it clear during installation. I was using Puro just to try to reproduce some bugs and I was surprised to find I had a second Pub Cache (and now I'm using a Windows Dev Drive for better performance, this change would actually move my cache back onto a non-Dev Drive and undo my performance gains).

(that said, it's still not clear to me what moving the folder gains at all.. if it's still a single fixed folder for SDKs, how does the custom location differ from the default?)

DanTup avatar Oct 11 '24 10:10 DanTup

I will be reverting this in the next release, new installs will use the default pub cache

pingbird avatar Dec 05 '24 02:12 pingbird

@pingbird so how active installs should proceed?

feinstein avatar Dec 06 '24 02:12 feinstein

@pingbird since this was closed, could you provide some instructions on how previous installations could be modified to match the new behaviour? Or is this going to be automatic?

feinstein avatar May 15 '25 10:05 feinstein