conan config

Manage the Conan configuration in the Conan home.

conan config home

$ conan config home -h
Migration: Successfully updated settings.yml
Migration: Successfully updated profile.py
usage: conan config home [-h] [-v [V]] [-cc CORE_CONF]

Show the Conan home folder.

options:
  -h, --help            show this help message and exit
  -v [V]                Level of detail of the output. Valid options from less
                        verbose to more verbose: -vquiet, -verror, -vwarning,
                        -vnotice, -vstatus, -v or -vverbose, -vv or -vdebug,
                        -vvv or -vtrace
  -cc CORE_CONF, --core-conf CORE_CONF
                        Global configuration for Conan

The conan config home command returns the path of the Conan home folder.

$ conan config home

/home/user/.conan2

conan config install

$ conan config install -h
Migration: Successfully updated settings.yml
Migration: Successfully updated profile.py
usage: conan config install [-h] [-v [V]] [-cc CORE_CONF]
                            [--verify-ssl [VERIFY_SSL] | --insecure]
                            [-t {git,dir,file,url}] [-a ARGS]
                            [-sf SOURCE_FOLDER] [-tf TARGET_FOLDER]
                            item

Install the configuration (remotes, profiles, conf), from git, http or a
folder, into the Conan home folder.

positional arguments:
  item                  git repository, local file or folder or zip file
                        (local or http) where the configuration is stored

options:
  -h, --help            show this help message and exit
  -v [V]                Level of detail of the output. Valid options from less
                        verbose to more verbose: -vquiet, -verror, -vwarning,
                        -vnotice, -vstatus, -v or -vverbose, -vv or -vdebug,
                        -vvv or -vtrace
  -cc CORE_CONF, --core-conf CORE_CONF
                        Global configuration for Conan
  --verify-ssl [VERIFY_SSL]
                        Verify SSL connection when downloading file
  --insecure            Allow insecure server connections when using SSL.
                        Equivalent to --verify-ssl=False
  -t {git,dir,file,url}, --type {git,dir,file,url}
                        Type of remote config
  -a ARGS, --args ARGS  String with extra arguments for "git clone"
  -sf SOURCE_FOLDER, --source-folder SOURCE_FOLDER
                        Install files only from a source subfolder from the
                        specified origin
  -tf TARGET_FOLDER, --target-folder TARGET_FOLDER
                        Install to that path in the conan cache

The conan config install command is intended to install in the current home a common shared Conan configuration, like the definitions of remotes, profiles, settings, hooks, extensions, etc.

The command can use as source any of the following:

  • A URL pointing to a zip archive containing the configuration files

  • A git repository containing the files

  • A local folder

  • Just one file

Files in the current Conan home will be replaced by the ones from the installation source. All the configuration files can be shared and installed this way:

  • remotes.json for the definition of remotes

  • Any custom profile files inside a profiles subfolder

  • Custom settings.yml

  • Custom global.conf

  • All the extensions, including plugins, hooks.

  • Custom user commands.

This command reads a .conanignore file which, if present, filters which files and folders are copied over to the user’s Conan home folder. This file uses fnmatch patterns to match over the folder contents, excluding those entries that match from the config installation. See conan-io/command-extensions’s .conanignore for an example of such a file.

Examples:

  • Install the configuration from a URL:

    $ conan config install http://url/to/some/config.zip
    
  • Install the configuration from a URL, but only getting the files inside a origin folder inside the zip file, and putting them inside a target folder in the local cache:

    $ conan config install http://url/to/some/config.zip -sf=origin -tf=target
    
  • Install configuration from 2 different zip files from 2 different urls, using different source and target folders for each one, then update all:

    $ conan config install http://url/to/some/config.zip -sf=origin -tf=target
    $ conan config install http://url/to/some/config.zip -sf=origin2 -tf=target2
    $ conan config install http://other/url/to/other.zip -sf=hooks -tf=hooks
    
  • Install the configuration from a Git repository with submodules:

    $ conan config install http://github.com/user/conan_config/.git --args "--recursive"
    

    You can also force the git download by using --type git (in case it is not deduced from the URL automatically):

    $ conan config install http://github.com/user/conan_config/.git --type git
    
  • Install from a URL skipping SSL verification:

    $ conan config install http://url/to/some/config.zip --verify-ssl=False
    

    This will disable the SSL check of the certificate.

  • Install a specific file from a local path:

    $ conan config install my_settings/settings.yml
    
  • Install the configuration from a local path:

    $ conan config install /path/to/some/config.zip
    

conan config install-pkg

Warning

This feature is experimental and subject to breaking changes. See the Conan stability section for more information.

$ conan config install-pkg -h
WARN: Downgrading cache from Conan 2.4.1 to 2.2.3
WARN: Applying downgrade migration 2.4_1-migrate.py
Migration: Successfully updated cppstd_compat.py
usage: conan config install-pkg [-h] [-v [V]] [-cc CORE_CONF] [-l LOCKFILE]
                                [--lockfile-partial]
                                [--lockfile-out LOCKFILE_OUT] [-f]
                                item

(Experimental) Install the configuration (remotes, profiles, conf), from a
Conan package

positional arguments:
  item                  Conan require

