Closed me-nkr closed 3 years ago
did you already try another mongodb version than the default (4.0.14) like 4.2 or 4.4
btw, did you already try the beta version?
aside from that i now saw that you try to use it on arm64, then you should really try the beta version, it added support for ubuntu arm64, or you need to manually define what archive name to use
did you already try another mongodb version than the default (4.0.14) like 4.2 or 4.4
no
btw, did you already try the beta version?
no
and can you tell me how ?
i updated your comment to better reflect what something means, please change it if not right
to use the 7 beta you have to npm i -s mongodb-memory-server@beta
(replace npm with your package manager, replace -s
with whatever dependency section you prefer and replace mongodb-memory-server
with whatever package you are using from this repo)
here you can find the migration guide, note that the documentation is written only for 7.x
to change the version read here (also the top of the page)
I uninstalled what I had and installed mongodb-memory-server@beta
, I am running arm64 btw
still gets this error ; MongoMS:MongoInstance Mongo[42737]: stderrHandler: ""/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory
try to install apt install libssl-dev
or try apt install libssl1.1
on ubuntu
try to install
apt install libssl-dev
or tryapt install libssl1.1
on ubuntu
both are already installed
then it seems like an newer mongodb version is required, maybe try MONGOMS_VERSION=4.2.14
or MONGOMS_VERSION=4.4.5
oh, now that i look i also found that there is again an newer 4.0 version, so maybe MONGOMS_VERSION=4.0.25
will work
I don't think 4.2.14
and 4.4.5
is available for arm64
and 4.0.25
gives the same error
did you also already try putting an v
in-front of the versions? (mongodb's file naming is rather inconsistent in this regard)
actually, nevermind, i just checked, look into #482 for more
for now, try to overwrite the arch MONGOMS_ARCH=aarch64
(but i dont know if it will even work, probably not)
edit: or you can fully overwrite the archive name with (MONGOMS_ARCHIVE_NAME=
](https://nodkz.github.io/mongodb-memory-server/docs/api/config-options#archive_name) (find an appropriate file here)
This is in my package.json
"config": {
"mongodbMemoryServer": {
"arch": "arm64",
"archive_name" : "http://downloads.mongodb.org/linux/mongodb-linux-aarch64-ubuntu2004-latest.tgzhttp://downloads.mongodb.org/linux/mongodb-linux-aarch64-ubuntu2004-v4.4-latest.tgz",
"debug": "1"
}
}
I'm not sure, but I have a feeling that this has something to do with libcrypto
's version.
for what you did, you need to use MONGOMS_DOWNLOAD_URL
, the archive name is just the mongodb-linux-aarch64-ubuntu2004-latest.tgz
part
PS: it seems like you have double-pasted the url in the config PPS: here is how you convert the config options for package.json
I'm not sure, but I have a feeling that this has something to do with libcrypto's version.
yes it does, but currently this package does only support generating arm64
urls, not aarch64
, which mongodb seems to use now for higher versions
for #482 to be easier to understand and replicate (if needed), could you provide the following:
v14.17.0
?Ubuntu 20.04.2 aarch64
?console.log(process.arch)
? (just run it in the node repl)aarch64-ubuntu2004-latest
work for you?aarch64
should now be correctly downloaded, fix is in 7.0.0-beta.44
if you want to try it (if you had an binary before, you need to remove it, and also the config options to overwrite the archive)
- is the nodejs version used still
v14.17.0
?
yes
- is the distro still
Ubuntu 20.04.2 aarch64
?
yes
- what is your hardware? (like an raspberry pi?)
Raspberry Pi 4B
- what is the output of
console.log(process.arch)
? (just run it in the node repl)
arm64
- and did the archive
aarch64-ubuntu2004-latest
work for you?
no
and this is in my package.json now
"config": {
"mongodbMemoryServer": {
"arch": "arm64",
"archiveName" : "linux/mongodb-linux-aarch64-ubuntu2004-latest.tgz",
"debug": "1"
}
}
aarch64
should now be correctly downloaded, fix is in7.0.0-beta.44
if you want to try it (if you had an binary before, you need to remove it, and also the config options to overwrite the archive)
sorry but can you guide me through ? I'm kinda confused
and this is in my package.json now
the correct archive name would be mongodb-linux-aarch64-ubuntu2004-latest.tgz
sorry but can you guide me through ? I'm kinda confused
confused on what exactly? there is an migration guide if you still only used 6.x
PS: if you are going to try the beta.44 version, then you would need to also remove the config options arch
and archiveName
confused on what exactly?
how to use the beta version
how to use the beta version
do you mean on how to install it, or how to use is in the code?
how to use the beta version
do you mean on how to install it, or how to use is in the code?
install, sorry for not being specific
there are 2 methods:
7.0.0-beta.44
and run the install command (should be easier)npm i mongodb-memory-server@7.0.0-beta.44
(replace with the package used and the package manager that is used)if you want more examples, you could look at this documentation
"config": {
"mongodbMemoryServer": {
"debug": "1"
}
}
this is now in my package.json
I ran npm i mongodb-memory-server@7.0.0-beta.44
still gets the libcrypto error;
MongoMS:MongoInstance Mongo[33475]: stderrHandler: ""/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory
here is the full log:
MongoMS:MongoMemoryServer create: Called .create() method +0ms
MongoMS:MongoMemoryServer start: Called .start() method +8ms
MongoMS:MongoMemoryServer _startUpInstance: Called MongoMemoryServer._startUpInstance() method +3ms
MongoMS:MongoMemoryServer getStartOptions +1ms
MongoMS:MongoMemoryServer _startUpInstance: Creating new MongoDB instance with options: {"instance":{"port":33475,"dbName":"f7e3c463-9aff-40c5-be8d-545817ef1539","ip":"127.0.0.1","storageEngine":"ephemeralForTest","dbPath":"/tmp/mongo-mem--7835-RsXQ62ZHRfSZ","tmpDir":{"name":"/tmp/mongo-mem--7835-RsXQ62ZHRfSZ"}}} +31ms
MongoMS:MongoInstance create: Called .create() method +0ms
MongoMS:MongoInstance Mongo[33475]: start +2ms
MongoMS:MongoBinary getPath +0ms
MongoMS:utils tryReleaseFile: "/etc/upstream-release/lsb-release" does not exist +0ms
MongoMS:getos getLinuxInformation: Using etcOsRelease +0ms
MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +0ms
MongoMS:DryMongoBinary generateDownloadPath: Paths: {
legacyHomeCache: '',
modulesCache: '/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20',
relative: '/home/ubuntu/Projects/Web/CowinTracker/server/mongodb-binaries/mongod-arm64-ubuntu-4.0.20',
resolveConfig: ''
} +7ms
MongoMS:DryMongoBinary generateDownloadPath: Found binary in modulesCache: "/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20" +15ms
MongoMS:MongoBinary getPath: MongoBinary options: {
"version": "4.0.20",
"downloadDir": "/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server",
"os": {
"os": "linux",
"dist": "ubuntu",
"codename": "focal",
"release": "20.04",
"id_like": "debian"
},
"arch": "arm64",
"systemBinary": "",
"platform": "linux",
"checkMD5": false
} +46ms
MongoMS:DryMongoBinary locateBinary: Trying to locate Binary for version "4.0.20" +3ms
MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +3ms
MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty +3ms
MongoMS:DryMongoBinary generateDownloadPath: Paths: {
legacyHomeCache: '',
modulesCache: '/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20',
relative: '/home/ubuntu/Projects/Web/CowinTracker/server/mongodb-binaries/mongod-arm64-ubuntu-4.0.20',
resolveConfig: '/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20'
} +0ms
MongoMS:DryMongoBinary generateDownloadPath: Found binary in resolveConfig (DOWNLOAD_DIR): "/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20" +3ms
MongoMS:DryMongoBinary locateBinary: running generateDownloadPath +0ms
MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +1ms
MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty +3ms
MongoMS:DryMongoBinary generateDownloadPath: Paths: {
legacyHomeCache: '',
modulesCache: '/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20',
relative: '/home/ubuntu/Projects/Web/CowinTracker/server/mongodb-binaries/mongod-arm64-ubuntu-4.0.20',
resolveConfig: '/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20'
} +1ms
MongoMS:DryMongoBinary generateDownloadPath: Found binary in resolveConfig (DOWNLOAD_DIR): "/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20" +3ms
MongoMS:DryMongoBinary locateBinary: found binary at "/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20" +1ms
MongoMS:MongoBinary getPath: Mongod binary path: "/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20" +20ms
MongoMS:MongoInstance Mongo[33475]: start: Starting Processes +71ms
MongoMS:MongoInstance Mongo[33475]: _launchMongod: Launching Mongod Process +1ms
MongoMS:MongoInstance Mongo[33475]: prepareCommandArgs +2ms
MongoMS:MongoInstance Mongo[33475]: prepareCommandArgs: final arugment array:["--port","33475","--dbpath","/tmp/mongo-mem--7835-RsXQ62ZHRfSZ","--storageEngine","ephemeralForTest","--bind_ip","127.0.0.1","--noauth"] +0ms
MongoMS:MongoInstance Mongo[33475]: _launchKiller: Launching Killer Process (parent: 7835, child: 7846) +47ms
MongoMS:MongoInstance Mongo[33475]: stderrHandler: ""/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory
MongoMS:MongoInstance "" +25ms
MongoMS:MongoInstance Mongo[33475]: closeHandler: Mongod instance closed with an non-0 (or non 12 on windows) code! +6ms
MongoMS:MongoInstance Mongo[33475]: closeHandler: 127 +1ms
sorry forgot to mention, you will still need to overwrite the version with MONGOMS_VERSION
, the default for 6.x is 4.0.14
and for 7.x (currently) is 4.0.20
to which version ?
to an higher version than default, we had it earlier in the issue: https://github.com/nodkz/mongodb-memory-server/issues/480#issuecomment-858963570
so I tried the following in package.json
"version": "v4.0.25"
> got 403 (Mongodb's 404)
"version": "4.0.25"
> got libcrypto
error
"version": "v4.0-latest"
> got 403, but also noticed Used Url: "https://fastdl.mongodb.org/linux/mongodb-linux-arm64-ubuntu2004-v4.0-latest.tgz"
you will need to try an higher version than 4.0 / 4.1, so try (like said earlier in the issue) 4.2.14
or 4.4.5
version 4.2.14
works fine, in the sense a instance starts and I can getUri and instanceInfo, so thanks for the support. I hope pointing this issue helped. Looking forward to contributing more
I'm using Ubuntu 22.10 and I'm facing this same issue with mongodb-memory-server when running jest tests.
In order to work around this I needed to install libcrypto.so.1.0.0
from Ubuntu archive since the libcrypto package is not installed by default in Ubuntu 22.04 >=.
You can find how to install it manually from Ubuntu archive repo here: https://stackoverflow.com/a/73251469/9936281
@andrempeixoto you could also manually set the version to 6.0.4
(or higher), because that is the version mongodb ships with builds for ubuntu 2204
I actually already had "mongodb-memory-server": "6.9.6"
, so should it have worked from the start?
@andrempeixoto that is the package version, i was meaning the binary version via the config option
I did not install the libcrypto library but just set the config option as follows in my package.json file but the error remains.
"config": {
"mongodbMemoryServer": {
"MONGOMS_VERSION": "6.0.4"
}
}
@simplexityware
MONGOMS_VERSION
that is the environment variable name, see this page what name to use where (in the case of VERSION
it would be version
)
Thank you! Now my tests keep downloading the mongo-memory-server for each test resulting in the following timeout error...
FAIL src/mongo.test.ts > Mongo Memory Server Test > Test MongoDB
Error: Test timed out in 5000ms.
If this is a long-running test, pass a timeout value as the last argument or configure it globally with "testTimeout".
My simple test is as follows ..
const runTest = async () => {
const mongod = await MongoMemoryServer.create();
await mongod.start();
const uri = await mongod.getUri()
// Do your tests here
console.log('MongoDB URI:', uri)
await mongod.stop()
}
describe('Mongo Memory Server Test', () => {
it('Test MongoDB', async () => {
await runTest()
})
})
What am I missing?
const mongod = await MongoMemoryServer.create(); await mongod.start();
no need for a extra .start
, .create
is literally a new Class
chained with .start`
https://github.com/nodkz/mongodb-memory-server/blob/ebee09413ba669307403066cad4df0c9376fdc76/packages/mongodb-memory-server-core/src/MongoMemoryServer.ts#L250-L251
const uri = await mongod.getUri()
.getUri
is sync since 7.0.0 (not returning a promise)
await runTest()
the way you have it defined is considered bad practice; only one instance should only be created for the current test suite, not for each test. and even better is if you can create just one instance for all tests, see Integration with Test Runners
Now my tests keep downloading the mongo-memory-server for each test resulting in the following timeout error...
if you dont have the binary already downloaded, then MMS will by default download it when the instance is started - which can take some time. it is recommended to have it auto-download at package install time (using any package other than -core
will automatically download a version) or otherwise use a global hook (like jest's globalSetup
) to call await MongoBinary.getPath()
(or with parameter { version: 'x.x.x' }
when wanting some specific version other than defined via environment variable or package json)
Thank you! Sorry I am new to Typescript as well as Mongo. Please tell me exactly what I need to do including the version in "config" as well as any "npm install mongoldb-memory-server" additional parameters to pass my test to get me started using MMS.
to get me started using MMS.
basically follow the quick-start-guide and Integration with test runners (use the section for your test runner like jest or mocha)
you can also look at examples like MMS's own testing or how typegoose uses it or how mongoose uses it (look at the respective package.jsons and test runner configs manually)
if you want more setup help, consider asking on our discord or opening up a new discussion
Using the integration with test runners link, without any need to change package.json file, I get the same error as the original author of this thread...
FAIL src/mongo.test.ts > Mongo Memory Server Test > Test MongoDB
Error: Instance failed to start because a library is missing or cannot be opened: "libcrypto.so.1.1"
❯ MongoInstance.checkErrorInLine node_modules/mongodb-memory-server-core/src/util/MongoInstance.ts:678:11
❯ MongoInstance.stderrHandler node_modules/mongodb-memory-server-core/src/util/MongoInstance.ts:563:10
❯ Socket.emit node:events:512:28
❯ Socket.emit node:domain:489:12
What should I do next?
Error: Instance failed to start because a library is missing or cannot be opened: "libcrypto.so.1.1"
https://github.com/nodkz/mongodb-memory-server/issues/732
please search existing issues for those errors first
this fixed it for me:
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
this fixed it for me:
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
Thanks! This solution worked for me!
I had a similar issue with it working fine on my Mac (no mongo install) but failing on a CircleCI build using their own image cimg/node
but it worked fine when I switched to node: bullseye
which is a Debian 11 release. So, it's definitely a host OS config or compatibility issue.
I had a similar issue with it working fine on my Mac (no mongo install) but failing on a CircleCI build using their own image
cimg/node
but it worked fine when I switched tonode: bullseye
which is a Debian 11 release. So, it's definitely a host OS config or compatibility issue.
Specifically, what did you do? I think I have the same issue.
In config.yml
for CircleCI, I changed the docker image to node: bullseye
. Here's the file within the context of my project https://github.com/duluca/document-ts/blob/main/.circleci/config.yml
this fixed it for me:
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
Worked for me. Thanks a lot
Thanks a lot. This worked for me.
I am able to install and run MongoDB from official repos on Ubuntu 22.04 without any problem, but mongodb-memory-server still fails complaining about libssl1.1, even if I set the binary version to 6.0.4 or even 6.3.0, it still fails. Why is there inconsistent behaviour between the actual mongo libraries and the libraries used by MMS?
Why is there inconsistent behaviour between the actual mongo libraries and the libraries used by MMS?
there is none, please provide the binary name you have tested with (just note that the APT repository is not a source for MMS)
if this error still continues with 6.0.4 binaries, please open a new issue providing the debug log
this fixed it for me:
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
Thanks man, you just saved me!
Versions
package: mongo-memory-server
What is your question?
when I write this following code
I get the following error
then I made symlinks for
libssl1.1
aslibssl.so.1.0.0
andlibcrypto.so.1.1
aslibcrypto.so.1.0.0
, and I gothow can I overcome these errors ?