Conan Add Remote (HIGH-QUALITY »)
conan add remote only adds the remote configuration; it does not store user credentials. To authenticate with a private remote that requires login, you use:
conan user -p mypassword -r mycompany myusername
Conan then stores an authentication token locally (in ~/.conan2/remotes.json or similar). Future operations with --remote=mycompany will use this token.
conan remote add company-repo https://conan.jfrog.io/artifactory/api/conan/default-conan-local conan add remote
Before diving into the command itself, it's crucial to understand what a remote represents in Conan.
Think of Conan remotes exactly like Git remotes. Just as git remote add origin https://github.com/user/repo.git links your local repository to a shared server, conan add remote links your local Conan cache to a Conan server. This server could be: conan add remote only adds the remote configuration;
When you run conan install, Conan searches your configured remotes in a specific order to find the recipe and binary packages for your dependencies. Without the correct remotes, your build will fail with a cryptic Unable to find 'openssl/1.1.1' in remotes error.
In the world of C++ dependency management, Conan stands out as a powerful, decentralized package manager. At the heart of this decentralization is the concept of remotes—servers that host Conan packages. The conan add remote command is your primary tool for connecting your local Conan client to these servers, enabling you to install, upload, and manage packages from various sources. Conan then stores an authentication token locally (in ~/
Remote priority matters: Conan searches remotes in the order they are listed (from highest to lowest priority). To make your company remote take precedence over Conan Center:
conan add remote mycompany https://artifacts.mycompany.com/artifactory/api/conan/cpp-libs --insert --index 0
Now Conan will first look for any package in mycompany; only if not found there will it fall back to conancenter.
The basic syntax of the command is:
conan add remote <remote_name> <remote_url> [options]
Use Conan Center as a fallback for packages not in your private remote.
conan remote add private https://private.repo.com/v2 --insert 0
conan remote add conancenter https://center.conan.io # now priority is lower