Remotes: Local Indexes, conan_server & Artifactory
A package in your local cache helps one machine. To share recipes and binaries with a team and CI, you need a remote. Conan supports three kinds:
| Remote | Holds | Typical use |
|---|---|---|
ConanCenter (center2.conan.io) |
public recipes and prebuilt binaries | open-source dependencies |
| Artifactory (Community Edition for C/C++ is free) or conan_server | your recipes and binaries, private | company packages, mirrors of ConanCenter |
| local-recipes-index | recipes in a folder or Git repository, no binaries | private recipe repos, ConanCenter forks, air-gapped builds from source |
Managing remotes
conan remote list
conan remote add company https://artifactory.example.com/artifactory/api/conan/conan-local
conan remote login company ci-bot -p "$CONAN_PASSWORD" # or CONAN_LOGIN_USERNAME_COMPANY / CONAN_PASSWORD_COMPANY
conan remote update company --index 0 # search it before ConanCenter
conan remote disable conancenter # only use the company remoteConan looks for a recipe in the remotes in order and uses the first that has it (unless you pass -r to name one). Order matters for security: if a public remote comes first, someone could publish a package with your private package's name there (dependency confusion). Put private remotes first, or better, use only a company remote that proxies ConanCenter.
A local-recipes-index remote (runs offline)
The simplest remote is a folder laid out like ConanCenter's GitHub repository: recipes/<name>/config.yml lists versions and the folder holding each version's recipe. Conan builds from the recipe when a binary is needed:
mkdir -p repo/recipes/greet/all/src repo/recipes/greet/all/include
cat > repo/recipes/greet/config.yml <<'Y'
versions:
"1.0.0":
folder: all
Y
cat > repo/recipes/greet/all/conanfile.py <<'PY'
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
class GreetRecipe(ConanFile):
name = "greet"
package_type = "static-library"
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain"
exports_sources = "CMakeLists.txt", "src/*", "include/*"
def layout(self):
cmake_layout(self)
def build(self):
cmake = CMake(self); cmake.configure(); cmake.build()
def package(self):
CMake(self).install()
def package_info(self):
self.cpp_info.libs = ["greet"]
PY
printf 'cmake_minimum_required(VERSION 3.25)\nproject(greet CXX)\nadd_library(greet src/greet.cpp)\ntarget_include_directories(greet PUBLIC include)\ninstall(TARGETS greet)\ninstall(FILES include/greet.h DESTINATION include)\n' > repo/recipes/greet/all/CMakeLists.txt
printf '#pragma once\nconst char* greeting();\n' > repo/recipes/greet/all/include/greet.h
printf '#include "greet.h"\nconst char* greeting() { return "hello from the in-house index"; }\n' > repo/recipes/greet/all/src/greet.cpp
conan remote add inhouse ./repo --type=local-recipes-index
conan remote disable conancenter > /dev/null
conan remote list
conan search "greet*" -r inhouse
conan install --requires=greet/1.0.0 --build=missing -c tools.build:jobs=1 2>&1 | grep -E 'Downloaded recipe|Checking remote| - (Build|Downloaded)|: Package 'conancenter: https://center2.conan.io [Verify SSL: True, Enabled: False]
inhouse: /home/learner/repo [local-recipes-index, Enabled: True]
Found 1 pkg/version recipes matching greet* in inhouse
inhouse
greet
greet/1.0.0
greet/1.0.0: Checking remote: inhouse
greet/1.0.0: Downloaded recipe revision 4fc6d96e3fb85f2c6d1bb402ccd05e1f
greet/1.0.0#4fc6d96e3fb85f2c6d1bb402ccd05e1f - Downloaded (inhouse)
greet/1.0.0#4fc6d96e3fb85f2c6d1bb402ccd05e1f:9579ed92ff10290b68440279875f9eccd83f2d71 - Build
greet/1.0.0: Package '9579ed92ff10290b68440279875f9eccd83f2d71' built
The recipe came from inhouse, no binary existed anywhere, so --build=missing built it locally. A local-recipes-index can't store binaries: every machine builds from source once and then reuses its own cache. That's fine for a few small packages, and for an air-gapped network it can be paired with conan cache save/restore to move binaries.
conan_server
conan_server is a small reference server shipped with Conan's Python package (install it with pip install "conan[server]"; this course's image has it). It stores recipes and binaries on disk under ~/.conan_server/data, with users and permissions in ~/.conan_server/server.conf, which the first start writes if it's missing. It's fine for experiments and small teams, not for production (no web UI, no replication, minimal access control).
The session starts the server in the background (its access log goes to a file, so it doesn't interleave with Conan's output), waits until it answers on port 9300, then builds a greet package, uploads it, deletes it from the local cache and installs it back from the server:
grep -A1 -E '^\[(write_permissions|read_permissions|users)\]' ~/.conan_server/server.conf
conan_server > server.log 2>&1 &
until curl -s http://localhost:9300/v2/ping > /dev/null; do sleep 0.2; done
mkdir greet && cd greet
conan new cmake_lib -d name=greet -d version=1.0.0 > /dev/null 2>&1
find . -exec touch -h -d @$SOURCE_DATE_EPOCH {} +
conan create . -tf="" -c tools.build:jobs=1 > /dev/null 2>&1
conan remote add local http://localhost:9300
conan remote login local demo -p demo
conan upload "greet/1.0.0" -r local -c 2>&1 | grep -E 'Uploading (recipe|package)'
echo "--- on the server:"
conan list "greet/1.0.0:*" -r local 2>/dev/null | sed 's/ ([0-9-]* [0-9:]* UTC)//' | head -n 7
conan remove "greet/*" -c > /dev/null 2>&1
echo "--- fresh install from the server:"
conan install --requires=greet/1.0.0 -r local 2>&1 | grep -E 'Downloaded (recipe|package)|- Download(ed)? \('
kill %1[write_permissions]
*/*@*/*: demo
--
[read_permissions]
*/*@*/*: *
--
[users]
demo: demo
Authenticated in remote 'local' with user 'demo'
Changed user of remote 'local' from 'None' (anonymous) to 'demo' (authenticated)
greet/1.0.0: Uploading recipe 'greet/1.0.0#985a47244e0721362a6bfde1360bb9d4' (2.9KB)
greet/1.0.0: Uploading package 'greet/1.0.0#985a47244e0721362a6bfde1360bb9d4:838c313f1b7acdfd23b222f0156e7c264dcc2515#6cc0d663e7adf144c165b39c9be03699' (2.2KB)
--- on the server:
local
greet
greet/1.0.0
revisions
985a47244e0721362a6bfde1360bb9d4
packages
838c313f1b7acdfd23b222f0156e7c264dcc2515
--- fresh install from the server:
greet/1.0.0: Downloaded recipe revision 985a47244e0721362a6bfde1360bb9d4
greet/1.0.0#985a47244e0721362a6bfde1360bb9d4 - Downloaded (local)
greet/1.0.0#985a47244e0721362a6bfde1360bb9d4:838c313f1b7acdfd23b222f0156e7c264dcc2515#6cc0d663e7adf144c165b39c9be03699 - Download (local)
greet/1.0.0: Downloaded package revision 6cc0d663e7adf144c165b39c9be03699
What happened, step by step:
server.confmaps package patterns (name/version@user/channel) to users:demomay write everything, and*lets anyone, even anonymous clients, read. Users and their passwords sit in plain text under[users], one more reason this is a test server.conan remote loginexchanged the password for a token; uploads are refused without it.conan upload "greet/1.0.0" -csent the recipe and its binary (-cconfirms without asking), and the server now lists the recipe revision and the package id.- After
conan remove, the install found nothing in the cache, so it downloaded both the recipe and the prebuilt binary (- Download (local)) instead of building, which is the whole point of a binary remote. A teammate's machine or a CI job with the same profile gets that binary too. - The
find … touchline pins file times, so the compressed sizes (2.9KB) are the same on every run; in real use you don't need it.
Stop the server with kill %1 (or run it as a service). A real deployment needs HTTPS, so put it behind a reverse proxy, or use Artifactory below.
Uploading
conan upload "greet/1.0.0" -r company -c # recipe + all its binaries in the cache
conan upload "greet/1.0.0:*" -r company -c --only-recipe # just the recipe
conan upload "*" -r company -c --list=pkglist.json # exactly what a previous command produced-c confirms without prompting. In CI, conan create ... --format=json > build.json followed by conan list --graph=build.json --graph-binaries=build --format=json > pkglist.json and conan upload --list=pkglist.json -r company -c uploads exactly the binaries that job built, nothing else.
Artifactory (Community Edition)
JFrog Artifactory is the server most companies use for Conan. The Artifactory Community Edition for C/C++ is free and supports Conan repositories. A typical setup has three repositories:
| Repository | Type | Purpose |
|---|---|---|
conan-local |
local | your packages, uploaded by CI |
conancenter-remote |
remote | a caching proxy of ConanCenter |
conan |
virtual | one URL that combines both; developers add only this one |
docker run -d --name artifactory -p 8081:8081 -p 8082:8082 releases-docker.jfrog.io/jfrog/artifactory-cpp-ce:latest
conan remote add artifactory http://localhost:8081/artifactory/api/conan/conan
conan remote login artifactory admin -p '<password>'The virtual repository gives you a single place to apply permissions, retention and promotion (copying a tested package from a dev repository to release), and the remote proxy keeps working if ConanCenter is slow or a package disappears upstream. The Toolkit lesson lists the JFrog CLI commands that automate this.
Test yourself
Which remote type can't store binaries?
- Artifactory
- conan_server
- local-recipes-index
- ConanCenter
Why should private remotes come before public ones, or replace them with a proxy?
- Private remotes are faster
- To prevent dependency confusion: a public package with your private package's name could be picked first
- Conan requires it
- Public remotes don't support search
What does an Artifactory *virtual* Conan repository do?
- Runs builds
- Combines local and remote repositories behind one URL
- Stores only virtual machines
- Replaces Conan's cache