← Back to issue list

Charmcraft fails to build due to lack of Git

View original Github issue

Metadata

Project
charmcraft
Number
#605
Type
issue
State
closed
Author
Artonus
Labels
—
Created
Updated
Closed

Current evaluation

Resolved as a build-environment configuration issue: the reporter fixed the failure by adding git to parts.charm.build-packages in charmcraft.yaml.

Resolution: closed not a bug

Reason: The build environment lacked Git rather than Charmcraft failing to install it. The reporter confirmed that declaring git under parts.charm.build-packages resolved the same failure documented in canonical/charmcraft#490.

Evaluated by: mr-cal-bot

No scores available.

Issue body

Hi there! I have found an issue in which charmcraft fails to pack the operator when the package specification in the `requirements.txt` contains the reference to the git repository in example: ` git+https://github.com/canonical/operator/#egg=ops` Lxd version : `4.0.8` Charmcraft version: `1.2.1` My `charmcraft.yaml` file has the following contents: ``` # Learn more about charmcraft.yaml configuration at: # https://juju.is/docs/sdk/charmcraft-config type: "charm" bases: - build-on: - name: "ubuntu" channel: "20.04" run-on: - name: "ubuntu" channel: "20.04" ``` The error logs are following: ``` 2021-11-19 14:20:56,206 craft_parts.executor.step_handler DEBUG :: Creating the 'install' hook script pointing to dispatch mm 2021-11-19 14:20:56,206 craft_parts.executor.step_handler DEBUG :: Creating the 'start' hook script pointing to dispatch mm 2021-11-19 14:20:56,206 craft_parts.executor.step_handler DEBUG :: Creating the 'upgrade-charm' hook script pointing to dispatch mm 2021-11-19 14:20:56,206 craft_parts.executor.step_handler DEBUG :: Installing dependencies mm 2021-11-19 14:20:56,206 craft_parts.executor.step_handler DEBUG :: Running external command ['pip3', '--version'] mm 2021-11-19 14:20:56,680 craft_parts.executor.step_handler DEBUG :: :: pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8) mm 2021-11-19 14:20:56,710 craft_parts.executor.step_handler DEBUG :: Running external command ['pip3', 'install', '--target=/root/project/build/parts/charm/install/venv', '--requirement=requirements.txt'] mm 2021-11-19 14:20:57,355 craft_parts.executor.step_handler DEBUG :: :: Collecting ops mm 2021-11-19 14:20:57,355 craft_parts.executor.step_handler DEBUG :: :: Cloning https://github.com/canonical/operator/ to /tmp/pip-install-8zar0ant/ops mm 2021-11-19 14:20:57,355 craft_parts.executor.step_handler DEBUG :: :: Running command git clone -q https://github.com/canonical/operator/ /tmp/pip-install-8zar0ant/ops mm 2021-11-19 14:20:57,356 craft_parts.executor.step_handler DEBUG :: :: ERROR: Error [Errno 2] No such file or directory: 'git' while executing command git clone -q https://github.com/canonical/operator/ /tmp/pip-install-8zar0ant/ops mm 2021-11-19 14:20:57,356 craft_parts.executor.step_handler DEBUG :: :: ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH? mm 2021-11-19 14:20:57,384 craft_parts.executor.step_handler DEBUG :: Executing ['pip3', 'install', '--target=/root/project/build/parts/charm/install/venv', '--requirement=requirements.txt'] failed with return code 1 mm 2021-11-19 14:20:57,384 craft_parts.executor.step_handler DEBUG :: Traceback (most recent call last): mm 2021-11-19 14:20:57,385 craft_parts.executor.step_handler DEBUG :: File "/snap/charmcraft/x2/lib/charmcraft/charm_builder.py", line 334, in <module> mm 2021-11-19 14:20:57,385 craft_parts.executor.step_handler DEBUG :: main() mm 2021-11-19 14:20:57,385 craft_parts.executor.step_handler DEBUG :: File "/snap/charmcraft/x2/lib/charmcraft/charm_builder.py", line 330, in main mm 2021-11-19 14:20:57,385 craft_parts.executor.step_handler DEBUG :: builder.build_charm() mm 2021-11-19 14:20:57,385 craft_parts.executor.step_handler DEBUG :: File "/snap/charmcraft/x2/lib/charmcraft/charm_builder.py", line 90, in build_charm mm 2021-11-19 14:20:57,385 craft_parts.executor.step_handler DEBUG :: self.handle_dependencies() mm 2021-11-19 14:20:57,385 craft_parts.executor.step_handler DEBUG :: File "/snap/charmcraft/x2/lib/charmcraft/charm_builder.py", line 244, in handle_dependencies mm 2021-11-19 14:20:57,385 craft_parts.executor.step_handler DEBUG :: raise CommandError("problems installing dependencies") mm 2021-11-19 14:20:57,385 craft_parts.executor.step_handler DEBUG :: charmcraft.cmdbase.CommandError: problems installing dependencies mm 2021-11-19 14:20:57,405 charmcraft ERROR Parts processing error: Failed to run the build script for part 'charm'. (full execution logs in '/tmp/charmcraft.log') 2021-11-19 14:20:57,575 craft_providers.lxd.lxc DEBUG Executing on host: lxc --project charmcraft config device show local:charmcraft-mc-operator-1839996-0-0-amd64 2021-11-19 14:20:57,618 craft_providers.lxd.lxc DEBUG Executing on host: lxc --project charmcraft config device remove local:charmcraft-mc-operator-1839996-0-0-amd64 disk-/root/project 2021-11-19 14:20:57,686 craft_providers.lxd.lxc DEBUG Executing on host: lxc --project charmcraft stop local:charmcraft-mc-operator-1839996-0-0-amd64 2021-11-19 14:20:58,713 charmcraft ERROR Failed to build charm for bases index '0'. (full execution logs in '/home/bartek/snap/charmcraft/common/charmcraft-log-2asxqh4w') ``` When I specify the ops module using the standard notation `ops >= 1.2.0` everything works well. Is there any reason that the Git is not installed on the build machine? Thanks a lot!

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed not a bug Resolved as a build-environment configuration issue: the reporter fixed the failure by adding git to parts.charm.build-packages in charmcraft.yaml.
stealth/space-bunny-alpha — closed not a bug Git-based requirements built successfully after adding git to parts.charm.build-packages in charmcraft.yaml; the reporter confirmed this solution in canonical/charmcraft#490.
qwen3.6-35b-a3b-mtp-q6 — — Charmcraft fails to build when installing git-referenced dependencies due to a missing git binary in the build environment. The reporter resolved the issue by adding git to build-packages in charmcraft.yaml. Closed as resolved.
qwen/qwen3.6-35b-a3b — — Resolved via configuration. Adding build-packages: [git] to the charm part in charmcraft.yaml installs Git in the build environment, allowing pip to clone git-based dependencies from requirements.txt.
qwen3.6-35b-a3b-mtp-q6 — — Resolved by adding git to the charm part's build-packages in charmcraft.yaml. The build environment lacked git, causing pip to fail when cloning git-based dependencies. Specifying git as a build package fixes the error.

