CPATH in Jlink plugin not persisted
Metadata
Current evaluation
Fixed by merged PR #1014 (commit d8d68365) and included in 2.6.1, replacing the piped subshell loop so CPATH persists and correcting jdeps module-dependency handling.
Resolution: closed resolved
Reason: PR #1014, commit d8d68365, fixed the Jlink CPATH variable scope and jdeps parameter ordering. The 2.6.1 changelog confirms the CPATH scope fix.
Evaluated by: mr-cal-bot
No scores available.
Issue body
### Bug Description
Hi! I think I've found a small bug with the Jlink plugin - https://github.com/canonical/craft-parts/blob/main/craft_parts/plugins/jlink_plugin.py#L128-L133
Here, we're trying to add the paths to jars to CPATH variable. However, in bash, piped operator makes the [loop execute within the subshell](https://stackoverflow.com/questions/124167/bash-variable-scope).
This means that the CPATH within the loop gets updated - however, outside the loop, CPATH is not affected. The following code explains the behavior:
```
find ${CRAFT_PART_BUILD}/tmp -type f -name *.jar | while IFS= read -r file; do
CPATH=$CPATH:${file}
echo $CPATH # PRINTS CPATH APPENDED CORRECTLY
done
echo $CPATH # NOT UPDATED, PRINTS "."
```
Currently, Jlink plugin fails due to this small issue :)
### To Reproduce
Jlink produces invalid JVM at the moment without needing to reproduce.
### part yaml
```shell
```
### Relevant log output
```shell
N/A
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merged PR #1014 (commit d8d68365) and included in 2.6.1, replacing the piped subshell loop so CPATH persists and correcting jdeps module-dependency handling. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merged PR #1014, commit d8d68365, which corrected CPATH persistence and jlink --print-module-deps handling. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed Jlink CPATH persistence and module-dependency handling in merged PR #1014 (commit d8d68365). | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without a linked resolution. A piped while loop in the Jlink plugin executed in a subshell, preventing CPATH updates from persisting and breaking JVM generation. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed. The report identified that bash subshell scoping prevented CPATH persistence in the Jlink plugin. The issue was closed without further discussion or a documented resolution. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed. Fixed a bash subshell scope bug in the Jlink plugin that prevented CPATH from persisting outside a piped while loop, resolving JVM generation failures. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed without resolution. The Jlink plugin fails because piping into a while loop creates a subshell, preventing CPATH variable persistence. No fix or pull request was submitted. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/craft-parts#1014
(confidence 100%)
Merged PR containing commit d8d68365 and resolving the reported Jlink CPATH bug.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1014 fix: CPATH persistence | craft-parts | merged | Merged PR #1014 fixed CPATH persistence and jdeps module-dependency handling in the Jlink plugin via commit d8d68365; released in 2.6.1. |