conan install — conan 2.6.0 documentation (2024)

$ conan install -husage: conan install [-h] [-v [V]] [-cc CORE_CONF] [-f FORMAT] [--name NAME] [--version VERSION] [--user USER] [--channel CHANNEL] [--requires REQUIRES] [--tool-requires TOOL_REQUIRES] [-b BUILD] [-r REMOTE | -nr] [-u [UPDATE]] [-pr PROFILE] [-pr:b PROFILE_BUILD] [-pr:h PROFILE_HOST] [-pr:a PROFILE_ALL] [-o OPTIONS] [-o:b OPTIONS_BUILD] [-o:h OPTIONS_HOST] [-o:a OPTIONS_ALL] [-s SETTINGS] [-s:b SETTINGS_BUILD] [-s:h SETTINGS_HOST] [-s:a SETTINGS_ALL] [-c CONF] [-c:b CONF_BUILD] [-c:h CONF_HOST] [-c:a CONF_ALL] [-l LOCKFILE] [--lockfile-partial] [--lockfile-out LOCKFILE_OUT] [--lockfile-clean] [--lockfile-overrides LOCKFILE_OVERRIDES] [-g GENERATOR] [-of OUTPUT_FOLDER] [-d DEPLOYER] [--deployer-folder DEPLOYER_FOLDER] [--deployer-package DEPLOYER_PACKAGE] [--build-require] [path]Install the requirements specified in a recipe (conanfile.py or conanfile.txt).It can also be used to install packages without a conanfile, using the--requires and --tool-requires arguments.If any requirement is not found in the local cache, it will iterate the remoteslooking for it. When the full dependency graph is computed, and all dependenciesrecipes have been found, it will look for binary packages matching the current settings.If no binary package is found for some or several dependencies, it will error,unless the '--build' argument is used to build it from source.After installation of packages, the generators and deployers will be called.positional arguments: path Path to a folder containing a recipe (conanfile.py or conanfile.txt) or to a recipe file. e.g., ./my_project/conanfile.txt.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 Define core configuration, overwriting global.conf values. E.g.: -cc core:non_interactive=True -f FORMAT, --format FORMAT Select the output format: json --name NAME Provide a package name if not specified in conanfile --version VERSION Provide a package version if not specified in conanfile --user USER Provide a user if not specified in conanfile --channel CHANNEL Provide a channel if not specified in conanfile --requires REQUIRES Directly provide requires instead of a conanfile --tool-requires TOOL_REQUIRES Directly provide tool-requires instead of a conanfile -b BUILD, --build BUILD Optional, specify which packages to build from source. Combining multiple '--build' options on one command line is allowed. Possible values: --build="*" Force build from source for all packages. --build=never Disallow build for all packages, use binary packages or fail if a binary package is not found, it cannot be combined with other '--build' options. --build=missing Build packages from source whose binary package is not found. --build=cascade Build packages from source that have at least one dependency being built from source. --build=[pattern] Build packages from source whose package reference matches the pattern. The pattern uses 'fnmatch' style wildcards. --build=~[pattern] Excluded packages, which will not be built from the source, whose package reference matches the pattern. The pattern uses 'fnmatch' style wildcards. --build=missing:[pattern] Build from source if a compatible binary does not exist, only for packages matching pattern. -r REMOTE, --remote REMOTE Look in the specified remote or remotes server -nr, --no-remote Do not use remote, resolve exclusively in the cache -u [UPDATE], --update [UPDATE] Will install newer versions and/or revisions in the local cache for the given reference, or all in case no argument is supplied. When using version ranges, it will install the latest version that satisfies the range. Also, if using revisions, it will update to the latest revision for the resolved version range. -pr PROFILE, --profile PROFILE Apply the specified profile. By default, or if specifying -pr:h (--profile:host), it applies to the host context. Use -pr:b (--profile:build) to specify the build context, or -pr:a (--profile:all) to specify both contexts at once -pr:b PROFILE_BUILD, --profile:build PROFILE_BUILD -pr:h PROFILE_HOST, --profile:host PROFILE_HOST -pr:a PROFILE_ALL, --profile:all PROFILE_ALL -o OPTIONS, --options OPTIONS Apply the specified options. By default, or if specifying -o:h (--options:host), it applies to the host context. Use -o:b (--options:build) to specify the build context, or -o:a (--options:all) to specify both contexts at once. Example: -o pkg:with_qt=true -o:b OPTIONS_BUILD, --options:build OPTIONS_BUILD -o:h OPTIONS_HOST, --options:host OPTIONS_HOST -o:a OPTIONS_ALL, --options:all OPTIONS_ALL -s SETTINGS, --settings SETTINGS Apply the specified settings. By default, or if specifying -s:h (--settings:host), it applies to the host context. Use -s:b (--settings:build) to specify the build context, or -s:a (--settings:all) to specify both contexts at once. Example: -s compiler=gcc -s:b SETTINGS_BUILD, --settings:build SETTINGS_BUILD -s:h SETTINGS_HOST, --settings:host SETTINGS_HOST -s:a SETTINGS_ALL, --settings:all SETTINGS_ALL -c CONF, --conf CONF Apply the specified conf. By default, or if specifying -c:h (--conf:host), it applies to the host context. Use -c:b (--conf:build) to specify the build context, or -c:a (--conf:all) to specify both contexts at once. Example: -c tools.cmake.cmaketoolchain:generator=Xcode -c:b CONF_BUILD, --conf:build CONF_BUILD -c:h CONF_HOST, --conf:host CONF_HOST -c:a CONF_ALL, --conf:all CONF_ALL -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 --lockfile-clean Remove unused entries from the lockfile --lockfile-overrides LOCKFILE_OVERRIDES Overwrite lockfile overrides -g GENERATOR, --generator GENERATOR Generators to use -of OUTPUT_FOLDER, --output-folder OUTPUT_FOLDER The root output folder for generated and build files -d DEPLOYER, --deployer DEPLOYER Deploy using the provided deployer to the output folder. Built-in deployers: 'full_deploy', 'direct_deploy', 'runtime_deploy' --deployer-folder DEPLOYER_FOLDER Deployer output folder, base build folder by default if not set --deployer-package DEPLOYER_PACKAGE Execute the deploy() method of the packages matching the provided patterns --build-require Whether the provided path is a build-require

