← Back to issue list

Rpath patching overwrites existing rpaths

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1746329
Type
issue
State
closed
Author
~kyrofa
Labels
—
Created
Updated
Closed

Current evaluation

Fixed by snapcore/snapcraft#1896 (commit c543156ff, 'elf: do not strip rpaths that contain $ORIGIN'): the patcher now prepends existing $ORIGIN rpaths to the snap's own rpath list instead of discarding them.

Resolution: closed resolved

Reason: Maintainer ~kyrofa closed the bug pointing to snapcore/snapcraft#1896, merged as commit c543156ff. That commit is on the branch and its logic remains in snapcraft/elf/_patcher.py::get_proposed_rpath, which filters existing rpaths to those containing '$ORIGIN' and prepends them to the computed rpaths; the behaviour is documented in docs/explanation/classic-confinement.rst. The closing comment notes the limitation that only $ORIGIN rpaths are preserved.

Evaluated by: mr-cal-bot

No scores available.

Issue body

Currently Snapcraft uses patchelf to rewrite rpaths for classic snaps to use the libraries in the snap instead of looking on the host for them. This works well if the libraries required by an app are in the ELF header, but this isn't always the case (e.g. if a lib is dlopened). One way to make this work is to set rpaths on one's own, but snapcraft overwrites the rpath during the prime set. Snapcraft should probably keep the rpaths that are already present, and append new ones rather than replacing them.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Fixed by snapcore/snapcraft#1896 (commit c543156ff, 'elf: do not strip rpaths that contain $ORIGIN'): the patcher now prepends existing $ORIGIN rpaths to the snap's own rpath list instead of discarding them.
stealth/space-bunny-alpha — closed resolved Fixed by snapcore/snapcraft#1896 (commit c543156ff): Snapcraft preserves existing rpaths containing $ORIGIN while adding snap library paths.
stealth/space-bunny-alpha — closed stale Closed as abandoned after inactivity: Snapcraft continued overwriting existing RPATHs during prime, and the requested preservation/append behavior was never implemented.
qwen/qwen3.6-35b-a3b — — Abandoned due to inactivity. Snapcraft continues to overwrite existing rpaths during the prime set instead of appending new ones, leaving the suggested fix unimplemented.
qwen/qwen3.6-35b-a3b — — Closed without resolution. Snapcraft overwrites existing rpaths during patching instead of appending new ones, breaking dlopened libraries. No fix or discussion was provided.

Update history

Date Change
created

Related work

  • Likely Fixed By: canonical/snapcraft#1896 (confidence 98%)

    PR 'elf: do not strip rpaths that contain $ORIGIN', merged as c543156ff and cited by the reporter as the fix.

  • Related To: canonical/snapcraft#2019 (confidence 80%)

    Follow-up commit e7b9d745c 'elf: avoid duplicating rpath entries' refining the same rpath-merging logic.

  • Related To: canonical/snapcraft#1781 (confidence 75%)

    Original PR 3eafb9dd6 that introduced patchelf-based rpath setting for classic snaps, which overwrote existing rpaths.

  • Related To: canonical/snapcraft#2085 (confidence 70%)

    Commit 4ed555c5e 'elf: clear the current runpath before setting the rpath' touches the same runpath-clearing behaviour.

Related issues

Issue Project State Summary Similarity
#1570895 Rpath with $ORIGIN fools snapcraft library bundling mechanism snapcraft (launchpad) closed Fixed by ubuntu-core/snapcraft PR #580 (commit 00e37e57d); snapcraft 2.12 no longer copies libraries already in prime and was successfully verified.
78%
#1781 many: set rpath for elf files for classic snapcraft merged Merged as commit 3eafb9dd6, adding patchelf-based $ORIGIN-relative rpaths for ELF files in classic snaps and avoiding LD_LIBRARY_PATH side effects.
75%
#1896 elf: do not strip rpaths that contain $ORIGIN snapcraft merged Merged PR #1896 preserved ELF rpaths containing $ORIGIN during stripping; commit c543156ff implemented the fix.
71%