I recently ran into an issue of MongoDB shell commands not working. The error message was:
Invariant failure !driverName.empty() && !driverVersion.empty() && !osType.empty() && !osName.empty() && !osArchitecture.empty() && !osVersion.empty() src/mongo/rpc/metadata/client_metadata.cpp
I ran an strace
on the mongo
command and saw it was trying (and failing) to open the following files:
stat("/etc/lsb-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/system-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/redhat-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/gentoo-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/novell-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/gentoo-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/SuSE-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/SUSE-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/sles-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/debian_release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/slackware-version", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/centos-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/os-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
I solved this by simply creating a string in the /etc/system-release
file:
echo "My OS version 1.2.3" > /etc/system-release
Hopefully this helps someone else having the same issue.
strace is your friend.
Great! Thanks! Helped me out!