The conan install command is one of the main Conan commands, and it is used to resolve and install dependencies.

This command does the following:

  • Compute the whole dependency graph, for the current configuration defined by settings, options, profiles and configuration.It resolves version ranges, transitive dependencies, conditional requirements, etc, to build the dependency graph.

  • Evaluate the existence of binaries for every package in the graph, whether or not there are precompiled binaries to download, or ifthey should be built from sources (as directed by the --build argument). If binaries are missing, it will not recomputethe dependency graph to try to fallback to previous versions that contain binaries for that configuration. If a certaindependency version is desired, it should be explicitly required.

  • Download precompiled binaries, or build binaries from sources in the local cache, in the right order for the dependency graph.

  • Create the necessary files as requested by the “generators”, so build systems and other tools can locate the locally installed dependencies

  • Optionally, execute the desired deployers.

See also

  • Check the JSON format output for this command.

Conanfile path or –requires

The conan install command can use 2 different origins for information. The first one is using a local conanfile.pyor conanfile.txt, containing definitions of the dependencies and generators to be used.

$ conan install . # there is a conanfile.txt or a conanfile.py in the cwd$ conan install conanfile.py # also works, direct reference file$ conan install myconan.txt # explicit custom name$ conan install myfolder # there is a conanfile in "myfolder" folder

Even if it is possible to use a custom name, in the general case, it is recommended to use the default conanfile.pyname, located in the repository root, so users can do a straightforward git clone ... `` + ``conan install .

The other possibility is to not have a conanfile at all, and define the requirements to be installed directly in thecommand line:

