← Back to issue list

sources module unaware of the environment

View original Github issue

Metadata

Project
craft-parts
Number
#806
Type
issue
State
open
Author
upils
Labels
—
Created
Updated
Closed
—

Current evaluation

Source pulls reportedly ignore the consuming application's environment, so snap-packaged consumers can miss snap PATH tools and invoke incompatible binaries; the issue remains untriaged.

Suggested action: needs triage

Reason: The report provides a concrete imagecraft configuration and a spread-test log where git clone ignores the snap-packaged tool and invokes an incompatible installed version. However, there are no labels, maintainer comments, or assignment, and no source-specific resolving commit was confirmed; PR #925 and PR #1608 may cover parts of the affected path but require scope verification.

Evaluated by: mr-cal-bot

Impact: 57 Quick Win: 24 Complexity: 48 Confidence: 86 Actionability: 82

Issue body

### Bug Description The [sources](https://github.com/canonical/craft-parts/tree/main/craft_parts/sources) modules in craft_parts executes subcommands without passing env vars. So when using the lib as a project running in a snap, env vars from the snap, and especially the PATH, are not considered. See [current log output](https://github.com/canonical/imagecraft/actions/runs/10315021793/job/28554568598?pr=54) of imagecraft spread tests. `git` is not found on the system (even though it is packaged in the snap), then installed. But the installed version is not compatible and unable to properly handle the given command. See [the related discussion on matrix](https://matrix.to/#/!GGqzbFAUQprdPgYYCM:ubuntu.com/$Lj7xtjSH1a3XZFeW0iLFK-j1AYkaPostfMMb4tar0Hw?via=ubuntu.com&via=matrix.org&via=envs.net) for context. ### To Reproduce Create a simple craft app using craft_parts and consuming a part using a plugin calling the sources modules. Example of a plugin in imagecraft: [gadget plugin](https://github.com/canonical/imagecraft/blob/main/imagecraft/plugins/gadget.py). The following YAML is to be run with imagecraft. Following this [how-to build a basic image with imagecraft](https://canonical-imagecraft.readthedocs-hosted.com/en/latest/howto/basic_image/) on a 18.04 machine should reproduce the issue. ### part yaml ```shell name: ubuntu-server-amd64 version: "1" base: ubuntu@24.04 series: noble platforms: amd64: build-for: [amd64] build-on: [amd64] package-repositories: - type: apt components: [main, restricted, universe, multiverse] url: http://archive.ubuntu.com/ubuntu/ pocket: updates used-for: build parts: gadget: plugin: gadget source: https://github.com/snapcore/pc-gadget.git source-branch: classic rootfs: plugin: ubuntu-seed ubuntu-seed-pocket: updates ubuntu-seed-germinate: urls: - "git://git.launchpad.net/~ubuntu-core-dev/ubuntu-seeds/+git/" branch: noble vcs: true names: - server - minimal - standard - cloud-image ubuntu-seed-kernel: linux-image-generic ubuntu-seed-extra-snaps: [snapd] stage: - -rootfs/etc/cloud/cloud.cfg.d/90_dpkg.cfg - -rootfs/dev/stderr # workaround until u-i cleans it - -rootfs/dev/stdin # workaround until u-i cleans it - -rootfs/dev/stdout # workaround until u-i cleans it cloud-init: plugin: dump source: cloud-init/ organize: '*': rootfs/ ``` ### Relevant log output ```shell 2024-08-09T07:10:18.4712656Z 2024-08-09 07:10:14.332 Initialising lifecycle 2024-08-09T07:10:18.4713825Z 2024-08-09 07:10:14.333 ignore patterns: [] 2024-08-09T07:10:18.4714769Z 2024-08-09 07:10:14.333 source build packages: {'git'} 2024-08-09T07:10:18.4715994Z 2024-08-09 07:10:14.333 plugin build packages: {'make'} 2024-08-09T07:10:18.4717724Z 2024-08-09 07:10:14.333 plugin build snaps: {'i', '-', 'a', 'b', 't', 'g', 'u', 'n', 'e', 'm'} 2024-08-09T07:10:18.4718928Z 2024-08-09 07:10:14.334 Installing build-packages 2024-08-09T07:10:18.4720367Z 2024-08-09 07:10:14.334 Requested build-packages: ['git', 'make'] 2024-08-09T07:10:18.4721841Z 2024-08-09 07:10:16.746 Marking git (and its dependencies) to be fetched 2024-08-09T07:10:18.4723060Z 2024-08-09 07:10:16.746 package: git 2024-08-09T07:10:18.4724485Z 2024-08-09 07:10:16.761 Marking make (and its dependencies) to be fetched 2024-08-09T07:10:18.4725899Z 2024-08-09 07:10:16.761 package: make 2024-08-09T07:10:18.4728001Z 2024-08-09 07:10:16.806 Requested build-packages already installed: ['git', 'make'] 2024-08-09T07:10:18.4729985Z 2024-08-09 07:10:17.138 Installing build-snaps [...] 2024-08-09T07:10:18.4886486Z 2024-08-09 07:10:17.223 Pulling gadget 2024-08-09T07:10:18.4893619Z 2024-08-09 07:10:17.223 execute action gadget:Action(part_name='gadget', step=Step.PULL, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None)) 2024-08-09T07:10:18.4896541Z 2024-08-09 07:10:17.225 Executing: git clone --recursive --branch classic https://github.com/snapcore/pc-gadget.git 2024-08-09T07:10:18.4900147Z 2024-08-09 07:10:17.344 :: Cloning into '/home/imagecraft/tests/spread/amd64/classic/ubuntu_server_pc_amd64/parts/gadget/src'... 2024-08-09T07:10:18.4905073Z 2024-08-09 07:10:18.285 :: usage: git submodule [--quiet] [--cached] 2024-08-09T07:10:18.4910611Z 2024-08-09 07:10:18.285 :: or: git submodule [--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>] [...] ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 57
Quick Win: 24
Complexity: 48
Confidence: 86
Actionability: 82
needs triage Source pulls reportedly ignore the consuming application's environment, so snap-packaged consumers can miss snap PATH tools and invoke incompatible binaries; the issue remains untriaged.
qwen/qwen3.6-35b-a3b
Impact: 75
Quick Win: 42
Complexity: 30
Confidence: 70
Actionability: 80
keep open craft_parts sources modules don't pass environment variables to subprocess calls, breaking execution in snap environments where PATH includes snap-packaged binaries.
qwen/qwen3.8-27b
Impact: 55
Quick Win: 25
Staleness: 70
Complexity: 55
Confidence: 60
Support Request: 5
needs triage craft-parts sources modules run subcommands without passing the process environment, so PATH/env vars from a snap (e.g. imagecraft) are ignored and git is not found. Unlabeled, no maintainer response, last activity ~18 months ago.
qwen/qwen3.6-35b-a3b
Staleness: 90
Complexity: 45
Confidence: 85
Support Request: 10
needs triage Bug report detailing that craft_parts sources modules fail to pass environment variables (like PATH) to subprocesses, causing command failures in snap environments. Unlabelled and inactive for over a year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 50
Confidence: 80
Support Request: 5
needs triage craft_parts sources module ignores environment variables when executing subcommands, causing failures in snap environments. Unlabeled, no maintainer comments, inactive for over a year.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/craft-parts#925 (confidence 58%)

    Commit 11be8c7a uses craft.git where possible, which may avoid this Git executable lookup but does not establish a general environment fix.

  • Related To: canonical/craft-parts#1608 (confidence 55%)

    Commit 0f7a4b1c adds an application-configurable build environment; its propagation to source pull handlers is unverified.

Related issues

No related issues found above the similarity threshold.