vkarpov15 / run-rs

Zero-config MongoDB runner. Starts a replica set with no non-Node dependencies, not even MongoDB.
Apache License 2.0
265 stars 36 forks source link

Cannot read property 'toString' of null, on macOS #37

Closed ajmas closed 5 years ago

ajmas commented 5 years ago

I just ran run-rs --version 4.0.0 on macOS 10.14.6 and got the output below. Note, I did try stopping the mongodb server that I had running, but this did not change anything.

╰─➤  run-rs --version 4.0.0
Downloading MongoDB 4.0.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 66.3M  100 66.3M    0     0  10.9M      0  0:00:06  0:00:06 --:--:-- 11.0M
x mongodb-osx-x86_64-4.0.0/README
x mongodb-osx-x86_64-4.0.0/THIRD-PARTY-NOTICES
x mongodb-osx-x86_64-4.0.0/MPL-2
x mongodb-osx-x86_64-4.0.0/GNU-AGPL-3.0
x mongodb-osx-x86_64-4.0.0/LICENSE-Community.txt
x mongodb-osx-x86_64-4.0.0/bin/mongodump
x mongodb-osx-x86_64-4.0.0/bin/mongorestore
x mongodb-osx-x86_64-4.0.0/bin/mongoexport
x mongodb-osx-x86_64-4.0.0/bin/mongoimport
x mongodb-osx-x86_64-4.0.0/bin/mongostat
x mongodb-osx-x86_64-4.0.0/bin/mongotop
x mongodb-osx-x86_64-4.0.0/bin/bsondump
x mongodb-osx-x86_64-4.0.0/bin/mongofiles
x mongodb-osx-x86_64-4.0.0/bin/mongoreplay
x mongodb-osx-x86_64-4.0.0/bin/mongod
x mongodb-osx-x86_64-4.0.0/bin/mongos
x mongodb-osx-x86_64-4.0.0/bin/mongo
x mongodb-osx-x86_64-4.0.0/bin/install_compass
Copied MongoDB 4.0.0 to '/Users/ajmas/npm/lib/node_modules/run-rs/src/4.0.0'
Purging database...
Running '/Users/ajmas/npm/lib/node_modules/run-rs/4.0.0/mongod' [ 27017, 27018, 27019 ]
Starting replica set...
/Users/ajmas/npm/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/replset.js:124
            .toString()
             ^

TypeError: Cannot read property 'toString' of null
    at ChildProcess.<anonymous> (/Users/ajmas/npm/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/replset.js:124:14)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Socket.stream.socket.on (internal/child_process.js:389:11)
    at Socket.emit (events.js:189:13)
    at Pipe._handle.close (net.js:597:12)

Node version is v10.15.3

ajmas commented 5 years ago

After the issue above, I did get another issue after running the command another two times, though not sure in what way it may be related to the original issue.

╰─➤  run-rs --version 4.0.0                                                                                                                                                           1 ↵
Downloading MongoDB 4.0.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 66.3M  100 66.3M    0     0  11.2M      0  0:00:05  0:00:05 --:--:-- 11.0M
x mongodb-osx-x86_64-4.0.0/README
x mongodb-osx-x86_64-4.0.0/THIRD-PARTY-NOTICES
x mongodb-osx-x86_64-4.0.0/MPL-2
x mongodb-osx-x86_64-4.0.0/GNU-AGPL-3.0
x mongodb-osx-x86_64-4.0.0/LICENSE-Community.txt
x mongodb-osx-x86_64-4.0.0/bin/mongodump
x mongodb-osx-x86_64-4.0.0/bin/mongorestore
x mongodb-osx-x86_64-4.0.0/bin/mongoexport
x mongodb-osx-x86_64-4.0.0/bin/mongoimport
x mongodb-osx-x86_64-4.0.0/bin/mongostat
x mongodb-osx-x86_64-4.0.0/bin/mongotop
x mongodb-osx-x86_64-4.0.0/bin/bsondump
x mongodb-osx-x86_64-4.0.0/bin/mongofiles
x mongodb-osx-x86_64-4.0.0/bin/mongoreplay
x mongodb-osx-x86_64-4.0.0/bin/mongod
x mongodb-osx-x86_64-4.0.0/bin/mongos
x mongodb-osx-x86_64-4.0.0/bin/mongo
x mongodb-osx-x86_64-4.0.0/bin/install_compass
mv: rename ./mongodb-osx-x86_64-4.0.0/bin to /Users/ajmas/npm/lib/node_modules/run-rs/src/4.0.0/bin: Directory not empty
Error: Command failed: mv ./mongodb-osx-x86_64-4.0.0/bin /Users/ajmas/npm/lib/node_modules/run-rs/src/4.0.0
mv: rename ./mongodb-osx-x86_64-4.0.0/bin to /Users/ajmas/npm/lib/node_modules/run-rs/src/4.0.0/bin: Directory not empty

    at checkExecSyncError (child_process.js:616:11)
    at execSync (child_process.js:653:13)
    at download (/Users/ajmas/npm/lib/node_modules/run-rs/src/download.js:54:5)
    at run (/Users/ajmas/npm/lib/node_modules/run-rs/index.js:80:20)
    at run.next (<anonymous>)
    at onFulfilled (/Users/ajmas/npm/lib/node_modules/run-rs/node_modules/co/index.js:65:19)
    at /Users/ajmas/npm/lib/node_modules/run-rs/node_modules/co/index.js:54:5
    at new Promise (<anonymous>)
    at co (/Users/ajmas/npm/lib/node_modules/run-rs/node_modules/co/index.js:50:10)
    at Object.<anonymous> (/Users/ajmas/npm/lib/node_modules/run-rs/index.js:30:1)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