# Install the zlib/1.2.13 library$ conan install --requires=zlib/1.2.13# Install the zlib/1.2.13 and bzip2/1.0.8 libraries$ conan install --requires=zlib/1.2.13 --requires=bzip2/1.0.8# Install the cmake/3.23.5 and ninja/1.11.0 tools$ conan install --tool-requires=cmake/3.23.5 --tool-requires=ninja/1.11.0# Install the zlib/1.2.13 library and ninja/1.11.0 tool$ conan install --requires=zlib/1.2.13 --tool-requires=ninja/1.11.0

In the general case, it is recommended to use a conanfile instead of defining things in the command line.

Profiles, Settings, Options, Conf

There are several arguments that are used to define the effective profiles that will be used, both for the “build”and “host” contexts.

By default the arguments refer to the “host” context, so --settings:host, -s:h is totally equivalent to--settings, -s. Also, by default, the conan install command will use the default profile both for the“build” and “host” context. That means that if a profile with the “default” name has not been created, it will error.

Multiple definitions of profiles can be passed as arguments, and they will compound from left to right (right has thehighest priority)

# The values of myprofile3 will have higher priority$ conan install . -pr=myprofile1 -pr=myprofile2 -pr=myprofile3

If values for any of settings, options and conf are provided in the command line, they create a profile thatis composed with the other provided -pr (or the “default” one if not specified) profiles, with higher priority,not matter what the order of arguments is.

# the final "host" profile will always be build_type=Debug, even if "myprofile"# says "build_type=Release"$ conan install . -pr=myprofile -s build_type=Debug

Generators and deployers

The -g argument allows to define in the command line the different built-in generators to be used:

$ conan install --requires=zlib/1.2.13 -g CMakeDeps -g CMakeToolchain

Note that in the general case, the recommended approach is to have the generators defined in the conanfile,and only for the --requires use case, it would be more necessary as command line argument.

Generators are intended to create files for the build systems to locate the dependencies, while the deployersmain use case is to copy files from the Conan cache to user space, and performing any other custom operations over the dependency graph,like collecting licenses, generating reports, deploying binaries to the system, etc. The syntax for deployers is:

# does a full copy of the dependencies binaries to the current user folder$ conan install . --deployer=full_deploy

There are 3 built-in deployers:

  • full_deploy does a complete copy of the dependencies binaries in the local folder, with a minimal folderstructure to avoid conflicts between files and artifacts of different packages

  • direct_deploy does a copy of only the immediate direct dependencies, but does not include the transitivedependencies.

  • runtime_deploy deploys all the shared libraries and the executables of thedependencies (like .so, .dll, or .dylib files) into a flat directorystructure. (Available since Conan 2.5.0)

Some generators might have the capability of redefining the target “package folder”. That means that if some othergenerator like CMakeDeps is used that is pointing to the packages, it will be pointing to the local deployedcopy, and not to the original packages in the Conan cache. See the full example in Creating a Conan-agnostic deploy of dependencies for developer use.

It is also possible, and it is a powerful extension point, to write custom user deployers.Read more about custom deployers in Deployers.

It is possible to also invoke the package recipes deploy() method with the --deployer-package:

# Execute deploy() method of every recipe that defines it$ conan install --requires=pkg/0.1 --deployer-package=*# Execute deploy() method only for "pkg" (any version) recipes$ conan install --requires=pkg/0.1 --deployer-package=pkg/*

The --deployer-package argument is a pattern and accept multiple values, all package references matching any of the defined patterns will execute its deploy() method. The --deployer-folder argument will also affect the output location of this deployment. See the deploy() method.

If multiple deployed packages deploy to the same location, it is their responsibility to not mutually overwrite their binaries if they have the same filenames. For example if multiple packages deploy() a file called “License.txt”, each recipe is responsible for creating an intermediate folder with the package name and/or version that makes it unique, so other recipes deploy() method do not overwrite previously deployed “License.txt” files.

Name, version, user, channel

The conan install command provides optional arguments for --name, --version, --user, --channel. Thesearguments might not be necessary in the majority of cases. Never for conanfile.txt and for conanfile.pyonly in the case that they are not defined in the recipe:

