Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postinstall does not resolve a relative "DOWNLOAD_DIR" correctly #548

Closed
porwin88 opened this issue Sep 30, 2021 · 23 comments
Closed

Postinstall does not resolve a relative "DOWNLOAD_DIR" correctly #548

porwin88 opened this issue Sep 30, 2021 · 23 comments
Labels
bug released on @beta released Pull Request released | Issue is fixed
Milestone

Comments

@porwin88
Copy link

Versions

  • NodeJS: docker container image node:14.17.5
  • mongo-memory-server-*: 7.4.1
  • mongodb(the binary version): 4.4.6
  • mongoose: 6.0.7
  • system: Linux version 5.10.47-linuxkit

package: mongo-memory-server

What is the Problem?

The db is not downloading and caching on install, but rather downloads the first time it is required in a test file.
Tried 8.0.0-beta.1 and beta.2, but the same issue.

With 7.0.0-beta.43 it works as expected.

Do you know why it happens?

no

@porwin88 porwin88 added the bug label Sep 30, 2021
@hasezoey
Copy link
Member

hasezoey commented Sep 30, 2021

Extra Information:
Docker Image node:14.17.5 is based on Debian 9 (stretch)


could you provide debug output? (while using the latest version, which currently is 8.0.0-beta.2 when possible)


edit: also, does 7.0.0 work, or is 7.0.0-beta.43 the last working version?
another edit: what host system do you use? (linux distro, not kernel)

@porwin88
Copy link
Author

Thanks for the quick response!

7.0.0 works.
Host: macOS BigSur 11.6

There is no debug output as such, because the tests are running. The issue is that the download is not taking place on npm i. It is taking place when the first test file requiring mongo-memory-server is run.

If I use the later versions (including e.g. 7.4.1 or 8.0.0-beta.2) the npm i hangs for a long time at the step
"reify:mongodb: timing reifyNode:node_modules/mongodb-memory-server-core/node_modules/bson", or
"reify:mongodb-memory-server-core: http fetch GET 200 https://registry.npmjs.org/mongodb-memory-server-core/-/mongodb-memory-server-c"

before completing the install.

@hasezoey
Copy link
Member

If I use the later versions (including e.g. 7.4.1 or 8.0.0-beta.2) the npm i hangs for a long time at the step
"reify:mongodb: timing reifyNode:node_modules/mongodb-memory-server-core/node_modules/bson", or
"reify:mongodb-memory-server-core: http fetch GET 200 https://registry.npmjs.org/mongodb-memory-server-core/-/mongodb-memory-server-c"

i dont quite know but i think this step is actually downloading the package itself, not executing the postinstall

also, if you want to prevent runtime download, you can use option RUNTIME_DOWNLOAD set to false either in the package.json or environment

There is no debug output as such, because the tests are running

that should not really matter, just setting the environment variable should do it (if the testing engine passes through the variables, from what i know jest & mocha pass them through)

7.0.0 works.

then theoretically 7.3.6 should also work, because it does not modify anything related to downloads - only fixes stuff

@porwin88
Copy link
Author

porwin88 commented Sep 30, 2021

7.3.6 doesn't work.

If I set {runtimeDownload: false}, there is no download but also the test does not run at all, it just hangs there.

These are the further config settings:

 "mongodbMemoryServer": {
            "debug": "0",
            "version": "4.4.6",
            "disablePostinstall": "0",
            "downloadDir": "./node_modules/.cache"
        }
Debug output with 8.0.0-beta.2
MongoMS:ResolveConfig Debug Mode Enabled, through package.json +0ms
  MongoMS:MongoMemoryServer create: Called .create() method +0ms
  MongoMS:MongoMemoryServer Mongo[unknown]: start: Called .start() method +1ms
  MongoMS:MongoMemoryServer Mongo[unknown]: _startUpInstance: Called MongoMemoryServer._startUpInstance() method +1ms
  MongoMS:MongoMemoryServer Mongo[unknown]: getStartOptions +0ms
  MongoMS:MongoMemoryServer Mongo[unknown]: _startUpInstance: Creating new MongoDB instance with options: {
  instance: {
    port: 57019,
    dbName: 'nextOR_test',
    ip: '127.0.0.1',
    storageEngine: 'ephemeralForTest',
    replSet: undefined,
    dbPath: '/tmp/mongo-mem--64-bGkWefuWgbw7',
    tmpDir: {
      name: '/tmp/mongo-mem--64-bGkWefuWgbw7',
      removeCallback: [Function: _cleanupCallback]
    },
    args: undefined,
    auth: undefined
  },
  binary: undefined,
  spawn: undefined
} +9ms
  MongoMS:MongoInstance create: Called .create() method +0ms
  MongoMS:MongoInstance Mongo[57019]: start +1ms
  MongoMS:MongoBinary getPath +0ms
  MongoMS:DryMongoBinary generateOptions +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" +11ms
  MongoMS:DryMongoBinary generatePaths +0ms
  MongoMS:DryMongoBinary getBinaryName +1ms
  MongoMS:DryMongoBinary combineBinaryName +2ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary generateDownloadPath: Paths: {
  legacyHomeCache: '/home/node/.cache/mongodb-binaries/mongod-x64-debian-4.4.6',
  modulesCache: '/home/node/node_modules/.cache/mongodb-memory-server/mongod-x64-debian-4.4.6',
  relative: '/home/node/mongodb-binaries/mongod-x64-debian-4.4.6',
  resolveConfig: '/home/node/node_modules/.cache/mongod-x64-debian-4.4.6'
}  +1ms
  MongoMS:DryMongoBinary generateDownloadPath: no existing binary for version "4.4.6" was found +3ms
  MongoMS:DryMongoBinary generateDownloadPath: using resolveConfig (DOWNLOAD_DIR) "/home/node/node_modules/.cache/mongod-x64-debian-4.4.6" +0ms
  MongoMS:MongoBinary getPath: MongoBinary options: {
  "version": "4.4.6",
  "downloadDir": "/home/node/node_modules/.cache",
  "os": {
    "os": "linux",
    "dist": "debian",
    "codename": "stretch",
    "release": "9"
  },
  "arch": "x64",
  "systemBinary": "",
  "platform": "linux",
  "checkMD5": false
} +20ms
  MongoMS:DryMongoBinary locateBinary: Trying to locate Binary for version "4.4.6" +2ms
  MongoMS:DryMongoBinary generateOptions +1ms
  MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +0ms
  MongoMS:DryMongoBinary generatePaths +1ms
  MongoMS:DryMongoBinary getBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +1ms
  MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary generateDownloadPath: Paths: {
  legacyHomeCache: '/home/node/.cache/mongodb-binaries/mongod-x64-debian-4.4.6',
  modulesCache: '/home/node/node_modules/.cache/mongodb-memory-server/mongod-x64-debian-4.4.6',
  relative: '/home/node/mongodb-binaries/mongod-x64-debian-4.4.6',
  resolveConfig: '/home/node/node_modules/.cache/mongod-x64-debian-4.4.6'
}  +0ms
  MongoMS:DryMongoBinary generateDownloadPath: no existing binary for version "4.4.6" was found +2ms
  MongoMS:DryMongoBinary generateDownloadPath: using resolveConfig (DOWNLOAD_DIR) "/home/node/node_modules/.cache/mongod-x64-debian-4.4.6" +1ms
  MongoMS:DryMongoBinary locateBinary: running generateDownloadPath +0ms
  MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +0ms
  MongoMS:DryMongoBinary generatePaths +0ms
  MongoMS:DryMongoBinary getBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +1ms
  MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary generateDownloadPath: Paths: {
  legacyHomeCache: '/home/node/.cache/mongodb-binaries/mongod-x64-debian-4.4.6',
  modulesCache: '/home/node/node_modules/.cache/mongodb-memory-server/mongod-x64-debian-4.4.6',
  relative: '/home/node/mongodb-binaries/mongod-x64-debian-4.4.6',
  resolveConfig: '/home/node/node_modules/.cache/mongod-x64-debian-4.4.6'
}  +0ms
  MongoMS:DryMongoBinary generateDownloadPath: no existing binary for version "4.4.6" was found +2ms
  MongoMS:DryMongoBinary generateDownloadPath: using resolveConfig (DOWNLOAD_DIR) "/home/node/node_modules/.cache/mongod-x64-debian-4.4.6" +0ms
  MongoMS:DryMongoBinary locateBinary: could not find a existing binary +0ms
  MongoMS:MongoBinary getPath: "RUNTIME_DOWNLOAD" is "true", trying to download +10ms
  MongoMS:MongoBinary download +1ms
  MongoMS:MongoBinary download: Waiting to acquire Download lock for file "/home/node/node_modules/.cache/4.4.6.lock" +3ms
  MongoMS:LockFile lock: Locking file "/home/node/node_modules/.cache/4.4.6.lock" +0ms
  MongoMS:LockFile checkLock: for file "/home/node/node_modules/.cache/4.4.6.lock" with uuid: "undefined" +0ms
  MongoMS:LockFile createLock: trying to create a lock file for "/home/node/node_modules/.cache/4.4.6.lock" +1ms
  MongoMS:LockFile createLock: Lock File Created for file "/home/node/node_modules/.cache/4.4.6.lock" +6ms
  MongoMS:MongoBinary download: Download lock acquired +8ms
  MongoMS:MongoBinary download: Adding version 4.4.6 to cache +0ms
  MongoMS:MongoBinaryDownload getMongodPath +0ms
  MongoMS:DryMongoBinary generateOptions +14ms
  MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +0ms
  MongoMS:DryMongoBinary generatePaths +1ms
  MongoMS:DryMongoBinary getBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty +0ms
  MongoMS:DryMongoBinary combineBinaryName +1ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary generateDownloadPath: Paths: {
  legacyHomeCache: '/home/node/.cache/mongodb-binaries/mongod-x64-debian-4.4.6',
  modulesCache: '/home/node/node_modules/.cache/mongodb-memory-server/mongod-x64-debian-4.4.6',
  relative: '/home/node/mongodb-binaries/mongod-x64-debian-4.4.6',
  resolveConfig: '/home/node/node_modules/.cache/mongod-x64-debian-4.4.6'
}  +0ms
  MongoMS:DryMongoBinary generateDownloadPath: no existing binary for version "4.4.6" was found +2ms
  MongoMS:DryMongoBinary generateDownloadPath: using resolveConfig (DOWNLOAD_DIR) "/home/node/node_modules/.cache/mongod-x64-debian-4.4.6" +0ms
  MongoMS:DryMongoBinary getBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:MongoBinaryDownload startDownload +5ms
  MongoMS:MongoBinaryDownloadUrl Using "mongodb-linux-x86_64-debian92-4.4.6.tgz" as the Archive String +0ms
  MongoMS:MongoBinaryDownloadUrl Using "https://fastdl.mongodb.org" as the mirror +1ms
  MongoMS:MongoBinaryDownload download +5ms
  MongoMS:MongoBinaryDownload download: Downloading: "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian92-4.4.6.tgz" +1ms
  MongoMS:MongoBinaryDownload httpDownload +4ms
  MongoMS:MongoBinaryDownload httpDownload: trying to download "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian92-4.4.6.tgz" +1ms
Downloading MongoDB "4.4.6": 55.3% (37.8mb / 68.3mb)

@hasezoey
Copy link
Member

hasezoey commented Sep 30, 2021

        "downloadDir": "./node_modules/.cache"

you dont need to define that, by default it will use the home directory if it already exists and is wanted, otherwise will use the modulesCache option

Debug output with 8.0.0-beta.2

is that output from the tests / single run or from postinstall and could you provide the opposite if possible (to compare paths)?


also, because it is in a node-docker container, what it the setup? is it a custom dockerfile that uses FROM node:14.17.5 or a docker container that runs the mentioned image directly with bash on? also in any case, do you run npm instal / yarn install inside the container / layer or is it run outside?


for now, i dont actually see a problem with the storage paths

PS: i wrapped the log you provided in a collapsible / spoiler / details

@porwin88
Copy link
Author

porwin88 commented Oct 1, 2021

also, because it is in a node-docker container, what it the setup? is it a custom dockerfile that uses FROM node:14.17.5 or a docker container that runs the mentioned image directly with bash on? also in any case, do you run npm instal / yarn install inside the container / layer or is it run outside?

It is a custom dockerfile using FROM node:14.17.5 with RUN npm install inside the container.

is that output from the tests / single run or from postinstall and could you provide the opposite if possible (to compare paths)?

Unfortunately I don't understand what you are asking. This debug output comes from running the tests inside the docker container with debug activated. The output provided above came immediately before the package download which took place before the running of the first test, despite it having apparently downloaded once before, on npm i. This leads me to believe that it has something to do with the caching.

you dont need to define that, by default it will use the home directory if it already exists and is wanted, otherwise will use the modulesCache option

When I ran 7.0.0 without the "downloadDir": "./node_modules/.cache" option, I had the same problem (no cache). After reinstating the downloadDir option, it worked.

PS: i wrapped the log you provided in a collapsible / spoiler / details

Thanks, I will keep this in mind in the future.

@hasezoey
Copy link
Member

hasezoey commented Oct 1, 2021

Unfortunately I don't understand what you are asking

thanks, this clarified that the output was from the tests, could you try replacing RUN npm install with RUN MONGOMS_DEBUG=true npm install and see if there is any debug output and provide that?

When I ran 7.0.0 without the "downloadDir": "./node_modules/.cache" option, I had the same problem (no cache). After reinstating the downloadDir option, it worked.

this leads me to believe that somhow the CWD is messed up at postinstall and also $HOME is not quite correct - could you provide your dockerfile?
also, from the already provided debug log, it seems like your container $HOME is also your project directory, could you maybe try to change your project to be a sub-directory of $HOME or another directory outside of $HOME?

@porwin88
Copy link
Author

porwin88 commented Oct 1, 2021

could you try replacing RUN npm install with RUN MONGOMS_DEBUG=true npm install and see if there is any debug output and provide that?

Ran 8.0.0-beta.2 with MONGOMS_DEBUG=true npm install but no debug output and problem remained.

could you provide your dockerfile?

After further investigtation I have found that this problem is happening with npm run test as well, so it can not be a problem with the container. This is the debug output when running 8.0.0-beta.2.

Debug output on npm run test with 8.0.0-beta.2
# Base -----------------
  MongoMS:ResolveConfig Debug Mode Enabled, through package.json +0ms
  MongoMS:MongoMemoryServer create: Called .create() method +0ms
  MongoMS:MongoMemoryServer Mongo[unknown]: start: Called .start() method +1ms
  MongoMS:MongoMemoryServer Mongo[unknown]: _startUpInstance: Called MongoMemoryServer._startUpInstance() method +0ms
  MongoMS:MongoMemoryServer Mongo[unknown]: getStartOptions +1ms
  MongoMS:MongoMemoryServer Mongo[unknown]: _startUpInstance: Creating new MongoDB instance with options: {
  instance: {
    port: 57019,
    dbName: 'app_test',
    ip: '127.0.0.1',
    storageEngine: 'ephemeralForTest',
    replSet: undefined,
    dbPath: '/var/folders/2h/45jx_6sx4yzbhn5qdknqzfkm0000gp/T/mongo-mem--39989-t5AgjHtieNqS',
    tmpDir: {
      name: '/var/folders/2h/45jx_6sx4yzbhn5qdknqzfkm0000gp/T/mongo-mem--39989-t5AgjHtieNqS',
      removeCallback: [Function: _cleanupCallback]
    },
    args: undefined,
    auth: undefined
  },
  binary: undefined,
  spawn: undefined
} +8ms
  MongoMS:MongoInstance create: Called .create() method +0ms
  MongoMS:MongoInstance Mongo[57019]: start +0ms
  MongoMS:MongoBinary getPath +0ms
  MongoMS:DryMongoBinary generateOptions +0ms
  MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +2ms
  MongoMS:DryMongoBinary generatePaths +0ms
  MongoMS:DryMongoBinary getBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +1ms
  MongoMS:DryMongoBinary combineBinaryName +1ms
  MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary generateDownloadPath: Paths: {
  legacyHomeCache: '/Users/MACUSER/.cache/mongodb-binaries/mongod-x64-darwin-4.4.6',
  modulesCache: '/Users/MACUSER/repos/app/app/node_modules/.cache/mongodb-memory-server/mongod-x64-darwin-4.4.6',
  relative: '/Users/MACUSER/repos/app/app/mongodb-binaries/mongod-x64-darwin-4.4.6',
  resolveConfig: '/Users/MACUSER/repos/app/app/node_modules/.cache/mongod-x64-darwin-4.4.6'
}  +0ms
  MongoMS:DryMongoBinary generateDownloadPath: no existing binary for version "4.4.6" was found +2ms
  MongoMS:DryMongoBinary generateDownloadPath: using resolveConfig (DOWNLOAD_DIR) "/Users/MACUSER/repos/app/app/node_modules/.cache/mongod-x64-darwin-4.4.6" +1ms
  MongoMS:MongoBinary getPath: MongoBinary options: {
  "version": "4.4.6",
  "downloadDir": "/Users/MACUSER/repos/app/app/node_modules/.cache",
  "os": {
    "os": "darwin"
  },
  "arch": "x64",
  "systemBinary": "",
  "platform": "darwin",
  "checkMD5": false
} +7ms
  MongoMS:DryMongoBinary locateBinary: Trying to locate Binary for version "4.4.6" +0ms
  MongoMS:DryMongoBinary generateOptions +0ms
  MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +1ms
  MongoMS:DryMongoBinary generatePaths +0ms
  MongoMS:DryMongoBinary getBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary generateDownloadPath: Paths: {
  legacyHomeCache: '/Users/MACUSER/.cache/mongodb-binaries/mongod-x64-darwin-4.4.6',
  modulesCache: '/Users/MACUSER/repos/app/app/node_modules/.cache/mongodb-memory-server/mongod-x64-darwin-4.4.6',
  relative: '/Users/MACUSER/repos/app/app/mongodb-binaries/mongod-x64-darwin-4.4.6',
  resolveConfig: '/Users/MACUSER/repos/app/app/node_modules/.cache/mongod-x64-darwin-4.4.6'
}  +0ms
  MongoMS:DryMongoBinary generateDownloadPath: no existing binary for version "4.4.6" was found +1ms
  MongoMS:DryMongoBinary generateDownloadPath: using resolveConfig (DOWNLOAD_DIR) "/Users/MACUSER/repos/app/app/node_modules/.cache/mongod-x64-darwin-4.4.6" +0ms
  MongoMS:DryMongoBinary locateBinary: running generateDownloadPath +0ms
  MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +0ms
  MongoMS:DryMongoBinary generatePaths +0ms
  MongoMS:DryMongoBinary getBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +1ms
  MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary generateDownloadPath: Paths: {
  legacyHomeCache: '/Users/MACUSER/.cache/mongodb-binaries/mongod-x64-darwin-4.4.6',
  modulesCache: '/Users/MACUSER/repos/app/app/node_modules/.cache/mongodb-memory-server/mongod-x64-darwin-4.4.6',
  relative: '/Users/MACUSER/repos/app/app/mongodb-binaries/mongod-x64-darwin-4.4.6',
  resolveConfig: '/Users/MACUSER/repos/app/app/node_modules/.cache/mongod-x64-darwin-4.4.6'
}  +0ms
  MongoMS:DryMongoBinary generateDownloadPath: no existing binary for version "4.4.6" was found +0ms
  MongoMS:DryMongoBinary generateDownloadPath: using resolveConfig (DOWNLOAD_DIR) "/Users/MACUSER/repos/app/app/node_modules/.cache/mongod-x64-darwin-4.4.6" +1ms
  MongoMS:DryMongoBinary locateBinary: could not find a existing binary +0ms
  MongoMS:MongoBinary getPath: "RUNTIME_DOWNLOAD" is "true", trying to download +4ms
  MongoMS:MongoBinary download +0ms
  MongoMS:MongoBinary download: Waiting to acquire Download lock for file "/Users/MACUSER/repos/app/app/node_modules/.cache/4.4.6.lock" +3ms
  MongoMS:LockFile lock: Locking file "/Users/MACUSER/repos/app/app/node_modules/.cache/4.4.6.lock" +0ms
  MongoMS:LockFile checkLock: for file "/Users/MACUSER/repos/app/app/node_modules/.cache/4.4.6.lock" with uuid: "undefined" +1ms
  MongoMS:LockFile createLock: trying to create a lock file for "/Users/MACUSER/repos/app/app/node_modules/.cache/4.4.6.lock" +0ms
  MongoMS:LockFile createLock: Lock File Created for file "/Users/MACUSER/repos/app/app/node_modules/.cache/4.4.6.lock" +5ms
  MongoMS:MongoBinary download: Download lock acquired +6ms
  MongoMS:MongoBinary download: Adding version 4.4.6 to cache +0ms
  MongoMS:MongoBinaryDownload getMongodPath +0ms
  MongoMS:DryMongoBinary generateOptions +10ms
  MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +0ms
  MongoMS:DryMongoBinary generatePaths +0ms
  MongoMS:DryMongoBinary getBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty +1ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:DryMongoBinary generateDownloadPath: Paths: {
  legacyHomeCache: '/Users/MACUSER/.cache/mongodb-binaries/mongod-x64-darwin-4.4.6',
  modulesCache: '/Users/MACUSER/repos/app/app/node_modules/.cache/mongodb-memory-server/mongod-x64-darwin-4.4.6',
  relative: '/Users/MACUSER/repos/app/app/mongodb-binaries/mongod-x64-darwin-4.4.6',
  resolveConfig: '/Users/MACUSER/repos/app/app/node_modules/.cache/mongod-x64-darwin-4.4.6'
}  +0ms
  MongoMS:DryMongoBinary generateDownloadPath: no existing binary for version "4.4.6" was found +0ms
  MongoMS:DryMongoBinary generateDownloadPath: using resolveConfig (DOWNLOAD_DIR) "/Users/MACUSER/repos/app/app/node_modules/.cache/mongod-x64-darwin-4.4.6" +1ms
  MongoMS:DryMongoBinary getBinaryName +0ms
  MongoMS:DryMongoBinary combineBinaryName +0ms
  MongoMS:MongoBinaryDownload startDownload +2ms
  MongoMS:MongoBinaryDownloadUrl Using "mongodb-macos-x86_64-4.4.6.tgz" as the Archive String +0ms
  MongoMS:MongoBinaryDownloadUrl Using "https://fastdl.mongodb.org" as the mirror +0ms
  MongoMS:MongoBinaryDownload download +3ms
  MongoMS:MongoBinaryDownload download: Downloading: "https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.4.6.tgz" +1ms
  MongoMS:MongoBinaryDownload httpDownload +1ms
  MongoMS:MongoBinaryDownload httpDownload: trying to download "https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.4.6.tgz" +0ms
Downloading MongoDB "4.4.6": 39.2% (22.4mb / 57.2

@hasezoey
Copy link
Member

hasezoey commented Oct 1, 2021

After further investigtation I have found that this problem is happening with npm run test as well, so it can not be a problem with the container. This is the debug output when running 8.0.0-beta.2.

my guess is this log is from running it on the host machine (macos / osx / darwin)?


totally forgot that npm 7.x does not log any script output anymore, please try running MONGOMS_DEBUG=1 npm install --foreground-scripts without having DOWNLOAD_DIR defined / set (if you are interested, see npm/cli#3820)

@porwin88
Copy link
Author

porwin88 commented Oct 5, 2021

Hi, sorry for the delay, I managed to corner a colleague to help me debug and it was in fact a problem on our side. Long story short (as clearly stated in the docs :/) the root needs to be specified in the downloadDir path: projectRoot/node_modules/.cache/mongodb-binaries Without this, the binary was being saved in the user root .cache of our intermediate docker container and not being copied across with the node_modules. Sorry for the runaround.

Thanks a lot for your prompt and dedicated support! It is very much appreciated.

@porwin88 porwin88 closed this as completed Oct 5, 2021
@hasezoey
Copy link
Member

hasezoey commented Oct 5, 2021

Long story short (as clearly stated in the docs :/) the root needs to be specified in the downloadDir path: projectRoot/node_modules/.cache/mongodb-binaries Without this, the binary was being saved in the user root .cache of our intermediate docker container and not being copied across with the node_modules. Sorry for the runaround.

bascially, the binary was installed to the wrong user?

@hasezoey hasezoey added question and removed bug labels Oct 5, 2021
@porwin88
Copy link
Author

porwin88 commented Oct 5, 2021

The downloadDir path was incorrectly specified (it was "./node_modules/.cache" instead of "/home/node/node_modules/.cache"). As a result, npm i was caching the binary in "root/.cache".

Our Dockerfile splits the images into base, builder and test. We ran npm i in the builder image, then copied the node_modules into the test image and then ran the test image. Thus when we provided the incorrect downloadDir path, the binary was not being copied over together with the node_modules and had to be downloaded again.

Dockerfile
# Base -----------------
FROM node:14.17.5 AS base
WORKDIR /home/node

# Builder -----------------
FROM base AS builder

# Install all dependencies
COPY package*.json ./
RUN npm install

# test -----------------
FROM base AS test
ENV IS_CONTAINER=1

# Copy app source and dependencies
COPY --chown=node:node . .

COPY --from=builder --chown=node:node /home/node/node_modules ./node_modules

USER node
CMD ["npm", "run", "test"]

@hasezoey
Copy link
Member

hasezoey commented Oct 5, 2021

The downloadDir path was incorrectly specified (it was "./node_modules/.cache" instead of "/home/node/node_modules/.cache"). As a result, npm i was caching the binary in "root/.cache".

so npm install was executed as user root and later was switched to user node, but the workdir was already /home/node

from my understanding it should have resolved correctly:

  • cwd is /home/node
  • extra path is ./node_modules/.cache
  • should result in /home/node/node_modules/.cache

did the path maybe get overridden by COPY --chown=node:node . . or COPY --from=builder --chown=node:node /home/node/node_modules ./node_modules?

@hasezoey

This comment has been minimized.

@hasezoey
Copy link
Member

hasezoey commented Oct 5, 2021

i just tried with your dockerfile in a test project, and i could reproduce your problem

because the downloadDir path was not absolute, it somehow got resolved to /home/node/node_modules/mongodb-memory-server/node_modules/.cache/mongod-x64-debian-4.4.6, which is obviously wrong

@hasezoey
Copy link
Member

hasezoey commented Oct 5, 2021

reopen, because the actual problem was found

@hasezoey hasezoey reopened this Oct 5, 2021
@hasezoey hasezoey added bug and removed question labels Oct 5, 2021
@hasezoey hasezoey changed the title mongo-memory-server 7.4.1 not caching binary on install in container Postinstall does not resolve a relative "DOWNLOAD_DIR" correctly Oct 5, 2021
@porwin88
Copy link
Author

porwin88 commented Oct 5, 2021

i just noticed, it is in your test docker file FROM base AS test, shouldnt it be FROM builder AS test?

We just copy the node_modules from that image without using it as the base for the next image. Wasn't my call to construct it that way, so can't be sure why. It works like this though ;)

from my understanding it should have resolved correctly:
cwd is /home/node
extra path is ./node_modules/.cache
should result in /home/node/node_modules/.cache

That was also my understanding, which is why I thought it was a problem at your end, but after logging into the container and searching for the binary, we discovered that it was indeed in /root/.cache and not ./node_modules/.cache. Once we changed the downloadDir to specify /home/node/node_modules/.cache, the binary was being correctly cached in node_modules.

@hasezoey
Copy link
Member

hasezoey commented Oct 5, 2021

fixed with 8f16a2a in 8.0.0-beta.4 (no automatic, because i did not know if it would fix this issue)

this issue will stay open until this fix is merged into master

@hasezoey hasezoey added this to the 8.0 milestone Oct 5, 2021
@hasezoey
Copy link
Member

hasezoey commented Oct 5, 2021

in 8f16a2a (in beta) i rewrote the function to be more maintainable

i also added a fix for 7.x (25c4119), which should be in 7.4.3 after the build finishes

@github-actions
Copy link

github-actions bot commented Oct 5, 2021

🎉 This issue has been resolved in version 7.4.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot added the released Pull Request released | Issue is fixed label Oct 5, 2021
@github-actions
Copy link

🎉 This issue has been resolved in version 8.0.0-beta.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ChrisLahaye
Copy link

@hasezoey I am using mongodb-memory-server-core v8.0.2 and don't think this is properly fixed. I invoke the download using jest and see that the download path is still global (/root/.cache) instead of local (node_modules).

[Container] 2021/11/11 11:53:41 Running command yarn jest
yarn run v1.22.15
$ /codebuild/output/src822999710/src/node_modules/.bin/jest
2021-11-11T11:53:54.307Z MongoMS:ResolveConfig Debug Mode Enabled, through Environment Variable
2021-11-11T11:53:54.308Z MongoMS:ResolveConfig findPackageJson: Found package.json at "/codebuild/output/src822999710/src/package.json"
2021-11-11T11:53:54.308Z MongoMS:ResolveConfig Debug Mode Enabled, through package.json
2021-11-11T11:53:54.520Z MongoMS:MongoMemoryReplSet create: Called .create() method
2021-11-11T11:53:54.521Z MongoMS:MongoMemoryReplSet start: stopped
(node:316) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
2021-11-11T11:53:54.522Z MongoMS:MongoMemoryReplSet initAllServers
2021-11-11T11:53:54.522Z MongoMS:MongoMemoryReplSet initAllServers: starting extra server "1" of "1" (count: 1)
2021-11-11T11:53:54.522Z MongoMS:MongoMemoryReplSet getInstanceOpts: instance opts: {
  auth: false,
  args: [],
  dbName: '',
  ip: '127.0.0.1',
  replSet: 'testset',
  storageEngine: 'wiredTiger'
}
2021-11-11T11:53:54.523Z MongoMS:MongoMemoryReplSet initAllServers: waiting for all servers to finish starting
2021-11-11T11:53:54.524Z MongoMS:MongoMemoryServer Mongo[unknown]: start: Called .start() method
2021-11-11T11:53:54.524Z MongoMS:MongoMemoryServer Mongo[unknown]: _startUpInstance: Called MongoMemoryServer._startUpInstance() method
2021-11-11T11:53:54.524Z MongoMS:MongoMemoryServer Mongo[unknown]: getStartOptions
2021-11-11T11:53:54.526Z MongoMS:MongoMemoryServer Mongo[unknown]: _startUpInstance: Creating new MongoDB instance with options: {
  instance: {
    port: 38215,
    dbName: '',
    ip: '127.0.0.1',
    storageEngine: 'wiredTiger',
    replSet: 'testset',
    dbPath: '/tmp/mongo-mem--316-rixvIS04jLWe',
    tmpDir: {
      name: '/tmp/mongo-mem--316-rixvIS04jLWe',
      removeCallback: [Function: _cleanupCallback]
    },
    args: [],
    auth: false
  },
  binary: {},
  spawn: {}
}
2021-11-11T11:53:54.527Z MongoMS:MongoInstance create: Called .create() method
2021-11-11T11:53:54.527Z MongoMS:MongoInstance Mongo[38215]: start
2021-11-11T11:53:54.527Z MongoMS:MongoBinary getPath
2021-11-11T11:53:54.527Z MongoMS:DryMongoBinary generateOptions
2021-11-11T11:53:54.530Z MongoMS:utils tryReleaseFile: "/etc/upstream-release/lsb-release" does not exist
2021-11-11T11:53:54.532Z MongoMS:getos getLinuxInformation: Using etcOsRelease
2021-11-11T11:53:54.533Z MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true"
2021-11-11T11:53:54.533Z MongoMS:DryMongoBinary generatePaths {
  version: '5.0.3',
  downloadDir: '',
  os: {
    os: 'linux',
    dist: 'ubuntu',
    codename: 'focal',
    release: '20.04',
    id_like: [ 'debian' ]
  },
  arch: 'x64',
  systemBinary: ''
}
2021-11-11T11:53:54.533Z MongoMS:DryMongoBinary getBinaryName
2021-11-11T11:53:54.533Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:54.533Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:54.534Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:54.534Z MongoMS:DryMongoBinary generateDownloadPath: Paths: {
  legacyHomeCache: '/root/.cache/mongodb-binaries/mongod-x64-ubuntu-5.0.3',
  modulesCache: '/codebuild/output/src822999710/src/node_modules/.cache/mongodb-memory-server/mongod-x64-ubuntu-5.0.3',
  relative: '/codebuild/output/src822999710/src/mongodb-binaries/mongod-x64-ubuntu-5.0.3',
  resolveConfig: ''
} 
2021-11-11T11:53:54.535Z MongoMS:DryMongoBinary generateDownloadPath: no existing binary for version "5.0.3" was found
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary generateDownloadPath: using global (preferGlobal) "/root/.cache/mongodb-binaries/mongod-x64-ubuntu-5.0.3"
2021-11-11T11:53:54.536Z MongoMS:MongoBinary getPath: MongoBinary options: {
  "version": "5.0.3",
  "downloadDir": "/root/.cache/mongodb-binaries",
  "os": {
    "os": "linux",
    "dist": "ubuntu",
    "codename": "focal",
    "release": "20.04",
    "id_like": [
      "debian"
    ]
  },
  "arch": "x64",
  "systemBinary": "",
  "platform": "linux",
  "checkMD5": false
}
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary locateBinary: Trying to locate Binary for version "5.0.3"
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary generateOptions
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true"
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary generatePaths {
  version: '5.0.3',
  downloadDir: '/root/.cache/mongodb-binaries',
  os: {
    os: 'linux',
    dist: 'ubuntu',
    codename: 'focal',
    release: '20.04',
    id_like: [ 'debian' ]
  },
  arch: 'x64',
  systemBinary: ''
}
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary getBinaryName
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary generateDownloadPath: Paths: {
  legacyHomeCache: '/root/.cache/mongodb-binaries/mongod-x64-ubuntu-5.0.3',
  modulesCache: '/codebuild/output/src822999710/src/node_modules/.cache/mongodb-memory-server/mongod-x64-ubuntu-5.0.3',
  relative: '/codebuild/output/src822999710/src/mongodb-binaries/mongod-x64-ubuntu-5.0.3',
  resolveConfig: '/root/.cache/mongodb-binaries/mongod-x64-ubuntu-5.0.3'
} 
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary generateDownloadPath: no existing binary for version "5.0.3" was found
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary generateDownloadPath: using resolveConfig (DOWNLOAD_DIR) "/root/.cache/mongodb-binaries/mongod-x64-ubuntu-5.0.3"
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary locateBinary: running generateDownloadPath
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true"
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary generatePaths {
  version: '5.0.3',
  downloadDir: '/root/.cache/mongodb-binaries',
  os: {
    os: 'linux',
    dist: 'ubuntu',
    codename: 'focal',
    release: '20.04',
    id_like: [ 'debian' ]
  },
  arch: 'x64',
  systemBinary: ''
}
2021-11-11T11:53:54.536Z MongoMS:DryMongoBinary getBinaryName
2021-11-11T11:53:54.537Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:54.537Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:54.537Z MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty
2021-11-11T11:53:54.537Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:54.537Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:54.537Z MongoMS:DryMongoBinary generateDownloadPath: Paths: {
  legacyHomeCache: '/root/.cache/mongodb-binaries/mongod-x64-ubuntu-5.0.3',
  modulesCache: '/codebuild/output/src822999710/src/node_modules/.cache/mongodb-memory-server/mongod-x64-ubuntu-5.0.3',
  relative: '/codebuild/output/src822999710/src/mongodb-binaries/mongod-x64-ubuntu-5.0.3',
  resolveConfig: '/root/.cache/mongodb-binaries/mongod-x64-ubuntu-5.0.3'
} 
2021-11-11T11:53:54.537Z MongoMS:DryMongoBinary generateDownloadPath: no existing binary for version "5.0.3" was found
2021-11-11T11:53:54.537Z MongoMS:DryMongoBinary generateDownloadPath: using resolveConfig (DOWNLOAD_DIR) "/root/.cache/mongodb-binaries/mongod-x64-ubuntu-5.0.3"
2021-11-11T11:53:54.537Z MongoMS:DryMongoBinary locateBinary: could not find a existing binary
2021-11-11T11:53:54.537Z MongoMS:MongoBinary getPath: "RUNTIME_DOWNLOAD" is "true", trying to download
2021-11-11T11:53:54.537Z MongoMS:MongoBinary download
2021-11-11T11:53:54.537Z MongoMS:MongoBinary download: Waiting to acquire Download lock for file "/root/.cache/mongodb-binaries/5.0.3.lock"
2021-11-11T11:53:54.537Z MongoMS:LockFile lock: Locking file "/root/.cache/mongodb-binaries/5.0.3.lock"
2021-11-11T11:53:54.538Z MongoMS:LockFile checkLock: for file "/root/.cache/mongodb-binaries/5.0.3.lock" with uuid: "undefined"
2021-11-11T11:53:54.538Z MongoMS:LockFile createLock: trying to create a lock file for "/root/.cache/mongodb-binaries/5.0.3.lock"
2021-11-11T11:53:54.539Z MongoMS:LockFile createLock: Lock File Created for file "/root/.cache/mongodb-binaries/5.0.3.lock"
2021-11-11T11:53:54.539Z MongoMS:MongoBinary download: Download lock acquired
2021-11-11T11:53:54.539Z MongoMS:MongoBinary download: Adding version 5.0.3 to cache
2021-11-11T11:53:54.539Z MongoMS:MongoBinaryDownload getMongodPath
2021-11-11T11:53:54.539Z MongoMS:DryMongoBinary generateOptions
2021-11-11T11:53:54.539Z MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true"
2021-11-11T11:53:54.539Z MongoMS:DryMongoBinary generatePaths {
  version: '5.0.3',
  downloadDir: '/root/.cache/mongodb-binaries',
  os: {
    os: 'linux',
    dist: 'ubuntu',
    codename: 'focal',
    release: '20.04',
    id_like: [ 'debian' ]
  },
  arch: 'x64',
  systemBinary: ''
}
2021-11-11T11:53:54.540Z MongoMS:DryMongoBinary getBinaryName
2021-11-11T11:53:54.540Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:54.540Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:54.540Z MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty
2021-11-11T11:53:54.540Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:54.540Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:54.540Z MongoMS:DryMongoBinary generateDownloadPath: Paths: {
  legacyHomeCache: '/root/.cache/mongodb-binaries/mongod-x64-ubuntu-5.0.3',
  modulesCache: '/codebuild/output/src822999710/src/node_modules/.cache/mongodb-memory-server/mongod-x64-ubuntu-5.0.3',
  relative: '/codebuild/output/src822999710/src/mongodb-binaries/mongod-x64-ubuntu-5.0.3',
  resolveConfig: '/root/.cache/mongodb-binaries/mongod-x64-ubuntu-5.0.3'
} 
2021-11-11T11:53:54.540Z MongoMS:DryMongoBinary generateDownloadPath: no existing binary for version "5.0.3" was found
2021-11-11T11:53:54.540Z MongoMS:DryMongoBinary generateDownloadPath: using resolveConfig (DOWNLOAD_DIR) "/root/.cache/mongodb-binaries/mongod-x64-ubuntu-5.0.3"
2021-11-11T11:53:54.540Z MongoMS:DryMongoBinary getBinaryName
2021-11-11T11:53:54.540Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:54.540Z MongoMS:MongoBinaryDownload startDownload
2021-11-11T11:53:54.543Z MongoMS:MongoBinaryDownloadUrl Using "mongodb-linux-x86_64-ubuntu2004-5.0.3.tgz" as the Archive String
2021-11-11T11:53:54.543Z MongoMS:MongoBinaryDownloadUrl Using "https://fastdl.mongodb.org" as the mirror
2021-11-11T11:53:54.543Z MongoMS:MongoBinaryDownload download
2021-11-11T11:53:54.543Z MongoMS:MongoBinaryDownload download: Downloading: "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-5.0.3.tgz"
2021-11-11T11:53:54.544Z MongoMS:MongoBinaryDownload httpDownload
2021-11-11T11:53:54.544Z MongoMS:MongoBinaryDownload httpDownload: trying to download "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-5.0.3.tgz"
Downloading MongoDB "5.0.3": 0% (0mb / 81.3mb)
Downloading MongoDB "5.0.3": 100% (81.3mb / 81.3mb)
2021-11-11T11:53:55.509Z MongoMS:MongoBinaryDownload httpDownload: moved "/root/.cache/mongodb-binaries/mongodb-linux-x86_64-ubuntu2004-5.0.3.tgz.downloading" to "/root/.cache/mongodb-binaries/mongodb-linux-x86_64-ubuntu2004-5.0.3.tgz"
2021-11-11T11:53:55.509Z MongoMS:MongoBinaryDownload makeMD5check: Checking MD5 of downloaded binary...
2021-11-11T11:53:55.509Z MongoMS:MongoBinaryDownload makeMD5check: checkMD5 is disabled
2021-11-11T11:53:55.509Z MongoMS:MongoBinaryDownload extract
2021-11-11T11:53:55.510Z MongoMS:DryMongoBinary generateOptions
2021-11-11T11:53:55.510Z MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true"
2021-11-11T11:53:55.510Z MongoMS:DryMongoBinary generatePaths {
  version: '5.0.3',
  downloadDir: '/root/.cache/mongodb-binaries',
  os: {
    os: 'linux',
    dist: 'ubuntu',
    codename: 'focal',
    release: '20.04',
    id_like: [ 'debian' ]
  },
  arch: 'x64',
  systemBinary: ''
}
2021-11-11T11:53:55.510Z MongoMS:DryMongoBinary getBinaryName
2021-11-11T11:53:55.510Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:55.510Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:55.510Z MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty
2021-11-11T11:53:55.510Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:55.510Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:55.510Z MongoMS:DryMongoBinary generateDownloadPath: Paths: {
  legacyHomeCache: '/root/.cache/mongodb-binaries/mongod-x64-ubuntu-5.0.3',
  modulesCache: '/codebuild/output/src822999710/src/node_modules/.cache/mongodb-memory-server/mongod-x64-ubuntu-5.0.3',
  relative: '/codebuild/output/src822999710/src/mongodb-binaries/mongod-x64-ubuntu-5.0.3',
  resolveConfig: '/root/.cache/mongodb-binaries/mongod-x64-ubuntu-5.0.3'
} 
2021-11-11T11:53:55.510Z MongoMS:DryMongoBinary generateDownloadPath: no existing binary for version "5.0.3" was found
2021-11-11T11:53:55.510Z MongoMS:DryMongoBinary generateDownloadPath: using resolveConfig (DOWNLOAD_DIR) "/root/.cache/mongodb-binaries/mongod-x64-ubuntu-5.0.3"
2021-11-11T11:53:55.510Z MongoMS:DryMongoBinary getBinaryName
2021-11-11T11:53:55.510Z MongoMS:DryMongoBinary combineBinaryName
2021-11-11T11:53:55.510Z MongoMS:MongoBinaryDownload extract: archive: "/root/.cache/mongodb-binaries/mongodb-linux-x86_64-ubuntu2004-5.0.3.tgz" final: "/root/.cache/mongodb-binaries/mongod-x64-ubuntu-5.0.3"
2021-11-11T11:53:55.511Z MongoMS:MongoBinaryDownload extractTarGz
2021-11-11T11:53:56.802Z MongoMS:MongoBinary download: Removing Download lock

@hasezoey
Copy link
Member

hasezoey commented Nov 11, 2021

@ChrisLahaye please provide how you set your custom DOWNLOAD_DIR option, guessing from the log, it does not appear to be set

it found the package.json at /codebuild/output/src822999710/src/package.json which contained a config: { mongodbMemoryServer: {] }, but does not seem like DOWNLOAD_DIR is set through it

also, if you want to download to local node_modules folder, you can set option PREFER_GLOBAL_PATH​ to false (true by default)
note: the binary will still be search there and used if it exists, but when download it needed, it will download it into the DOWNLOAD_DIR, if set

edit:

I am using mongodb-memory-server-core v8.0.2 and don't think this is properly fixed. I invoke the download using jest and see that the download path is still global (/root/.cache) instead of local (node_modules).

guessing from this message, it seems like your issue is not related to this issue, because yours it at runtime and not in postinstall, so maybe open a new issue referencing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug released on @beta released Pull Request released | Issue is fixed
Projects
None yet
Development

No branches or pull requests

3 participants