options:
  -h, --help            show this help message and exit
  -v [V]                Level of detail of the output. Valid options from less
                        verbose to more verbose: -vquiet, -verror, -vwarning,
                        -vnotice, -vstatus, -v or -vverbose, -vv or -vdebug,
                        -vvv or -vtrace
  -cc CORE_CONF, --core-conf CORE_CONF
                        Global configuration for Conan
  -l LOCKFILE, --lockfile LOCKFILE
                        Path to a lockfile. Use --lockfile="" to avoid
                        automatic use of existing 'conan.lock' file
  --lockfile-partial    Do not raise an error if some dependency is not found
                        in lockfile
  --lockfile-out LOCKFILE_OUT
                        Filename of the updated lockfile
  -f, --force           Force the re-installation of configuration

This command allows to install configuration from a Conan package stored in a Conan server.

The packages containing configuration follow some special rules:

  • They must define the package_type = "configuration"

  • The configuration files must be packaged in the final “binary” package, following the same layout as they would for other conan config install cases.

  • They cannot be used as requires of other packages, because that would result in a chicken-and-egg problem.

  • They cannot contain requires to other packages

  • The configuration packages are created with conan create and conan export-pkg as other packages, and uploaded to the servers with conan upload

To install configuration from a Conan configuration package, it is possible:

  • To generate a lockfile file with --lockfile-out. This lockfile file can be passed to conan config install-pkg --lockfile (it will automatically loaded it if is named conan.lock and found in the current directory) in the future to guarantee the same exact version.

  • Version ranges can be used conan config install-pkg "myconf/[>=1.0 <2]" is correct, and it will install the latest one in that range.

  • conan config install-pkg always look in the server for the latest version or revision.

  • If the same version and revision was downloaded and installed from the server, conan config install-pkg will be a no-op unless --force is used, in this case the configuration will be overwritten.

It is also possible to make the version of the configuration affect all packages package_id and be part of the binary model, by activating the core.package_id:config_mode conf (this is also experimental), to any available mode, like minor_mode.

conan config list

$ conan config list -h
Migration: Successfully updated settings.yml
Migration: Successfully updated profile.py
usage: conan config list [-h] [-f FORMAT] [-v [V]] [-cc CORE_CONF]

Show all the Conan available configurations: core and tools.

options:
  -h, --help            show this help message and exit
  -f FORMAT, --format FORMAT
                        Select the output format: json
  -v [V]                Level of detail of the output. Valid options from less
                        verbose to more verbose: -vquiet, -verror, -vwarning,
                        -vnotice, -vstatus, -v or -vverbose, -vv or -vdebug,
                        -vvv or -vtrace
  -cc CORE_CONF, --core-conf CORE_CONF
                        Global configuration for Conan

Displays all the Conan built-in configurations. There are 2 groups:

  • core.xxxx: These can only be defined in global.conf and are used by Conan internally

  • tools.xxxx: These can be defined both in global.conf and profiles, and will be used by recipes and tools used within recipes, like CMakeToolchain

$ conan config list
Error executing: conan config list
WARN: Downgrading cache from Conan 2.4.1 to 2.2.3
WARN: Applying downgrade migration 2.4_1-migrate.py
Migration: Successfully updated cppstd_compat.py
ERROR: [Errno 2] No such file or directory: '/root/.conan2/migrations/2.4_1-migrate.py'

conan config show

$ conan config show -h
WARN: Downgrading cache from Conan 2.4.1 to 2.2.3
WARN: Applying downgrade migration 2.4_1-migrate.py
Migration: Successfully updated cppstd_compat.py
usage: conan config show [-h] [-f FORMAT] [-v [V]] [-cc CORE_CONF] pattern

Get the value of the specified conf

positional arguments:
  pattern               Conf item(s) pattern for which to query their value

options:
  -h, --help            show this help message and exit
  -f FORMAT, --format FORMAT
                        Select the output format: json
  -v [V]                Level of detail of the output. Valid options from less
                        verbose to more verbose: -vquiet, -verror, -vwarning,
                        -vnotice, -vstatus, -v or -vverbose, -vv or -vdebug,
                        -vvv or -vtrace
  -cc CORE_CONF, --core-conf CORE_CONF
                        Global configuration for Conan

Shows the values of the conf items that match the given pattern.

For a global.conf consisting of

tools.build:jobs=42
tools.files.download:retry_wait=10
tools.files.download:retry=7
core.net.http:timeout=30
core.net.http:max_retries=5
zlib*/:tools.files.download:retry_wait=100
zlib*/:tools.files.download:retry=5

You can get all the values:

$ conan config show "*"

core.net.http:max_retries: 5
core.net.http:timeout: 30
tools.files.download:retry: 7
tools.files.download:retry_wait: 10
tools.build:jobs: 42
zlib*/:tools.files.download:retry: 5
zlib*/:tools.files.download:retry_wait: 100

Or just those referring to the tools.files section:

$ conan config show "*tools.files*"

tools.files.download:retry: 7
tools.files.download:retry_wait: 10
zlib*/:tools.files.download:retry: 5
zlib*/:tools.files.download:retry_wait: 100

Notice the first * in the pattern. This will match all the package patterns. Removing it will make the command only show global confs:

$ conan config show "tools.files*"

tools.files.download:retry: 7
tools.files.download:retry_wait: 10