← 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

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.

Suggested action: needs triage

Reason: The issue is a genuine bug report (sources modules execute subcommands without env vars, breaking git detection in snap-based consumers like imagecraft) but has no labels, no assignee, and zero comments/maintainer acknowledgement, so it has not been triaged. The current code in craft_parts/sources/base.py still calls os_utils.process_run and subprocess.check_output without an env argument, so the problem appears unfixed, but no maintainer has confirmed scope or a fix plan.

Impact: 55 Quick Win: 24.75 Staleness: 70 Complexity: 55 Confidence: 60 Support Request: 5

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
qwen/qwen3.8-27b
Impact: 55
Quick Win: 24.75
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.
qwen3.6-35b-a3b-mtp-q6
Staleness: 92
Complexity: 30
Confidence: 80
Support Request: 10
close stale craft_parts sources module executes subcommands without passing environment variables like PATH, causing failures in snap environments. Open, unassigned, no comments, inactive for 465 days. Awaiting triage and fix.

Update history

No update history recorded yet.

Related issues

No related issues found above the similarity threshold.