sastraxi/pgsh

metrics crashes pgsh

nafg opened this issue · 2 comments

nafg commented

I installed/updated pgsh by running sudo -H npm install -g pgsh. Now every command fails with

internal/fs/utils.js:461
    throw err;
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be one of type string, Buffer, or URL. Received type object
    at Object.openSync (fs.js:440:3)
    at Object.readFileSync (fs.js:348:35)
    at Object.<anonymous> (/usr/lib/node_modules/pgsh/src/metrics/record.js:6:6)
    at Module._compile (internal/modules/cjs/loader.js:816:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Module.require (internal/modules/cjs/loader.js:723:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at Object.<anonymous> (/usr/lib/node_modules/pgsh/src/end-program.js:10:44)

I did some sleuthing... I adding some logging to record.js and it seems require('find-config')('package.json') returns null.

nafg commented

https://www.npmjs.com/package/find-config says

Finds the first matching config file, if any, in the current directory, nearest ancestor, or user's home directory. Supports finding files within a subdirectory of an ancestor directory.

None of that suggests that if I'm in an arbitrary working directory, running /usr/bin/pgsh which is symlinked to /usr/lib/node_modules/pgsh/src/index.js, that it will help find /usr/lib/node_modules/pgsh/package.json

@nafg Thanks for the bug report! Fixed now and about to cut a new release.

At some point #70 will be adding a non-node-based project to the integration test suite, so hopefully less of these sorts of issues :)