← 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

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.

Suggested action:

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
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.
qwen3.6-35b-a3b-mtp-q6 Closed. Build failures with git-based dependencies were resolved by adding git to the charmcraft.yaml build-packages configuration. No code changes were required.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#490 pack fails with ERROR: Cannot find command 'git' charmcraft closed Resolved by adding parts: charm: build-packages: [git] to charmcraft.yaml to install required dependencies. The issue was closed after confirming this configuration addresses the missing git error on fresh installs.
77%
#55 `charmcraft build` breaks when pip packages come from github charmcraft closed The charmcraft snap lacked git, causing pip to fail when installing GitHub dependencies. Maintainers added preliminary git support in snap v0.2, resolving the issue. The reporter confirmed the fix works.
76%
#1747 Failed to run the build script for part 'charm' charmcraft closed Build script failure during charmcraft pack was resolved. The issue was closed after the maintainer acknowledged the report and merged the fix in PR #1751.
76%