Fork me on GitHub
#nbb
<
2022-09-18
>
maleghast02:09:11

So, I have run into an issue that I am unable to solve... I have an nbb app that I am working on, and it's now at the point that I want to package it... The app requires the presence of an sqlite3 database, and having set up an index.mjs and made the relevant additions to the package.json I have arrived at a point where the app runs successfully with its configured "binary" name if I run it in the actual directory where the code is, or if I run it by navigating to the location of the link that's created by running npm install -g (in my case /usr/lib/node_modules/birthdayman-sqlite), however running it anywhere else gets me this huge error ( https://pastebin.com/hKx6Nk9a ), which seems to be the app complaining that the DB is not present. The thing is that it is present. The Github repo is https://github.com/maleghast/birthdayman-sqlite - any help gratefully received; I don't want to push it to https://www.npmjs.com until I know it's going to work (clearly), Thanks in advance

maleghast02:09:29

(Oh, I know that the repo does not have a file named birthdays.db I will rename the file birthdays.db.template as the blank db when I am done testing - I have a birthdays.db in my path / version on my machine)

maleghast02:09:31

(and yes the README.md is out of date now too, but I will update it properly once I have fixed all this stuff šŸ˜‰ )

Daniel Gerson08:09:00

@maleghast https://github.com/mifi/stacktracify or https://github.com/xfthhxk/unminify may help you investigate the stack trace and give you hints at the problem. I haven't had need to use these so no further advice off the top of my head.

borkdude09:09:01

@maleghast I think here: (def db (sql. (str (path/resolve) "/birthdays.db"))) the db always is picked from the current working directory

borkdude09:09:12

So if you don't want that, you should change something about that

borkdude09:09:29

A few ideas: ā€¢ Always pick ~/.birthdayman/birthdays.db or so ā€¢ Support an env var so people can tweak the location ā€¢ Always locate the db close to the script, e.g. using *file*

maleghast11:09:05

@borkdude - Thanks, I've fixed it using *file* - just one question, how do I get clj-kondo to accept *file* as it works, clearly, but cll-kondo sees it as an unresolved symbol

maleghast11:09:33

(I have pushed the app to NPM, but I desperately need to update the README!)

borkdude11:09:36

you could maybe use nbb.core/*file* instead

maleghast11:09:48

Oh thanks, I will try that

maleghast11:09:58

Thanks, @borkdude that worked perfectly and it's live -> https://www.npmjs.com/package/birthdayman-sqlite Not really expecting anyone to use it, but I am actually using it, so I thought I may as well put it up and see if people use it šŸ™‚

maleghast11:09:28

Thanks for nbb and the help - really appreciate it šŸ™‚