Update history

No update history recorded yet.

Related work

  • Related To: canonical/charmcraft#490 (confidence 98%)

    Same missing-git build failure; adding git as a charm build package was the confirmed workaround.

Related issues

Issue Project State Summary Similarity
#490 pack fails with ERROR: Cannot find command 'git' charmcraft closed Resolved as a missing build dependency: add git under parts.charm.build-packages in charmcraft.yaml; the maintainer provided this configuration before closing the issue.
80%
#502 charmcraft internal error! BaseConfigurationError: Failed to install apt-utils charmcraft closed Resolved through project configuration: the author added git to parts.charm.build-packages in charmcraft.yaml; no Charmcraft code fix was reported.
76%
#55 `charmcraft build` breaks when pip packages come from github charmcraft closed GitHub requirements now work in snap-packaged Charmcraft 0.2, which added preliminary git support; the reporter confirmed the fix. Released via PR #58.
75%
#498 charmcraft 1.2.1 (candidate): cannot pull python deps with git charmcraft closed Reported that charmcraft 1.2.1 fails with "Cannot find command 'git'" when pulling Git-based Python deps. Maintainer facundobatista closed it as config: add git to build-packages (see Charm Discourse thread 4986); no code change.
75%
#883 Charmcraft (2.0.0) pack with build-packages failing on GitHub actions (but 2.1.0 - latest/candidate - is working) charmcraft closed Charmcraft 2.0.0 failed to install build packages after a GitHub runner update; running apt-get update worked. Maintainers closed it as likely unrelated to Charmcraft.
71%