upgrade fails due invalid mongo version parsing
Steps to Reproduce
- run
./bin/upgrade - modify
/config/overleaf.rcto new split mongo
MONGO_ENABLED=true
MONGO_DATA_PATH=data/mongo
MONGO_IMAGE=mongo
MONGO_VERSION=5.0
- run
./bin/upgrade
Expected Behaviour
- should upgrade
Observed Behaviour
error message
--------------------- ERROR -----------------------
Invalid MONGO_VERSION: MONGO_VERSION=5.0
MONGO_VERSION must start with the actual major version of mongo, followed by a dot.
Example: MONGO_IMAGE=my.dockerhub.com/custom-mongo
MONGO_VERSION=6.0-custom
--------------------- ERROR -----------------------
Analysis
a set -x in lib/shared-functions.sh looks (for me) that some variable name/value splitting is not done correctly
overleaf:~/overleaf-toolkit# ./bin/upgrade
Checking for code update...
No code update available for download
New docker image version available (5.1.1)
Current image version is '5.0.6' (from config/version)
Upgrade image? [y/n] y
Upgrading config/version from 5.0.6 to 5.1.1
++ read_configuration MONGO_IMAGE
++ local name=MONGO_IMAGE
++ grep -E '^MONGO_IMAGE=' /root/overleaf-toolkit/config/overleaf.rc
++ sed -r 's/^MONGO_IMAGE=(["'\'']?)(.+)\1$/\2/'
+ local mongo_image=MONGO_IMAGE=mongo
++ read_configuration MONGO_VERSION
++ local name=MONGO_VERSION
++ grep -E '^MONGO_VERSION=' /root/overleaf-toolkit/config/overleaf.rc
++ sed -r 's/^MONGO_VERSION=(["'\'']?)(.+)\1$/\2/'
+ local mongo_version=MONGO_VERSION=5.0
+ '[' -z MONGO_VERSION=5.0 ']'
+ [[ ! MONGO_VERSION=5.0 =~ ^([0-9]+)\.(.+)$ ]]
+ echo '--------------------- ERROR -----------------------'
+ echo ' Invalid MONGO_VERSION: MONGO_VERSION=5.0'
+ echo ''
+ echo ' MONGO_VERSION must start with the actual major version of mongo, followed by a dot.'
+ echo ' Example: MONGO_IMAGE=my.dockerhub.com/custom-mongo'
+ echo ' MONGO_VERSION=6.0-custom'
+ echo '--------------------- ERROR -----------------------'
+ exit 1
I think mongo_version should be 5.0 and not MONGO_VERSION=5.0
This is indeed a bug that I can confirm.
Changing the lib/shared-functions.sh sed regex syntax in the read_variable() and read_configuration() from
"s/^$name=([\"']?)(.+)\1\$/\2/"
to
"s/^$name=['\"]?(.*)['\"]?$/\1/"
resolves this issue.
This is indeed a bug that I can confirm. Changing the lib/shared-functions.sh sed regex syntax in the read_variable() and read_configuration() from
"s/^$name=([\"']?)(.+)\1\$/\2/"to"s/^$name=['\"]?(.*)['\"]?$/\1/"resolves this issue.
It's like a typo bug in this file, but this helped me! Thank you bro.