dtboy1995 commented 5 years ago

The same issue i install run-rs on travis cl

+ run-rs@0.5.3
added 95 packages from 60 contributors in 5.419s
before_install.2
0.00s$ run-rs -v 4.0.0 &
install
6.01s$ npm install
Downloading MongoDB 4.0.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 67.3M  100 67.3M    0     0  54.8M      0  0:00:01  0:00:01 --:--:-- 54.8M
Copied MongoDB 4.0.0 to '/home/travis/.nvm/versions/node/v8.16.1/lib/node_modules/run-rs/src/4.0.0'
Purging database...
Running '/home/travis/.nvm/versions/node/v8.16.1/lib/node_modules/run-rs/4.0.0/mongod' [ 27017, 27018, 27019 ]
Starting replica set...
/home/travis/.nvm/versions/node/v8.16.1/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/replset.js:124
            .toString()
             ^
TypeError: Cannot read property 'toString' of null
    at ChildProcess.<anonymous> (/home/travis/.nvm/versions/node/v8.16.1/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/replset.js:124:14)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:915:16)
    at Socket.stream.socket.on (internal/child_process.js:336:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:561:12)
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
audited 876892 packages in 5.376s
found 0 vulnerabilities
zxpectre commented 5 years ago

Same happened to me using 0.5.3 under Ubuntu. Downgrading to 0.5.2 works fine.

Anirudh0509 commented 5 years ago

I am getting the same error, when I run command run-rs

Starting replica set... /usr/local/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/replset.js:124 .toString() ^

TypeError: Cannot read property 'toString' of null at ChildProcess. (/usr/local/lib/node_modules/run-rs/node_modules/mongodb-topology-manager/lib/replset.js:124:14) at ChildProcess.emit (events.js:203:13) at maybeClose (internal/child_process.js:1021:16) at Socket. (internal/child_process.js:430:11) at Socket.emit (events.js:203:13) at Pipe. (net.js:588:12)

After implementing ProtonGustave fix for wrong path, I am getting the following error.

Error: Command failed: mv ./mongodb-osx-x86_64-4.0.6/bin {mainScriptDir}/4.0.6 mv: rename ./mongodb-osx-x86_64-4.0.6/bin to {mainScriptDir}/4.0.6: No such file or directory

at checkExecSyncError (child_process.js:621:11)
at execSync (child_process.js:657:15)
at download (/usr/local/lib/node_modules/run-rs/src/download.js:56:5)
at run (/usr/local/lib/node_modules/run-rs/index.js:80:20)
at run.next (<anonymous>)
at onFulfilled (/usr/local/lib/node_modules/run-rs/node_modules/co/index.js:65:19)
at /usr/local/lib/node_modules/run-rs/node_modules/co/index.js:54:5
at new Promise (<anonymous>)
at co (/usr/local/lib/node_modules/run-rs/node_modules/co/index.js:50:10)
at Object.<anonymous> (/usr/local/lib/node_modules/run-rs/index.js:30:1)
at Module._compile (internal/modules/cjs/loader.js:868:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:879:10)
at Module.load (internal/modules/cjs/loader.js:731:32)
at Function.Module._load (internal/modules/cjs/loader.js:644:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:931:10)
at internal/main/run_main_module.js:17:11

Please let us know how to resolve this. Thanks :)

vkarpov15 commented 5 years ago

Should be fixed by #38 in 0.5.4