from conan import ConanFilefrom conan.tools.scm import Versionclass Pkg(ConanFile): name = "mypkg" def requirements(self): if Version(self.version) >= "3.23": self.requires("...")
# If we don't specify ``--version``, it will be None and it will fail$ conan install . --version=3.24

Lockfiles

The conan install command has several arguments to load and produce lockfiles.By default, if a conan.lock file is located beside the recipe or in the current working directoryif no path is provided, will be used as an input lockfile.

Lockfiles are strict by default, that means thatif there is some requires and it cannot find a matching locked reference in the lockfile, it will errorand stop. For cases where it is expected that the lockfile will not be complete, as there might be newdependencies, the --lockfile-partial argument can be used.

By default, conan install will not generate an output lockfile, but if the --lockfile-out argumentis provided, pointing to a filename, like --lockfile-out=result.lock, then a lockfile will be generatedfrom the current dependency graph. If --lockfile-clean argument is provided, all versions and revisionsnot used in the current dependency graph will be dropped from the resulting lockfile.

Let’s say that we already have a conan.lock input lockfile, but we just added a new requires = "newpkg/1.0"to a new dependency. We could resolve the dependencies, locking all the previously locked versions, while allowingto resolve the new one, which was not previously present in the lockfile, and store it in a new location, or overwrite the existing lockfile:

# --lockfile=conan.lock is the default, not necessary$ conan install . --lockfile=conan.lock --lockfile-partial --lockfile-out=conan.lock

Also, it is likely that the majority of lockfile operations are better managed by the conan lock command.

See also

  • Lockfiles.

  • Read the tutorial about the local package development flow.

Update

The conan install command has an --update argument that will force the re-evaluation of the selected items of the dependency graph,allowing for the update of the dependencies to the latest version if using version ranges, or to the latest revision of the same version,when those versions are not locked in the given lockfile. Passing --update will check every package in the dependency graph,but it is also possible to pass a package name to the --update argument (it can be added to the command more than once with different names),to only update those packages, which avoids the re-evaluation of the whole graph.

$ conan install . --update # Update all packages in the graph$ conan install . --update=openssl # Update only the openssl package$ conan install . --update=openssl --update=boost # Update both openssl and boost packages

Note that the --update argument will look into all the remotes specified in the command for possible newer versions,and won’t stop at the first newer one found.

conan install — conan 2.6.0 documentation (2024)

FAQs

How to install conan version? ›

You can run Conan from source in Windows, MacOS, and Linux:
  1. Install pip following pip docs.
  2. Install in editable mode. $ cd conan-io && sudo pip install -e . ...
  3. You are ready, try to run Conan: $ conan --help Consumer commands install Installs the requirements specified in a recipe (conanfile.py or conanfile.txt). ...

How to install conan dependencies? ›

