Snapcraft doesn't set parts lib & include directories to CFLAGS/CXXFLAGS/LDFLAGS/LD_LIBRARY_PATH since Snapcraft 4.0
Metadata
Current evaluation
CMake stage discovery was fixed in Snapcraft 7.1.2 by PR #3217. Automatic LD_LIBRARY_PATH support was closed as intentional: core20+ requires users to set it explicitly.
Resolution: closed not a bug
Reason: PR #3217 removed the need for CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH in 7.1.2. Maintainer cmatsuoka rejected automatic LD_LIBRARY_PATH expansion because staged libraries must not automatically enter part build environments; core22's unset-variable error is expected.
Evaluated by: mr-cal-bot
No scores available.
Issue body
Since Snapcraft 4.0, configuration systems (like cmake) & gcc are unable to find libraries & headers built in parts. Built binaries running at build time (e.g. codegen) using libraries from the parts are unable to run. As a workaround, I used to set LD_LIBRARY_PATH to $SNAPCRAFT_STAGE/usr/lib/$SNAPCRAFT_ARCH_TRIPLET:$LD_LIBRARY_PATH and specify $SNAPCRAFT_STAGE-related paths to cmake variables manually. However, with Snapcraft 7.0 & core22 this no longer works, I'm getting "/bin/bash: line 41: LD_LIBRARY_PATH: unbound variable". I really hope that this will be fixed, so there finally will be no need to specify paths manually for every library built in snapcraft.yml. I'm surprised that no one has reported this within two years though.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed not a bug | CMake stage discovery was fixed in Snapcraft 7.1.2 by PR #3217. Automatic LD_LIBRARY_PATH support was closed as intentional: core20+ requires users to set it explicitly. | |
| stealth/space-bunny-alpha | — | closed not a bug | CMake stage discovery was fixed in Snapcraft 7.1.2 by #3217. Remaining LD_LIBRARY_PATH behavior was closed as intentional: core20+ requires users to set it, while core22 reports unset expansion. | |
| stealth/space-bunny-alpha | — | closed stale | Closed without a fix, superseding reference, or maintainer explanation; the reported omission of parts’ header and library paths from build flags remained unresolved. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution or comments. The regression causing Snapcraft to omit parts library and header paths from build flags remains unfixed. Inactivity indicates the issue was abandoned. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. The regression preventing Snapcraft from automatically setting parts build environment variables since v4.0 remains unfixed. The issue was abandoned due to inactivity. |
Update history
| Date | Change |
|---|---|
| created |
Related work
-
Likely Fixed By:
canonical/snapcraft#3217
(confidence 99%)
Released in Snapcraft 7.1.2 to restore CMake discovery of staged headers and libraries.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1723208 Snapcraft snap doesn't work natively on trusty | snapcraft (launchpad) | closed | Fixed Trusty classic-snap builds by preventing bundled-library LD_LIBRARY_PATH values from leaking into build commands; merged in snapcore/snapcraft#1635 as da9181487. | |
| #1975498 PATH/LD_LIBRARY_PATH not set in snapcraft 7.0 | snapcraft (launchpad) | closed | PATH/LD_LIBRARY_PATH regression in core22 snaps was fixed by PR #3758, merged as 6e8835dc8 and released in Snapcraft 7.1. | |
| #2011842 Incorrect default LD_LIBRARY_PATH | snapcraft (launchpad) | open | Core22+ Snapcraft emits unsupported shell expansion for LD_LIBRARY_PATH; the behavior is reproduced and remains blocked on snapd environment-list support. |