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

[feature] Add "force" option to conan remote remove #17578

Open
1 task done
Nekto89 opened this issue Jan 15, 2025 · 5 comments · May be fixed by #17514
Open
1 task done

[feature] Add "force" option to conan remote remove #17578

Nekto89 opened this issue Jan 15, 2025 · 5 comments · May be fixed by #17514
Assignees

Comments

@Nekto89
Copy link
Contributor

Nekto89 commented Jan 15, 2025

What is your suggestion?

Hi,

I just had issue with corrupted remotes.json again. After #16089 I'm getting pretty error message but it still requires manual intervention or additional non-conan actions.

I'm only using these commands for working with remotes:

conan remote remove "*"
conan remote add remotename https://.../api/conan/...
conan remote login -p password remotename username

As a workaround I've added additional del /f/s/q "%CONAN_HOME%\remotes.json" right after conan remote remove "*" but I don't really like it. Is it possible to add additional option --force (-f) that will completely remove remotes.json even if it's unreadable JSON? And maybe create new one with zero remotes.

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded memsharded self-assigned this Jan 15, 2025
@memsharded
Copy link
Member

Hi @Nekto89

Thanks for your suggestion.

I'm only using these commands for working with remotes:

I am quite surprised that the remotes.json is still being corrupted by using just these commands. Is it possible that some of this commands are hard-killed often? That would be the only explanation that I can think of that would explain these commands leaving the remotes.json in a bad state, only if their writing to the file is abruptly killed.

The new proposed conan config clean command in #17514 will do the removal of all Conan cache files, including the remotes.json, maybe that would be a reasonable solution? If the remotes.json is corrupted it is possible that there are other configurations files also damaged, and it would be better to have a clean configuration?

@Nekto89
Copy link
Contributor Author

Nekto89 commented Jan 15, 2025

I am quite surprised that the remotes.json is still being corrupted by using just these commands. Is it possible that some of this commands are hard-killed often? That would be the only explanation that I can think of that would explain these commands leaving the remotes.json in a bad state, only if their writing to the file is abruptly killed.

Pipeline can be cancelled at any point of time so there is definitely can be some "bad timing" if changes in this remotes.json aren't transactional.

The new proposed conan config clean command in #17514 will do the removal of all Conan cache files, including the remotes.json, maybe that would be a reasonable solution? If the remotes.json is corrupted it is possible that there are other configurations files also damaged, and it would be better to have a clean configuration?

conan config clean will probably work perfectly in my case. I also rewrite global.conf and cppstd_compat.py (disable it completely) from scratch each time but I am not using conan commands for that so didn't have any similar problems like with remotes.json.

@memsharded
Copy link
Member

Pipeline can be cancelled at any point of time so there is definitely can be some "bad timing" if changes in this remotes.json aren't transactional.

There is a single load() and a single separate save() for file contents, so there is nothing in Conan code that could be corrupting the file contents due to interrupted operation. But it is still possible that the save() operation internally in Python and system code could be killed, stopping the writing of the file without completing or something like that. It is not possible from Conan code to implement this transactionally, as depends on external factors.

conan config clean will probably work perfectly in my case. I also rewrite global.conf and cppstd_compat.py (disable it completely) from scratch each time but I am not using conan commands for that so didn't have any similar problems like with remotes.json.

Sounds perfect, then I am marking this ticket to be closed by the PR, if the conan config clean solution doesn't work, you can always create new tickets. Thanks for the feedback!

@memsharded memsharded linked a pull request Jan 15, 2025 that will close this issue
@Nekto89
Copy link
Contributor Author

Nekto89 commented Jan 16, 2025

It is not possible from Conan code to implement this transactionally, as depends on external factors.

Just an idea. Make save to new temporary file and use os.replace. Documentation states that it's an atomic operation.

@memsharded
Copy link
Member

Just an idea. Make save to new temporary file and use os.replace. Documentation states that it's an atomic operation.

That is a good idea, many thanks. It might need to be applied to different save operations, at least those that save files on the cache (I wouldn't apply it to all save operations of files in user space). I'll suggest it for remotes.json saving and discuss with the team.

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 a pull request may close this issue.

2 participants