How to Install a Legacy MongoDB Version Without SSL Support Using m
Use the --legacy flag with the m command to force download of the generic Linux tarball that excludes SSL libraries, bypassing distribution-specific packages.
The m MongoDB Version Manager simplifies switching between MongoDB releases, but modern builds often bundle SSL libraries that may be incompatible with older systems. When you need to install a legacy MongoDB version without SSL support using m, the tool provides a specific flag to retrieve generic Linux binaries that omit SSL entirely.
Understanding the --legacy Flag
The --legacy flag signals m to download the generic Linux build of MongoDB rather than distribution-specific packages. These generic tarballs are compiled without SSL support, making them ideal for environments where OpenSSL versions conflict or where encryption is handled externally.
When you append --legacy to your install command, m sets an internal variable _legacy_only=y that propagates through the download logic to suppress distro-specific selection.
How the Installation Flow Works
Flag Parsing in install_mongo
The entry point for this feature is in bin/m within the install_mongo function. When the script parses arguments, it detects the --legacy flag and configures the environment for a non-SSL build:
# bin/m: line 922-924
legacy|--legacy)
debug "Using generic Linux legacy config (does not include SSL)"
_legacy_only=y
config=""
;;
Setting _legacy_only=y is the critical switch that tells downstream functions to ignore distribution-specific packages that typically include SSL libraries.
Distribution Selection Logic
The get_distro_and_arch function normally builds a list of candidate distribution identifiers to find the most specific MongoDB package. However, when _legacy_only is enabled, this list is explicitly cleared:
# bin/m: line 1338-1340
if [ "$_legacy_only" = y ]; then
distros=""
fi
With an empty distros array, the script cannot match distribution-specific tarballs and must fall back to the generic format mongodb-<sslbuild>-<arch>-<version>.tgz.
URL Construction for Generic Tarballs
The URL assembly logic in bin/m (lines 886-896) constructs the download path. Because distros is empty when --legacy is used, the loop that checks for distro-specific packages never executes, leaving the generic tarball name intact:
# bin/m: line 886-896
local tarball="mongodb-$sslbuild-$arch-$version.tgz"
for distro in $distros; do
if good "http://fastdl.mongodb.org/$os/mongodb-$sslbuild-$arch-$distro-$version.tgz"; then
tarball="mongodb-$sslbuild-$arch-$distro-$version.tgz"
break
fi
done
local url="http://fastdl.mongodb.org/$os/$tarball"
The resulting URL points to the generic Linux build without SSL support.
Binary Installation
Finally, the install_bin function uses the computed URL to download the archive, extract it to $M_PREFIX/versions/<version>/, and symlink the binaries (mongod, mongo, etc.) into $M_BIN_DIR. The installation pipeline remains identical to standard installs, but the source binaries lack SSL dependencies.
Practical Examples
Install a specific legacy version without SSL:
# Install MongoDB 4.0.3 without SSL (legacy build)
m 4.0.3 --legacy
Install the latest patch release from a major version line:
# Install the latest 3.6 release without SSL
m 3.6 --legacy
Alternative syntax using the install subcommand:
# Explicitly use the legacy sub-command (same effect)
m install 5.0.12 legacy
Verify which binary was installed:
# Show the path of the active mongod binary
which mongod
# Expected output: $HOME/.local/bin/mongod -> $HOME/.local/m/versions/4.0.3/bin/mongod
List available versions to find legacy-compatible releases:
# List all 4.0.x releases (including legacy binaries)
m ls 4.0
Summary
- The
--legacyflag inmforces download of generic Linux tarballs that exclude SSL libraries. - When activated, the script sets
_legacy_only=yinbin/mand clears the distribution list to prevent selection of distro-specific packages. - The generic URL format
mongodb-<sslbuild>-<arch>-<version>.tgzis used instead of distribution-specific variants. - This approach is essential for running old MongoDB releases on systems with incompatible OpenSSL versions or where external encryption is preferred.
Frequently Asked Questions
What is the difference between legacy and regular MongoDB builds?
Legacy builds are generic Linux binaries compiled without SSL support, distributed as mongodb-<sslbuild>-<arch>-<version>.tgz. Regular builds are distribution-specific packages (e.g., for Ubuntu 20.04 or RHEL 8) that bundle SSL libraries. According to the m source code in bin/m, the --legacy flag forces selection of the generic tarball by clearing the distro selection list.
When should I use the --legacy flag?
Use --legacy when you need to install a legacy MongoDB version without SSL support using m, particularly on older systems where modern OpenSSL versions conflict with the MongoDB binary, or in containerized environments where you handle TLS termination externally. The flag ensures you receive the generic Linux build that lacks SSL dependencies entirely.
How do I verify that my MongoDB installation does not include SSL?
After installation, check the binary capabilities by running mongod --version and looking for SSL/OpenSSL version information in the output. If the --legacy flag was used during installation with m, the binary will not report SSL support. You can also verify the installation path using which mongod to confirm it points to the version installed via m in your $M_PREFIX/versions/ directory.
Can I use --legacy on macOS or Windows?
No. The --legacy flag is specifically designed for Linux systems. According to the m source code in bin/m, the legacy logic clears distribution identifiers and relies on the generic Linux tarball format mongodb-<sslbuild>-<arch>-<version>.tgz. macOS and Windows use different archive formats and naming conventions, so the flag has no effect on those platforms.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →