{"id":23466,"library":"craft-providers","title":"Craft Providers","description":"Craft-providers is a Python library for managing and provisioning build environments using LXD, Multipass, or Docker. It is part of the Snapcraft ecosystem, currently at version 3.6.0, with a release cadence of approximately monthly.","status":"active","version":"3.6.0","language":"python","source_language":"en","source_url":"https://github.com/canonical/craft-providers","tags":["build","container","lxd","multipass","docker","snapcraft"],"install":[{"cmd":"pip install craft-providers","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Correct import for LXD provider instance.","wrong":"","symbol":"LXDInstance","correct":"from craft_providers.lxd import LXDInstance"},{"note":"Correct import for Multipass provider instance.","wrong":"","symbol":"MultipassInstance","correct":"from craft_providers.multipass import MultipassInstance"},{"note":"The class is named DockerInstance, not Docker.","wrong":"from craft_providers.docker import Docker","symbol":"DockerInstance","correct":"from craft_providers.docker import DockerInstance"}],"quickstart":{"code":"from craft_providers.lxd import LXDInstance\nfrom craft_providers import bases\n\ninstance = LXDInstance(name=\"my-instance\")\ninstance.create(\n    base=bases.BuilddBase(series=\"jammy\")\n)\nwith instance as ctx:\n    print(ctx.execute_run([\"lsb_release\", \"-a\"]))\ninstance.delete()","lang":"python","description":"Creates an LXD container with Ubuntu Jammy, runs a command, then deletes it."},"warnings":[{"fix":"Update code to use new base classes; refer to migration guide.","message":"In craft-providers 2.0, the API was rewritten. The old craft_providers.bases.Base class hierarchy was replaced with craft_providers.bases.BuilddBase and other concrete base classes.","severity":"breaking","affected_versions":"<2.0"},{"fix":"Use .create() instead of .launch().","message":"craft_providers.lxd.LXDInstance.launch() is deprecated in favor of .create() since version 3.0.","severity":"deprecated","affected_versions":">=3.0"},{"fix":"Install LXD and add user to lxd group, then log out and back in.","message":"LXD must be installed and the user must have permission to interact with the LXD socket (usually via lxd group).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from craft_providers.lxd import LXDInstance","cause":"The LXDInstance class is not directly under craft_providers; it is in craft_providers.lxd.","error":"ImportError: cannot import name 'LXDInstance' from 'craft_providers'"},{"fix":"Ensure LXD is installed, the daemon is running, and user is in the lxd group.","cause":"LXD is not installed, not running, or the user lacks permissions.","error":"craft_providers.errors.ProviderError: Failed to launch LXD container"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}