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

Add conan.conanrc file to setup the conan user home #11675

Merged
merged 8 commits into from
Jul 21, 2022

Conversation

czoido
Copy link
Contributor

@czoido czoido commented Jul 20, 2022

Closes: #11542

You can create a .conanrc file in the folder where you are running conan (or any parent folder), it can have this content:

Set the conan home to an absolute folder

# accepts comments
conan_home=/absolute/folder

Set the conan home to a relative folder inside the current folder

# accepts comments
conan_home=./relative folder/inside current folder

Set the conan home to a relative folder outside the current folder

# accepts comments
conan_home=../relative folder/outside current folder

Set the conan home to a path containing the ~ that will be expanded to the system's user home

# accepts comments
conan_home=~/use the user home to expand it

The .conanrc file is searched for in all parent folders so, if for example, in this structure:

.
.conanrc
├── project1
└── project2

And you are running from folder project1 the parent folders are traversed recursively until a .conanrc is found in case it exists.

@czoido czoido added this to the 2.0.0-beta2 milestone Jul 20, 2022
@czoido czoido requested review from memsharded and removed request for memsharded July 20, 2022 07:04
conans/paths/__init__.py Outdated Show resolved Hide resolved
conans/paths/__init__.py Outdated Show resolved Hide resolved
@czoido czoido closed this Jul 20, 2022
@czoido czoido reopened this Jul 20, 2022
conans/paths/__init__.py Outdated Show resolved Hide resolved
conans/paths/__init__.py Outdated Show resolved Hide resolved
conans/test/unittests/paths/user_home_test.py Outdated Show resolved Hide resolved
@czoido czoido closed this Jul 20, 2022
@czoido czoido reopened this Jul 20, 2022
Copy link
Contributor

@lasote lasote left a comment

Choose a reason for hiding this comment

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

The issue to be closed described also that we wanted to recover the "storage" path (different from the cache). Right?

conans/paths/__init__.py Outdated Show resolved Hide resolved
@memsharded
Copy link
Member

@lasote the storage path was already merged in #11672

@memsharded memsharded merged commit 25df39d into conan-io:develop2 Jul 21, 2022
@prince-chrismc
Copy link
Contributor

This made playing with Conan 2.0 so much easier! ❤️

Now I just keep .conanrc in my root project folder with conan_home=~/.conan2 and magic 🧙 I get

$ conan config home
Current Conan home: /Users/christopherm/.conan2

👏

@memsharded
Copy link
Member

@prince-chrismc To make things clear, .conan2 is already the default name in Conan 2.0 beta to avoid colliding with Conan 1.X. But the feature should work for other names too, please check

@prince-chrismc
Copy link
Contributor

It does, conan_home=/tmp/meetup/.conan_two

Current Conan home: /Users/christopherm/.conan_two
 christopherm@christopherm-mac  ~/meetup   conan2 ±  conan config home
Initialized file: '/tmp/meetup/.conan_two/settings.yml'
Initialized file: '/tmp/meetup/.conan_two/extensions/plugins/compatibility/compatibility.py'
Initialized file: '/tmp/meetup/.conan_two/extensions/plugins/compatibility/app_compat.py'
Initialized file: '/tmp/meetup/.conan_two/extensions/plugins/compatibility/cppstd_compat.py'
Initialized file: '/tmp/meetup/.conan_two/extensions/plugins/profile.py'
Current Conan home: /tmp/meetup/.conan_two

@blackliner
Copy link
Contributor

blackliner commented Aug 20, 2022

Amazing, thanks for this! This will make working in multiple repositories with different, conflicting hooks a dream. Also, monorepo ❤️

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.

5 participants