← Back to issue list

Incorrect default LD_LIBRARY_PATH

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#2011842
Type
issue
State
open
Author
~saviq
Labels
—
Created
Updated
Closed
—

Current evaluation

Core22+ Snapcraft emits unsupported shell expansion for LD_LIBRARY_PATH; the behavior is reproduced and remains blocked on snapd environment-list support.

Suggested action: keep open

Reason: A maintainer reproduced the failure and traced it to core22 moving LD_LIBRARY_PATH from the shell-based snapcraft-runner into snap.yaml, where snapd performs only simple variable replacement. A later comment explicitly identifies snapd environment-list support in LP #1868460 as the solution, and current Snapcraft code and fixtures still emit the unsupported expansion.

Evaluated by: mr-cal-bot

Impact: 52 Quick Win: 12 Complexity: 70 Confidence: 95 Actionability: 76

Issue body

Given the following YAML: ```yaml name: env-bug base: core22 version: '0.1' summary: foo description: bar grade: devel confinement: strict apps:   hello-world:     environment:       plain: $LD_LIBRARY_PATH       bracketed: ${LD_LIBRARY_PATH}       prepended: foo:${LD_LIBRARY_PATH}       complex: ${LD_LIBRARY_PATH:-Foo}       snapcrafts: ${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}     command: echo parts:   my-part:     plugin: nil     override-build: |       touch ${CRAFT_PART_INSTALL}/foo       chmod 555 ${CRAFT_PART_INSTALL}/foo ``` Snapcraft sets the default top-level `environment.LD_LIBRARY_PATH` to: ```yaml # snap/meta.yaml environment   LD_LIBRARY_PATH: ${SNAP_LIBRARY_PATH}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ``` But there's no shell to interpret that expansion: ```shell $ snap run --shell my-snap-name.hello-world -c "printenv plain" /var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void $ snap run --shell my-snap-name.hello-world -c "printenv bracketed" /var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void $ snap run --shell my-snap-name.hello-world -c "printenv prepended" foo:/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void $ snap run --shell my-snap-name.hello-world -c "printenv complex" $ snap run --shell my-snap-name.hello-world -c "printenv snapcrafts" $ ``` As far I can tell, there's only simple string replacement happening.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 52
Quick Win: 12
Complexity: 70
Confidence: 95
Actionability: 76
keep open Core22+ Snapcraft emits unsupported shell expansion for LD_LIBRARY_PATH; the behavior is reproduced and remains blocked on snapd environment-list support.
stealth/space-bunny-alpha
Impact: 45
Quick Win: 9
Complexity: 72
Confidence: 94
Actionability: 74
keep open Snapcraft-generated core22+ snaps still emit unsupported shell expansion for LD_LIBRARY_PATH; complex app environment expressions are lost, pending snapd environment-list support.
stealth/space-bunny-alpha
Impact: 58
Quick Win: 23
Complexity: 55
Confidence: 93
Actionability: 87
needs triage Reproducible environment-expansion bug: Snapcraft emits unsupported shell syntax in default LD_LIBRARY_PATH, so app environment references lose or empty values. The current code and tests still encode the faulty expansion.
qwen3.6-35b-a3b-mtp-q6
Impact: 60
Quick Win: 36
Staleness: 85
Complexity: 40
Confidence: 50
Support Request: 10
needs triage Bug report about snapcraft not properly handling shell expansion in environment variables like ${LD_LIBRARY_PATH:-Foo}
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 45
Confidence: 85
Support Request: 5
needs triage Bug report detailing incorrect string replacement for default LD_LIBRARY_PATH in Snapcraft, causing unexpected environment variable expansion. Unlabeled and unresponded to for over three years.
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 40
Confidence: 85
Support Request: 5
needs triage Snapcraft incorrectly handles shell variable expansion in default LD_LIBRARY_PATH, performing literal string replacement instead. Unlabelled, zero comments, inactive for over three years.
qwen3.6-35b-a3b-mtp-q6
Staleness: 95
Complexity: 65
Confidence: 85
Support Request: 10
needs triage Snapcraft incorrectly treats shell-style variable expansions in environment variables as literal strings instead of evaluating them. The report is unlabelled, has zero maintainer comments, and has been inactive for over three years.

Update history

Date Change
created

Related work

  • Caused By: snapcore/snapcraft#3758 (confidence 98%)

    The reporter identified this PR as introducing the problematic environment setup.

  • Blocked By: snapd#1868460 (confidence 96%)

    A maintainer stated that snapd implementing environment values as a list should resolve the issue.

Related issues

Issue Project State Summary Similarity
#1486623 LD_LIBRARY_PATH hardcoded at snap creation time -- RPATH snapcraft (launchpad) closed Hardcoded LD_LIBRARY_PATH behavior was declared obsolete: a maintainer said in 2023 that it no longer applies to core22; discussion had moved to canonical/snapcraft#38.
76%
#1992557 snapcraft remote-build snapcraft.yaml validation too strict snapcraft (launchpad) closed Strict validation in snapcraft remote-build rejected empty LD_LIBRARY_PATH for core22 snaps. Resolved by the new remote builder, which fixes the legacy core18/20 implementation bug.
76%
#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.
76%
#4159 Environment stops working in snapcraft if defined snapcraft closed PATH and LD_LIBRARY_PATH are now retained when top-level environment variables are defined for core22+, via merged PR #3741 (ec190695c).
72%
#1978859 Snapcraft doesn't set parts lib & include directories to CFLAGS/CXXFLAGS/LDFLAGS/LD_LIBRARY_PATH since Snapcraft 4.0 snapcraft (launchpad) closed 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.
71%
#1667148 Need a way to set LD_LIBRARY_PATH snapcraft (launchpad) closed Closed as obsolete: current snapd supports setting top-level LD_LIBRARY_PATH to $SNAP/lib and expands snap variables correctly.
71%