Skip to content

Conversation

@Half-Shot
Copy link
Member

@Half-Shot Half-Shot commented Sep 4, 2025

Bash is great. So great in fact, that if your glob expression doesn't match any files then the loop will run once with your glob expression as the only item.

This causes Element Web to fail to run when the /modules directory is present, as it thinks it has found a module under *. This sets nullglob which works as you'd expect by skipping the for loop if a glob expression doesn't match.

Checklist

@Half-Shot Half-Shot requested a review from a team as a code owner September 4, 2025 14:32
@Half-Shot Half-Shot changed the title Ensure Element Web starts if it is mounted with an empty /modules directory. Ensure container starts if it is mounted with an empty /modules directory. Sep 4, 2025
@Half-Shot
Copy link
Member Author

(Bleh, this is sh not bash so using an if statement)

Comment on lines 18 to 20
if [ -d "/modules" ]; then
cd /modules

for MODULE in *
do
# If the module has a package.json, use its main field as the entrypoint
ENTRYPOINT="index.js"
if [ -f "/modules/$MODULE/package.json" ]; then
ENTRYPOINT=$(jq -r '.main' "/modules/$MODULE/package.json")
fi

entrypoint_log "Loading module $MODULE with entrypoint $ENTRYPOINT"

# Append the module to the config
jq ".modules += [\"/modules/$MODULE/$ENTRYPOINT\"]" /tmp/element-web-config/config.json | sponge /tmp/element-web-config/config.json
done
# ...and the module directory has modules in it
if [ "$( ls -A '/modules' )" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not combine these =(?

@Half-Shot Half-Shot enabled auto-merge September 4, 2025 15:40
@Half-Shot Half-Shot added this pull request to the merge queue Sep 4, 2025
Merged via the queue into develop with commit 1c30bec Sep 4, 2025
35 checks passed
@Half-Shot Half-Shot deleted the hs/set-nullglob branch September 4, 2025 16:28
@Half-Shot Half-Shot added the backport staging Label to automatically backport PR to staging branch label Sep 5, 2025
RiotRobot pushed a commit that referenced this pull request Sep 5, 2025
…tory. (#30699)

* Set nullglob

* Replace with a if statement (because we're using sh)

* combine if

(cherry picked from commit 1c30bec)
github-merge-queue bot pushed a commit that referenced this pull request Sep 5, 2025
…tory. (#30699) (#30705)

* Set nullglob

* Replace with a if statement (because we're using sh)

* combine if

(cherry picked from commit 1c30bec)

Co-authored-by: Will Hunt <will@half-shot.uk>
Half-Shot added a commit that referenced this pull request Sep 9, 2025
…tory. (#30699) (#30705)

* Set nullglob

* Replace with a if statement (because we're using sh)

* combine if

(cherry picked from commit 1c30bec)

Co-authored-by: Will Hunt <will@half-shot.uk>
Dileep9999 pushed a commit to hemanth-nag/element-web that referenced this pull request Oct 8, 2025
…tory. (element-hq#30699)

* Set nullglob

* Replace with a if statement (because we're using sh)

* combine if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport staging Label to automatically backport PR to staging branch T-Defect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants