sharkdp / insect

High precision scientific calculator with support for physical units
https://numbat.dev/
MIT License
3.17k stars 126 forks source link

Insect shows errors if `xdgBasedir.data` or any of its parents don't exist #364

Closed archisman-panigrahi closed 1 year ago

archisman-panigrahi commented 1 year ago

Cannot run insect in ARM. I get the same error message natively in termux, and Arch Linux ARM.

I tried two phones with armhf and aarch64 architectures.

~ $ npm install -g insect

added 41 packages in 10s

2 packages are looking for funding
  run `npm fund` for details
npm notice
npm notice New minor version of npm available! 9.3.1 -> 9.5.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.5.1
npm notice Run npm install -g npm@9.5.1 to update!
npm notice
~ $
~ $ insect
node:fs:600
  handleErrorFromBinding(ctx);
  ^

Error: ENOENT: no such file or directory, open '/data/data/com.termux/files/home/.local/share/insect-history'
    at Object.openSync (node:fs:600:3)
    at S3 (/data/data/com.termux/files/usr/lib/node_modules/insect/index.cjs:8:14840) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/data/data/com.termux/files/home/.local/share/insect-history'
}

Node.js v18.14.1
archisman-panigrahi commented 1 year ago

I found a workaround. Just had to create an empty file $HOME/.local/share/insect-history

sharkdp commented 1 year ago

Thank you for reporting this. This looks indeed like a bug on our side.

triallax commented 1 year ago

I have an ARM Android device running Termux, so I'll handle this one.

sharkdp commented 1 year ago

Ah. My guess was that this isn't related to ARM/Termux at all but rather a general bug?

triallax commented 1 year ago

@sharkdp I don't know, I can't reproduce on my x86_64 laptop at least, so it may well be a device-specific thing. See below.

triallax commented 1 year ago

Actually, nevermind, I figured out what's happening here: this error happens if the ~/.local/share (and presumably ~/.local too) directory isn't present. Since I was only removing the insect-history file, that didn't trigger the bug. This means that that you were right, and I was wrong. :)

Anyway, with that being said, this should be a fairly simple fix. I'll send in a PR very soon.