Skip to content

Conversation

travishathaway
Copy link
Contributor

@travishathaway travishathaway commented Jun 11, 2025

Description

Closes: #14922

This changes the error message when inserting duplicate prefix records to something that could actually fix the situation rather than suggestion users create an issue on our GitHub project.

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@travishathaway travishathaway requested a review from a team as a code owner June 11, 2025 07:22
@travishathaway travishathaway changed the title change error message when inserting duplicate prefix records Change error message when inserting duplicate prefix records Jun 11, 2025
@github-project-automation github-project-automation bot moved this to 🆕 New in 🔎 Review Jun 11, 2025
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Jun 11, 2025
Copy link

codspeed-hq bot commented Jun 11, 2025

CodSpeed Performance Report

Merging #14927 will not alter performance

Comparing travishathaway:issue-14922 (4f079c8) with main (fbeec0b)

Summary

✅ 21 untouched benchmarks

Co-authored-by: jaimergp <jaimergp@users.noreply.github.com>
@travishathaway travishathaway requested a review from jaimergp June 11, 2025 08:20
if prefix_record.name in self._prefix_records:
raise CondaError(
f"Prefix record insertion error: a record with name {prefix_record.name} already exists "
"in the prefix. This can often be resolved by running `conda clean --all`. "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is conda clean --all actually fixing this? I don't see anything in the code where it cleans duplicates in conda-meta 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a chance that conda clean --all removes some of the orphaned prefix records? I looked through the code myself, but wasn't able to actually verify this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be verified thoroughly if we are going to include it in the error message.

@jaimergp
Copy link
Contributor

Do we know why this happens? 🤔 It shouldn't happen under normal conditions!

@travishathaway
Copy link
Contributor Author

@jaimergp,

Yes, this is a weird issue. I was trying to manually recreate the conditions under which this happens today and had to do the following:

  1. Create an environment with ca-certificates installed into it: conda create --name test ca-certificates
  2. Copy the ca-certificates JSON file from the conda-meta directory to a temporary spot (i.e. /tmp/)
  3. Remove ca-certificates from the environment with conda remove --name test ca-certificates to make sure it's blank
  4. Install something that depends on ca-certificates like python with conda install --name test python (do not confirm installation yet!)
  5. While the package plan is being displayed, sneak in the ca-certificates JSON file we copied to /tmp with cp /tmp/ca-certificates-2025.6.15-hbd8a1cb_0.json ~/miniconda3/envs/test/conda-meta
  6. Hit confirm installation.
  7. Boom 💥 (should see the error about the duplicate prefix data record).

Subsequent install works because the installation routine is able to tell that ca-certificates JSON file is there. Obviously, this environment is now broken because that package isn't actually installed.

Anyways, I think these errors probably resolve themselves. Adding this error message does give the user a feeling like they are solving it though, which I think is important psychologically. Regardless, it keeps them from adding more duplicate issues to this GitHub project.

I get that this isn't ideal. Do you think we should instead attempt to clobber what currently exists in the PrefixData._prefix_records? This might cause other problems though 🤷‍♂️

@jaimergp
Copy link
Contributor

I get that this isn't ideal. Do you think we should instead attempt to clobber what currently exists in the PrefixData._prefix_records? This might cause other problems though 🤷‍♂️

Not sure. I was mostly trying to understand whether we had a reliable reproducer that didn't depend on race conditions. If this happens often enough that users are reporting it that much that we have duplicates, there must be a situation that introduces the issue and we should be aware of it. My concern was that we might be papering over the actual cause by saying now "don't report it, you are fine", and I'd rather understand why it happens and fix it. I agree that this is a situation that "shouldn't happen" so I'm puzzled of the high rate of occurrence in the issue tracker. Anyway, no extra actions needed from my side.

@travishathaway
Copy link
Contributor Author

travishathaway commented Jun 17, 2025

@jaimergp,

I think the high occurrence happens because we tell people to report this error in the exception message!

It gets reported so seldomly that I think we don't really have to worry about this being a huge problem. By seldom, I mean about twice a year.

@jaimergp
Copy link
Contributor

Ah ok, I had assumed a bigger incidence. We are good then!

Copy link
Member

@jezdez jezdez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd file this under improvement instead of docs, since it ultimately is about making sure users understand how to resolve the problem when using the tool. Not feeling strongly, though, let's just make sure the PR number is mentioned in the news item.

Co-authored-by: Jannis Leidel <jannis@leidel.info>
@travishathaway travishathaway enabled auto-merge (squash) June 18, 2025 09:43
@travishathaway travishathaway merged commit ea5728d into conda:main Jun 18, 2025
75 checks passed
@github-project-automation github-project-automation bot moved this from ✅ Approved to 🏁 Done in 🔎 Review Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Archived in project
6 participants