RocketChat / RocketChat/Rocket.Chat
Pre-refresh hook fails: SNAP_ARCH not set → broken LD_LIBRARY_PATH → mongod cannot find libcrypto.so.1.1
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Hey there,
so, the following bug report is done by AI, I am not sure, if this is completely correct or not, nor do i have the expertise to judge this. If you deem this wrong, please just delete it and accept my apologies.
I've encountered this error, when I tried to so snap refresh on revision 1785.
[ERROR] pre refresh migration script /snap/rocketchat-server/1785/migrations/pre_refresh/feature_compatibility/00-adopt_version.sh
My workaround was to ignore-errors
snap set rocketchat-server ignore-errors=true
snap refresh rocketchat-server
snap set rocketchat-server ignore-errors=false
Also, there is a typo in 00-adopt_version.sh: stop_monngod → stop_mongod.
Best
inDane
AI output begins here:
Bug Description
The pre-refresh hook fails during snap refresh because SNAP_ARCH is not set in the hook environment, causing environment.sh to build a broken LD_LIBRARY_PATH with empty architecture segments (e.g. /lib/-linux-gnu instead of /lib/x86_64-linux-gnu). This prevents mongod from finding bundled shared libraries like libcrypto.so.1.1.
Steps to Reproduce
- Install rocketchat-server snap (tested on revision 1785)
- Run
sudo snap refresh rocketchat-serveron Ubuntu 24.04 / snapd 2.75.2 - Pre-refresh hook fails with:
[ERROR] pre refresh migration script /snap/rocketchat-server/1785/migrations/pre_refresh/feature_compatibility/00-adopt_version.sh
- Running the migration script manually with proper env vars shows the real error:
mongod: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory
Root Cause
helpers/environment.sh line 6:
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/${ARCH[$SNAP_ARCH]}-linux-gnu:$SNAP/usr/lib/${ARCH[$SNAP_ARCH]}-linux-gnu"
When SNAP_ARCH is empty (not set by snapd in the hook context), ${ARCH[$SNAP_ARCH]} returns empty, producing paths like:
/snap/rocketchat-server/1785/lib/-linux-gnu
/snap/rocketchat-server/1785/usr/lib/-linux-gnu
Instead of the correct:
/snap/rocketchat-server/1785/lib/x86_64-linux-gnu
/snap/rocketchat-server/1785/usr/lib/x86_64-linux-gnu
The library libcrypto.so.1.1 exists at the correct path (/snap/rocketchat-server/1785/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1) but is never found because LD_LIBRARY_PATH points to non-existent directories.
Additional Issue: Typo in migration script
snap/rocketchat-server/1785/migrations/pre_refresh/feature_compatibility/00-adopt_version.sh line 8 contains:
is_mongod_running && stop_monngod
Three n characters (stop_monngod instead of stop_mongod). This causes a "command not found" error and a non-zero exit code.
Workaround
sudo snap set rocketchat-server ignore-errors=true
sudo snap refresh rocketchat-server
sudo snap set rocketchat-server ignore-errors=false
Or stop services before refreshing:
sudo systemctl stop snap.rocketchat-server.rocketchat-server
sudo systemctl stop snap.rocketchat-server.rocketchat-mongo
sudo snap refresh rocketchat-server
Suggested Fix
In helpers/environment.sh, add a fallback for SNAP_ARCH:
if [[ -z "${SNAP_ARCH:-}" ]]; then
SNAP_ARCH=$(dpkg --print-architecture 2>/dev/null || echo "amd64")
fi
And fix the typo in 00-adopt_version.sh: stop_monngod → stop_mongod.
Environment
- OS: Ubuntu 24.04 LTS
- Kernel: 6.8.0-124-generic
- snapd: 2.75.2+ubuntu24.04
- Architecture: amd64
- Rocket.Chat snap: revision 1785 → 1788
- MongoDB: 7.0 (bundled)
- OpenSSL: 3.0.13 (system), 1.1 (bundled in snap)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with helpers/environment.sh and migrations/pre_refresh/feature_compatibility/00-adopt_version.sh. Reproduce the pre-refresh failure using the stated snap revision and environment, then inspect how SNAP_ARCH builds LD_LIBRARY_PATH and verify the migration script typo. Done means snap refresh no longer fails because the bundled libcrypto cannot be found, and the migration command uses the intended function name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, mongodb, shell
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100