In Windows and OSX, the simplest approach is to copy the shared libraries to the executable folder, so they are found by the executable, without having to modify the path. This is done using the [imports] section in conanfile. txt . You can explore the package folder in your local cache (~/.

How to install conan on Ubuntu? ›

Install Conan on Ubuntu minimal and run a simple Eigen example
  1. install Conan with sudo pip3 install conan -y , please make sure you use the sudo otherwise you have to uninstall and install again.
  2. install cmake with sudo apt install cmake -y.
  3. I assume you have build-essential already installed (duh!)
Feb 12, 2020

Does conan work on Windows? ›

Conan can be installed in many Operating Systems. It has been extensively used and tested in Windows, Linux (different distros), OSX, and is also actively used in FreeBSD and Solaris SunOS. There are also several additional operating systems on which it has been reported to work.

How do I manually install Conan Exiles mods? ›

Start Conan Exiles, choose Mods from the main menu, and move the mods you want from “available” to “active” or whatever the columns are called in that screen. Restart Conan Exiles to load the selected mods. (There is a . txt file in the Mods folder that will update as you activate mods in the game.

How to check Conan version? ›

from conans import ConanFile, CMake, __version__ as conan_version from conans. tools import Version class MyLibraryConan(ConanFile): name = "mylibrary" version = "1.0" def build(self): if conan_version < Version("0.29"): cmake = CMake(self. settings) else: cmake = CMake(self) ...

What is the difference between conan install and conan create? ›

The conan install is what is used in the "consuming packages" tutorial. On the other hand, the conan create requires a conanfile.py with the build() , package() and package_info() methods, and it will create a package in the Conan cache from the current project.

What is install dependencies? ›

Dependency Installation is the process of installing software requirements (dependencies) for your applications before those applications are deployed. E.g. an application could require some library to be installed on the host in order to run properly.

How to clean conan cache? ›

Examples:
  1. Remove all non-critical files: $ conan cache clean "*"
  2. Remove all temporary files: $ conan cache clean "*" --temp.
  3. Remove the download folders for the zlib recipe: $ conan cache clean "zlib/*" --download.
  4. Remove everything but the download folder for the zlib recipe:

What is a Conan package manager? ›

Conan is a package manager for C and C++ developers: It is fully decentralized. Users can host their packages on their servers, privately. Integrates with Artifactory and Bintray. Portable.

What is conan in Python? ›

Conan: A Python package manager. Conan is a C and C++ package manager, and to deal with the vast variability of C and C++ build systems, compilers, configurations, etc., it was designed to be extremely flexible, to allow users the freedom to configure builds in virtually any manner required.

How to update Conan Linux? ›

Open a terminal and input pip install -U "conan<2.0" (this will install or update Conan). Check that the operation is successful with conan --version .

What is the best PC for Conan Exiles? ›

Recommended: OS: Windows 11 64bit. Processor: AMD Ryzen 7 5600X or Intel Core i7-11700F. Memory: 16 GB RAM.

Is Conan Exiles CPU or GPU? ›

To play Conan Exiles you will need a minimum CPU equivalent to an AMD FX-6300 Six-Core. However, the developers recommend a CPU greater or equal to an Intel Core i7-3770K to play the game. Conan Exiles system requirements state that you will need at least 6 GB of RAM.

Why won t Conan Exiles start PC? ›

The only solution I found is to go to the game folder “Conan Exiles\ConanSandbox\Binaries\Win64” and there there are 3 exes, by launching ConanSandbox_BE.exe there the game launches normally and I can play. When you get a chance, see if verifying the game files fixes the launcher connection to the exe.

How do I install a specific version of pip? ›

To install a specific version of a package using pip, use the syntax pip install package==version . For example, to install version 1.0. 0 of a package named 'sample', use pip install sample==1.0.

How do I update Conan on Windows? ›

Open a terminal and input pip install -U "conan<2.0" (this will install or update Conan). Check that the operation is successful with conan --version .

How to pip install command? ›

Method 1: Install PIP on Windows Using get-pip.py
  1. Step 1: Download PIP get-pip.py. Before installing PIP, download the get-pip.py file. ...
  2. Step 2: Installing PIP on Windows. To install PIP, run the following Python command: python get-pip.py. ...
  3. Step 3: Verify Installation. ...
  4. Step 4: Add Pip to Path. ...
  5. Step 5: Configuration.
Nov 30, 2023

Where is the Conan folder on Windows? ›

By default it is ./data, which is relative to the folder containing this conan. conf file, which by default is the <userhome>/. conan folder.

References

Top Articles
Latest Posts
Article information

Author: Stevie Stamm

Last Updated:

Views: 6329

Rating: 5 / 5 (80 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Stevie Stamm

Birthday: 1996-06-22

Address: Apt. 419 4200 Sipes Estate, East Delmerview, WY 05617

Phone: +342332224300

Job: Future Advertising Analyst

Hobby: Leather crafting, Puzzles, Leather crafting, scrapbook, Urban exploration, Cabaret, Skateboarding

Introduction: My name is Stevie Stamm, I am a colorful, sparkling, splendid, vast, open, hilarious, tender person who loves writing and wants to share my knowledge and understanding with you.