question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feature] [2.0] Make conan use conanonical config/cache/etc files.

See original GitHub issue

Tl;dr

What I’m suggesting

Stop using HOME/.conan for everything and instead use the canonical folders. So on linux settings.yml would go in HOME/.config/conan since it’s configuration and the data folder would go in HOME/.cache/conan since it can easily be regenerated.

The python project appdirs gives an easy way to find the right folders for everything in a cross platform way.

Why is this important

  • People who know the OS will understand what each folder/file does better.
  • The OS and other tools will be able to better handle Conan
  • Sysadmins will be able to better handle Conan
  • Making backups will be more straight forward
  • Its cool to do things the Right Way

Potential problems

  • People who don’t know there OSs customs might find this more confusing difficult.
  • Even if a user knows the OS customs they might be confused for a while about the change.
  • Conan shouldn’t use global folders like /usr/local/share if Conan was installed locally. I don’t think appdirs can detect a local installation though.
  • Conan can automatically migrate all the files it knows about but if the user put their own files into .conan then Conan doesn’t know whether those are config, cache, data etc. In those cases the migration will have to be finished by the user by hand.

Longer form

What I’m suggesting

Currently in Linux Conan has folder called .conan directly under the home folder. This is the old school linux way of doing things. Nowadays linux encourages the the use of .config, .cache and other such folders. This keeps the home folders clean and adds semantic information to the config files.

The .config is where configuration needs to stay. So when I’m backing up my computer I know I need to backup .config. Neovim uses the .config to store the vimrc, for example. The .cache folder is for stuff that can be regenerated. When my computers getting low on storage I can nuke .cache without worry. Pip uses .cache folder to cache wheels and other packages it pulls from PyPi and pypoetry uses it for virtual environments.

Conans folder structure looks like this right now.

HOME
└── .conan
   β”œβ”€β”€  artifacts.properties
   β”œβ”€β”€ cacert.pem
   β”œβ”€β”€ conan.conf
   β”œβ”€β”€ data
   β”‚   β”œβ”€β”€ <pkg name>
   β”‚   β”‚   └── <version>
   β”‚   └── <other pkg>
   β”‚       └── <version>
   β”œβ”€β”€ hooks
   β”‚   └── attribute_checker.py
   β”œβ”€β”€ profiles
   β”‚   └── default
   β”œβ”€β”€ remotes.json
   β”œβ”€β”€ settings.yml
   └── version.txt

On linux it should probably look something like this

HOME
β”œβ”€β”€ .config
β”‚   └── conan
β”‚       β”œβ”€β”€  artifacts.properties
β”‚       β”œβ”€β”€ cacert.pem
β”‚       β”œβ”€β”€ conan.conf
β”‚       β”œβ”€β”€ hooks
β”‚       β”‚   └── attribute_checker.py
β”‚       β”œβ”€β”€ profiles
β”‚       β”‚   └── default
β”‚       β”œβ”€β”€ remotes.json
β”‚       β”œβ”€β”€ settings.yml
β”‚       └── version.txt
└── .cache
    └── conan
        β”œβ”€β”€ data
        β”œβ”€β”€ <pkg name>
        β”‚   └── <version>
        └── <other pkg>
            └── <version>

On windows there’s the AppData and I don’t even know what Mac uses. Luckily there’s a handy python library called appdirs the takes care of finding the OS specific locations.

I haven’t dug into the conan source code but I feeling that this change would touch many files but each individual change will likely be pretty straight forward (if it’s put into Conan 2.0 as a breaking change).

Why this helps

When I was trying to understand Conan a lot of things were mysterious to me. It took me a good couple hours before I realized I could just delete the data folder without consequence. Using the canonical folders is in some ways another form of documentation. When something is in .config it tells the user β€œthis is per user configuration, if you need to configure conan for your user the files to do so are in here somewhere”. When I see that I have a .conan in the home directory I am told β€œall the data for conan is here probably.”

Tools and people trust this configuration for system administration, backups, etc. My backup scripts go into .config and backup the folders of all the programs I care about. I don’t know what’s in there or how it works half the time but I know it’s configuration. My script ignores everything in .cache because I know it can all be regenerated and I want my backups slim. Every time a program drops their stuff in the home directory I have to actually learn about the program, folder by folder, and in some cases file by file, and decide what’s important to keep (*cough* firefox *cough*). Using the standard system administration easier.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cheogcommented, Oct 14, 2021

@memsharded Thank you for taking the time to respond to this in full. I appreciate it a lot.

1reaction
memshardedcommented, Oct 13, 2021

A couple of notes about this:

  • We have favored homogeneous layout for all OS. It simplifies the code, the maintenance, the support and the documentation. Things are always in <userhome>/.conan in all platforms. This can also simplify CI scripts of users dealing with multiple platforms.
  • Having everything in 1 location allows to change the root folder, via 1 single env-var CONAN_USER_HOME, which is very common for CI setups. If the folders are separate, now the first point complexity keep compounding.

While I understand the Linux specific layout could have advantages, the fact is that other OS doesn’t have such strong convention, and that results that in practice a ton of tools do not follow that convention, as well described in https://twitter.com/codeinred/status/1445275055626199040?s=20. At the moment I tend to think (as always, it is a trade off) that even if slightly more convenient for Linux users, it would be overall better to keep it because of the above reasons.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conan local cache: concurrency, Continuous Integration ...
Conan local cache support some degree of concurrency, allowing simultaneous creation or installation of different packages, or building different binaries forΒ ...
Read more >
Introduction to Conan package manager - Kuba Sejdak
Automatic installation with CMake wrapper. The canonical (recommended) way of using Conan is via the conanfile.txt configuration. This is fineΒ ...
Read more >
Package List β€” Spack 0.20.0.dev0 documentation
This is a list of things you can install using Spack. It is automatically generated based on the packages in this Spack version....
Read more >
my first conan package not getting found by CMAKE?
The right process to debug this kind of problems is the following: Check the generated conanbuildinfo.cmake file, it will contain variablesΒ ...
Read more >
Development guide for GitLab CI/CD templates
If the template should be used by copy pasting it into a configuration file, or by using it with the include keyword in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found