Add SNAPCRAFT_PROJECT_DIR environment variable.
Metadata
Current evaluation
Merged PR #2534 (commit 3d4483d6f, 'project loader: add SNAPCRAFT_PROJECT_DIR environment variable') by tonysimpson, fixing Launchpad bug 1824417; the var still ships in snapcraft/parts/lifecycle.py global environment.
Resolution: closed resolved
Reason: The PR was approved and merged into master as commit 3d4483d6f, adding SNAPCRAFT_PROJECT_DIR to the build-time environment (set_global_environment in snapcraft/parts/lifecycle.py sets it to info.project_dir, correct in both host and container builds) and resolving Launchpad bug 1824417.
Evaluated by: mr-cal-bot
No scores available.
Issue body
New variable pointing to the project directory, the directory
the snapcraft command was run from. This variable should be correct
regardless of what build environment (container or host) the build
is running in. This allows easy reference to supporting script or
other resources inside snapcraft.yaml overrides sections.
Fixes https://bugs.launchpad.net/snapcraft/+bug/1824417
- [X] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [X] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [X] Have you successfully run `./runtests.sh static`?
- [X] Have you successfully run `./runtests.sh tests/unit`?
-----
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #2534 (commit 3d4483d6f, 'project loader: add SNAPCRAFT_PROJECT_DIR environment variable') by tonysimpson, fixing Launchpad bug 1824417; the var still ships in snapcraft/parts/lifecycle.py global environment. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #2534 in commit 3d4483d6f, adding SNAPCRAFT_PROJECT_DIR to point to the project directory in host and container builds and fixing Launchpad bug 1824417. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged #2534 via commit 3d4483d6f, adding SNAPCRAFT_PROJECT_DIR so builds can reference files from the directory where Snapcraft was invoked. Resolves Launchpad bug #1824417. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged after approval and CI checks. Adds SNAPCRAFT_PROJECT_DIR environment variable pointing to the project directory. Resolves Launchpad bug 1824417. Reviewer noted minor coverage decrease and suggested follow-up integration tests. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged into master, adding the SNAPCRAFT_PROJECT_DIR environment variable to reference the project directory in snapcraft.yaml overrides. Resolves bug #1824417. Maintainer requested follow-up integration tests. |
Update history
No update history recorded yet.
Related work
-
Related To:
snapcraft#2500
(confidence 30%)
Reviewed/approved the change (3 unresolved review comments left open at merge)
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #757 Export important project variables | snapcraft | merged | Merged PR #757 (commit dc0b68174) exports SNAPCRAFT_PROJECT_NAME, SNAPCRAFT_PROJECT_VERSION, SNAPCRAFT_PROJECT_STAGE and per-part SNAPCRAFT_PART_INSTALL, refactoring _expand_env into the project loader so variables work in fixed yaml fields. LP #1588336. | |
| #1824417 Expose project directory path to the scriptlets | snapcraft (launchpad) | closed | Feature request for a project-dir env var in scriptlets was implemented by PR #2534 (commit 3d4483d6f), adding SNAPCRAFT_PROJECT_DIR; shipped in snapcraft 3.4.1 (release commit 16de5d39f) and the LP bug was closed. | |
| #2744 project_loader: load build-environment after snapcraft environment | snapcraft | merged | Merged PR #2744 (commit f3799a5dc) reordered project-loader evaluation so build-environment loads after Snapcraft's environment, enabling variables such as $SNAPCRAFT_PART_INSTALL. | |
| #2122 many: introduce variables for part src and build | snapcraft | merged | Merged in commit 31307b5de via #2122, adding source/build directory variables and centralizing SNAPCRAFT_* environment handling; resolved LP #1763028. | |
| #1822375 SNAPCRAFT_PART_INSTALL doesn't expand in build-environment assignments | snapcraft (launchpad) | closed | Fixed in PR #841 (commit 6cef6c0f9) by replacing SNAPCRAFT_PART_INSTALL in part attributes with the part-specific install path. | |
| #1619418 parser needs to replace project level variables | snapcraft (launchpad) | closed | Parser-side substitution of SNAPCRAFT_PROJECT_NAME/VERSION landed via merged PR snapcore/snapcraft#773 (commit 362d6a5f5), closing the Launchpad bug that requested it. |