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] Ability to run conan profile detect w/o error and w/o overwriting when the profile already exists #15902

Closed
1 task done
mmomtchev opened this issue Mar 20, 2024 · 3 comments · Fixed by #15933
Closed
1 task done
Assignees
Milestone

Comments

@mmomtchev
Copy link

What is your suggestion?

I am using conan as a part of a source-level distribution system on npm for JavaScript packages that contain C++ code (compiled to native binary for Node.js and to WASM for the browser). conan enables me to produce self-contained builds without having to maintain all the included libraries.

Currently, all my build scripts start with:

{{platform.python}} -m pip install --user git+https://github.com/conan-io/conan # because of #15867
{{platform.python}} -m conans.conan profile detect || echo ok
{{platform.python}} -m conans.conan install ..... <very long line>

The second line works with both bash and cmd.exe but it would be even better if there was a --if-not-exists option - so that all my builds do not start with an error. I could of course create a special profile and overwrite it at each invocation - or even create my own conan home directory, but I think that I should support the case where the user has an already existing conan profile that contains custom options.

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded memsharded self-assigned this Mar 20, 2024
@memsharded
Copy link
Member

Hi @mmomtchev

Some quick feedback first: the usage of conans.conan is not documented, not part of the public interface. This is guaranteed to change in some future Conan release, when we will refactor the code internals.

For not raising an error for conan profile detect, there is already the --force flag. But that would indeed overwrite the existing default profile.

I think what is incompatible is both having a modified default profile and also calling conan profile detect to detect the default profile. The not overwrite error is there for this reason, to protect against this.

The strategy should probably be different:

  • Manage your own profiles explicitly, name them and use them explicitly. Manage them with conan config install
  • Detect and use a different name than the profile, like conan profile detect --name=myprofile. The default profile name can also be changed in global.conf if you want to avoid passing -pr=myprofile in every invocation.
  • You can check yourself in your pipeline with conan profile list if the default profile already exist

@mmomtchev
Copy link
Author

If I decide to always overwrite, I won't be compatible with an existing conan installation - which is could be a good decision. On other hand, parsing the conan profile list output in a platform-independent way would require a Node.js or Python script. And alas, a pip bin directory - especially the user one - that is not in the PATH is a very common occurrence - maybe not on Linux - but quite probable on macOS and Windows. I am afraid that there are no simple alternatives.

@memsharded
Copy link
Member

Proposing --exist-ok in #15933

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