-
Notifications
You must be signed in to change notification settings - Fork 985
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
Conan CLI: Add option to conan remove to just skip without error if package does not exist #16221
Comments
Hi @vincesp This doesn't look like a docs issue, but a client one. Moving it to the Conan client repo. |
$ conan remove zlib/1.4
Remove summary:
Local Cache This works without failing, not sure what you mean (zlib/1.4 doesn't exist yet)
It is not clear the background. Why would you remove a package if it exists? The whole purpose of using Conan is not having to rebuild something that already exists, this flow shouldn't be necessary in the first place. |
Hi @vincesp Any further feedback here? |
In a build pipeline, we want to clean certain package to force their rebuild. But we don't want to empty the local cache completely, as this would defeat the purpose of a cache. As we have many agents in our pool, we cannot be sure which packages have been built on which agent before. |
But rebuilding a package that exists in the server is considered a pipeline or model error. Anything that produces a new It is also not clear what is the error:
works well, it doesn't fail, even if |
PS> conan --version
Conan version 2.4.1
PS> conan remove -c zlib
ERROR: Recipe 'zlib' not found
PS> echo $LASTEXITCODE
1 So in our pipelines, we have the following code: - script: conan remove -c ${{ parameters.packageName }} || true
displayName: Conan Remove ${{ parameters.packageName }} (POSIX)
condition: or(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.OS'], 'Darwin'))
- script: conan remove -c ${{ parameters.packageName }} || exit /b 0
displayName: Conan Remove ${{ parameters.packageName }} (Windows)
condition: eq(variables['Agent.OS'], 'Windows_NT') |
Ok, I see what you mean. I think this is due to some legacy behavior that couldn't be fully removed in Conan 2, when using just a package name. The recommended approach for this is using patterns:
will achieve the behavior that you want, that is, remove all |
It seems to work. |
Ok, great, thanks for the feedback. I have checked the docs, and I cannot find occurrences of this, but the I have also checked the code and the use cases. There might be users relying on this as a feature, for example if doing an operation (upload, remove) after some package has been created, so it is guaranteed to be there, and if it is not there, they are happy to get an error. So most likely it is not worth the risk to try to change this behavior and make it not raise an error for the usage without a pattern I am closing this as solved, no option is necessary as the pattern syntax achieve that, but please re-open or create new tickets for any further question or issue. Thanks for the feedback! |
Update: Even In order for our pipelines to use the information from Artifactory, not from previous (potentially failed) local build attempts, we had to add the following to our pipelines: - script: |
rm -rf $HOME/.conan2/p
rm $HOME/.conan2/.conan.db
displayName: Clean Conan cache (POSIX)
condition: or(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.OS'], 'Darwin'))
- script: |
rmdir /s /q %USERPROFILE%\.conan2\p
del %USERPROFILE%\.conan2\.conan.db
displayName: Clean Conan cache (Windows_NT)
condition: eq(variables['Agent.OS'], 'Windows_NT') |
This removes all the packages from the cache, it won't remove configuration files or other temporary files.
Local build attempts in the Conan cache that didn't succeed are unreachable, they are in folders generated with a In any case, for CI it is recommended that every job will use a new, blank |
We regularly run into a situation where the build agent reports "can't find a 'xyz/1.2.3' package binary 'hash' for the configuration: …" while the exact hash is indeed available on our Artifactory server, but under a different parent hash. If conan already has the first part of the hash available locally from a previous failed build attempt (hence with an incomplete set of configurations), then it won't go back to the server and check. |
The "parent hash" is the recipe revision, it is associated with recipe and source changes.
I am not sure about this. The A different story is if it is resolving against a server repo that got uploaded a new recipe-revision with "incomplete binaries", lets try to clarify this case just in case:
This way it is impossible to have an incomplete set of configurations in the server repo. |
The
conan remove
command is missing an option to skip without returning an error if the package to be removed does not exist.Background: It is really cumbersome to build an Azure pipeline that detects if a package exists and only runs the
conan remove
task if it does. If using a pool with numerous agents, we cannot be sure in which state the conan cache on every single agent is, so we need to clean the cache just to be sure. AddingcontinueOnError: true
to the task only helps partially, as the pipeline run will show "completed with warnings" which does not reflect the actual outcome properly.The text was updated successfully, but these errors were encountered: