Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sources module unaware of the environment #806

Open
upils opened this issue Aug 9, 2024 · 0 comments
Open

sources module unaware of the environment #806

upils opened this issue Aug 9, 2024 · 0 comments
Labels
Bug Something isn't working

Comments

@upils
Copy link

upils commented Aug 9, 2024

Bug Description

The 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 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 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.

The following YAML is to be run with imagecraft. Following this how-to build a basic image with imagecraft on a 18.04 machine should reproduce the issue.

part yaml

name: ubuntu-server-amd64
version: "1"
base: [email protected]
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

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>]
[...]
@upils upils added the Bug Something isn't working label Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant