Yarn install fails when trying to install mongodb-memory-server on a Github hosted runner
Patrickkooijman opened this issue · 5 comments
Versions
- NodeJS: 18
- mongodb-memory-server-*: 8.15.1
- mongodb(the binary version): 5.0.19
- mongodb(the js package): 5.0.2
- mongoose: 7.5.3
- system: ubuntu-22.04
package: mongo-memory-server
What is your question?
I'm running into an issue with installing this dependency on a Github hosted runner. When it's installing the dependencies using yarn install
everything looks normal, but suddenly it exits with an exit code 1, throwing this error.
error An unexpected error occurred: "/home/runner/work/product-availability-service/product-availability-service/node_modules/mongodb-memory-server: Cannot read properties of undefined (reading 'config')".
I have the feeling this is thrown by the post-install script, but I'm not 100%. Also tried to get more debug logs, but that didn't result into more details, also not with the debug
flag. Also trying to disable the post-install script using the disablePostinstall
didn't solve the issue.
But the weirdest thing is, sometimes it works, sometimes it doesn't. I.e. on attempt #1 it failed, on attempt #2 it succeeded and on attempt #3 it failed again. When it succeeds, above error is not shown. I'm using this version for about a month, and until last Friday all worked as expected.
Hopefully someone has experienced this before and can point me into the right direction.
is this the exact error and do you have a stacktrace available? because there is no usage of config
(either import or variable or path) in mongodb-memory-server
, the first usage of config
would be in mongodb-memory-server-core
's resolveConfig
file, but i would need to know where exactly the problem is
Also tried to get more debug logs, but that didn't result into more details, also not with the debug flag
if the problem is in resolveConfig
, then this is to be expected, because that is the file that reads all configs and sets-up the logging level, aside from that, maybe try MONGOMS_DEBUG=true
(or if even that does not work DEBUG=MongoMS:*
)
also, what changed between those attempts? did a package.json
change?
Unfortunately there is no more logging in the runner, even with the applied ENV variables. Also nothing has changed between the deployments. The frustrating thing is that it can succeed / fail on subsequent trials. I have the feeling it has something to do with caching inside the runners, but I'm not sure.
I also tried to disable the post install script, but also without any luck
Unfortunately there is no more logging in the runner, even with the applied ENV variables. Also nothing has changed between the deployments
then i am sorry, but i cannot help further with that, the only thing i could suggest it to clear all cache in a all runners & workflows, if that is even possible
After searching for a while I have found more details, and this also made it clear what happened. Leaving my findings here in case others run into the same issue.
TypeError: /home/runner/work/product-availability-service/product-availability-service/node_modules/mongodb-memory-server: Cannot read properties of undefined (reading 'getOption')
at Config.getOption (/usr/local/lib/node_modules/yarn/lib/cli.js:40816:38)
at /usr/local/lib/node_modules/yarn/lib/cli.js:34074:28
at Generator.next ()
at step (/usr/local/lib/node_modules/yarn/lib/cli.js:310:30)
at /usr/local/lib/node_modules/yarn/lib/cli.js:328:14
at new Promise ()
at new F (/usr/local/lib/node_modules/yarn/lib/cli.js:5305:28)
at /usr/local/lib/node_modules/yarn/lib/cli.js:307:12
at makeEnv (/usr/local/lib/node_modules/yarn/lib/cli.js:34300:18)
at /usr/local/lib/node_modules/yarn/lib/cli.js:34314:21
There has been a breaking change in NPM which caused this issue when using yarn classic. The node-gyp package is removed from the global bin, so yarn tries to install node-gyp while running yarn install
, which then randomly fails, mostly while running in a CI. I have been able to "fix" this by manually running yarn global add node-gyp
in the runner before running yarn install
. In the end I think moving over to yarn 2.x+ or start using NPM would be a better option though.
thanks for reporting back with a cause and fix (just a note, to my knowledge MMS (and dependencies) dont use node-gyp, unless implicitly?)