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

pm-update: respect only_check value #3809

Closed
wants to merge 3 commits into from
Closed

Conversation

mcspr
Copy link
Contributor

@mcspr mcspr commented Jan 23, 2021

Related to the #3770
Don't uninstall the package when user-provided --dry-run / --only-check param (i.e. only_check var is True)

@mcspr
Copy link
Contributor Author

mcspr commented Jan 23, 2021

Oh. There's another invocation, but without the CLI params access. Don't really know what to do then :/

self.cleanup_packages(list(p.packages))

self.cleanup_packages(list(p.packages))

Still, would it make sense to erase only the older packages instead of everything not contained in the platform manifest? atm it purges anything installed manually through platform_packages = ... overrides. (Or, at least take project config into an account when cwd inside of the project directory?)

@ivankravets ivankravets added this to the 5.0.5 milestone Jan 23, 2021
@ivankravets
Copy link
Member

Thanks for the PR. I resolved this issue with ef6e70a

A little bit more clear code. In any case, we should have a solution for #3770

@mcspr
Copy link
Contributor Author

mcspr commented Jan 23, 2021

I was tracking the flow via pdb:

diff --git a/platformio/package/manager/platform.py b/platformio/package/manager/platform.py
index 7626d4d9..0a5ad4a7 100644
--- a/platformio/package/manager/platform.py
+++ b/platformio/package/manager/platform.py
@@ -148,6 +148,8 @@ class PlatformPackageManager(BasePackageManager):  # pylint: disable=too-many-an
             ]
             if any(skip_conds):
                 continue
+            import pdb
+            pdb.set_trace()
             try:
                 pm.uninstall(pkg.metadata.spec)
             except UnknownPackageError:

ef6e70a still does try to delete the toolchain package (which I tried to avoid via the package owner check)

> c:\users\maxim\documents\platformio\platformio-core\platformio\package\manager\platform.py(153)autoremove_packages()
-> try:
(Pdb) pkg
PackageItem <path=C:\Users\maxim\.platformio\packages\toolchain-xtensa metadata=PackageMetaData <type=tool name=toolchain-xtensa version=5.100200.201223 spec={'owner': 'mcspr', 'id': 11401, 'name': 'toolchain-xtensa', 'requirements': None, 'url': None}

@ivankravets
Copy link
Member

See latest commits: https://github.com/platformio/platformio-core/commits/develop

We removed a code for automatic package removal. Now, everyone will personally decide when to run pio system prune command.

We will add a new setting where PIO will check for "unnecessary" packages 1 time per week and will inform users. But, it will never remove these packages automatically.

What do you think about this approach? We have a similar Linux OS for the APT package manager.

See update docs https://docs.platformio.org/en/latest/core/userguide/system/cmd_prune.html

@mcspr
Copy link
Contributor Author

mcspr commented Jan 24, 2021

I would agree, but not a big fan of the reminders though. I wonder if it should match certain thresholds for size / amount of packages / amount of other stuff, but not the periods of time?

Also note that it still wants to remove the custom package:

> pio system prune --dry-run
Dry run mode (do not prune, only show data that will be removed)

Prune cached data:
 - cached API requests
 - cached package downloads
 - temporary data
Space on disk: 494.63MB

Prune unnecessary core packages:
Calculating...
Space on disk: 0B

Prune unnecessary development platform packages:
Calculating...
Package                 Version          Size
----------------------  ---------------  --------
mcspr/toolchain-xtensa  5.100200.201223  215.25MB
Space on disk: 215.25MB

Total reclaimed space: 709.88MB

@ivankravets
Copy link
Member

I wonder if it should match certain thresholds for size / amount of packages / amount of other stuff, but not the periods of time?

Thanks, great idea! How do you think, which threshold is good for default? 1Gb?

Also note that it still wants to remove the custom package:

Yes, it's correct behavior. See "note" https://docs.platformio.org/en/latest/core/userguide/system/cmd_prune.html

@ivankravets
Copy link
Member

So, the default threshold is 1Gb 2c389ae

@mcspr
Copy link
Contributor Author

mcspr commented Jan 24, 2021

May be ok. It depends though on most common use case e.g. judging by the size of the xtensa toolchain + framework it is already 360MB by itself, gccarm + nrf52 is around 460MB, so 1GB would trigger around the time there are around 3 outdated packages (not counting the cached files though).

Yes, it's correct behavior. See "note" https://docs.platformio.org/en/latest/core/userguide/system/cmd_prune.html

I mean, I did indent to install it through the package overrides via the registry download. Should pm auto-create those? I still kind of like the owner check, meaning PIO itself only manages the "platformio" packages, leaving user packages alone. Both registry-downloaded or the things placed into the ~/.platformio/packages manually

@ivankravets
Copy link
Member

We don't manage only platformio packages. It checks packages according to the platform dependencies.

So, if you have a dev-platform that referees to a custom package, PlatformIO will not list it for "prune".

@mcspr
Copy link
Contributor Author

mcspr commented Jan 24, 2021

I mean the packages that came from platformio platform's manifest file, I though those exclusively have owner="platformio"?

From my POV, I'd need to maintain platform fork (and supply updates) + .ini change instead of just the .ini change.

@ivankravets
Copy link
Member

Please share platform.json from your custom dev-platform

@mcspr
Copy link
Contributor Author

mcspr commented Jan 24, 2021

The espurna's .ini just refers to the platform = espressif8266, I don't have the custom platform where the package is used

@ivankravets
Copy link
Member

It seems that we talk about the same but have different in a mind. What is your proposal?

pio system prune keeps the system clean according to the declaration from dev-platforms and PlatformIO Coe. Custom packages, or manually copied to PlatformIO's packages folder are intended for removal. There is a note section that explains how to "hide" custom packages/folders from PlatformIO. You can override https://docs.platformio.org/en/latest/projectconf/section_platformio.html#packages-dir and PlatformIO will not touch your custom packages.

Again, the goal of pio system prune is to keep a PlatformIO system clean.

@mcspr
Copy link
Contributor Author

mcspr commented Jan 24, 2021

I think the gist of my issue so far is that PIO has no way of tracking that package origins when it is installed through the platform_packages = ... directive. Which is understandable, since without a platform there's no way to refer back to it (...unless package manager metadata refers to the .ini file?)

@mcspr
Copy link
Contributor Author

mcspr commented Jan 28, 2021

Not to put this into another loop, but...
Should packages installed through platform_packages = ... be tracked as real packages? i.e., add an attribute to the metadata / auto-create .piokeep / something else? i.e. following the APT metaphor:

Packages which you have installed explicitly via install are also never proposed for automatic removal.

Which is explicitly requested through the .ini declaration

Also sorry for misunderstanding the platform <-> packages relation which created the misunderstanding to begin with... and I'd open another issue, but most of the discussion is already here.

@ivankravets
Copy link
Member

We are going to release PlatformIO Core 5.1 in the next few hours. Please file a new issue at https://github.com/platformio/platformio-core/issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants