RocketChat / RocketChat/Rocket.Chat

Pre-refresh hook fails: SNAP_ARCH not set → broken LD_LIBRARY_PATH → mongod cannot find libcrypto.so.1.1

Open
#41,001 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
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_monngodstop_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

  1. Install rocketchat-server snap (tested on revision 1785)
  2. Run sudo snap refresh rocketchat-server on Ubuntu 24.04 / snapd 2.75.2
  3. Pre-refresh hook fails with:
[ERROR] pre refresh migration script /snap/rocketchat-server/1785/migrations/pre_refresh/feature_compatibility/00-adopt_version.sh
  1. 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_monngodstop_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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.