conan workspace

Warning

This feature is part of the new incubating features. This means that it is under development, and looking for user testing and feedback. For more info see Incubating section.

The conan workspace command allows to open, add, and remove packages from the current workspace. Check the conan workspace -h help and the help of the subcommands to check their usage.

$ conan workspace -h
Error executing: conan workspace -h
ERROR: Workspace command disabled without CONAN_WORKSPACE_ENABLE env var,please read the docs about this 'incubating' feature

conan workspace init

$ conan workspace init -h
Error executing: conan workspace init -h
ERROR: Workspace command disabled without CONAN_WORKSPACE_ENABLE env var,please read the docs about this 'incubating' feature

The command conan workspace init [path] creates an empty conanws.yml file and a minimal conanws.py within that path if they don’t exist yet. That path can be relative to your current working directory.

$ conan workspace init myfolder
Created empty conanws.yml in myfolder
Created minimal conanws.py in myfolder

conan workspace [add | remove]

$ conan workspace add -h
Error executing: conan workspace add -h
ERROR: Workspace command disabled without CONAN_WORKSPACE_ENABLE env var,please read the docs about this 'incubating' feature
$ conan workspace remove -h
Error executing: conan workspace remove -h
ERROR: Workspace command disabled without CONAN_WORKSPACE_ENABLE env var,please read the docs about this 'incubating' feature

Use these commands to add or remove editable packages to the current workspace. The conan workspace add <path> folder must contain a conanfile.py. That path can be relative to your current workspace.

The conanws.py has a default implementation, but it is possible to override the default behavior:

conanws.py
import os
from conan import Workspace

class MyWorkspace(Workspace):
   def name(self):
      return "myws"

   def add(self, ref, path, *args, **kwargs):
      self.output.info(f"Adding {ref} at {path}")
      super().add(ref, path, *args, **kwargs)

   def remove(self, path, *args, **kwargs):
      self.output.info(f"Removing {path}")
      return super().remove(path, *args, **kwargs)

conan workspace info

$ conan workspace info -h
Error executing: conan workspace info -h
ERROR: Workspace command disabled without CONAN_WORKSPACE_ENABLE env var,please read the docs about this 'incubating' feature

Use this command to show information about the current workspace

$ cd myfolder
$ conan new workspace
$ conan workspace info
WARN: Workspace found
WARN: Workspace is a dev-only feature, exclusively for testing
name: myfolder
folder: /path/to/myfolder
packages
  - path: liba
    ref: liba/0.1
  - path: libb
    ref: libb/0.1
  - path: app1
    ref: app1/0.1

conan workspace clean

$ conan workspace clean -h
Error executing: conan workspace clean -h
ERROR: Workspace command disabled without CONAN_WORKSPACE_ENABLE env var,please read the docs about this 'incubating' feature

The new conan workspace clean command removes by default the output-folder of every package in the workspace if it was defined. If it is not defined, it won’t remove anything by default, as removing files in user space is dangerous, and could destroy user changes or files. It would be recommended that users manage that cleaning with git clean -xdf or similar strategies. It is also possible to define a custom clean logic by implementing the clean() method:

class Ws(Workspace):
   def name(self):
      return "my_workspace"
   def clean(self):
      self.output.info("MY CLEAN!!!!")

conan workspace open

$ conan workspace open -h
Error executing: conan workspace open -h
ERROR: Workspace command disabled without CONAN_WORKSPACE_ENABLE env var,please read the docs about this 'incubating' feature

The new conan workspace open command implements a new concept. The packages containing an scm information in the conandata.yml (with git.coordinates_to_conandata()) can be automatically cloned and checkout inside the current workspace from their Conan recipe reference (including recipe revision).

conan workspace root

$ conan workspace root -h
Error executing: conan workspace root -h
ERROR: Workspace command disabled without CONAN_WORKSPACE_ENABLE env var,please read the docs about this 'incubating' feature

Return the folder containing the conanws.py/conanws.yml workspace file.

conan workspace source

$ conan workspace source -h
Error executing: conan workspace source -h
ERROR: Workspace command disabled without CONAN_WORKSPACE_ENABLE env var,please read the docs about this 'incubating' feature

The command conan workspace source performs the equivalent of conan source <package-path> for every package defined within the workspace.

conan workspace install

$ conan workspace install -h
Error executing: conan workspace install -h
ERROR: Workspace command disabled without CONAN_WORKSPACE_ENABLE env var,please read the docs about this 'incubating' feature

The command conan workspace install performs the equivalent of conan install <package-path> for every package defined within the workspace in the correct order.

conan workspace build

$ conan workspace build -h
Error executing: conan workspace build -h
ERROR: Workspace command disabled without CONAN_WORKSPACE_ENABLE env var,please read the docs about this 'incubating' feature

The command conan workspace build performs the equivalent of conan build <package-path> for every package defined within the workspace in the correct order.

conan workspace create

$ conan workspace create -h
Error executing: conan workspace create -h
ERROR: Workspace command disabled without CONAN_WORKSPACE_ENABLE env var,please read the docs about this 'incubating' feature

The command conan workspace create performs the equivalent of conan create <package-path> for every package defined within the workspace in the correct order. They will be created in the Conan cache, not locally.

conan workspace super-install

$ conan workspace super-install -h
Error executing: conan workspace super-install -h
ERROR: Workspace command disabled without CONAN_WORKSPACE_ENABLE env var,please read the docs about this 'incubating' feature

The command conan workspace super-install is useful to install and build the current workspace as a monolithic super-project of the editables.

By default it uses all the editable packages in the workspace. It is possible to select only a subset of them with the conan workspace super-install --pkg=pkg_name1 --pkg=pkg_name2 optional arguments. Only the subgraph of those packages, including their dependencies and transitive dependencies will be installed.

See also

Read the Workspace tutorial section. Read the conan new workspace command section.