Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps from nbb.edn are not in classpath when called by node from a bin script #297

Closed
cldwalker opened this issue Jan 2, 2023 · 9 comments

Comments

@cldwalker
Copy link

Hi @borkdude. Encountered this while doing something with nbb-logseq but this effect nbb users as well. Cheers


version

1.1.157

platform

osx 12.0.1 and node 16.13.1

problem
My problem is similar to #270 except I'm invoking node as a bin executable instead of in the current project directory. I encountered this while trying to turn this nbb-logseq script into an executable and following the directions from https://github.com/babashka/nbb/tree/b3e2418011e205559edad4677b6e26ddd66c74ea/doc/publish .

I don't have a great workaround for this except to hardcode .nbb/cache/X/nbb-deps directories in executables which seems brittle.

My initial use case is to globally install scripts. If this is fixed, I think it also enables nbb packages to be published with nbb.edn and to be consumed by node users who have bb, which would be pretty awesome.

repro

https://github.com/cldwalker/nbb-deps-repro - a modified version of #270

expected behavior

I expected to see the script load the nbb deps successfully

@borkdude
Copy link
Collaborator

borkdude commented Jan 2, 2023

Probably related to #281

@cldwalker
Copy link
Author

Ah, missed that. Thanks for the pointer

@borkdude
Copy link
Collaborator

I'm open to a PR around this and #281 or I'll probably look into this sometime in the next weeks.

@cldwalker
Copy link
Author

For this issue, local-nbb-edn is looking for nbb.edn in the wrong directory. One way I can solve this is by passing the executable's current directory to that fn through loadFile/loadString. In other words, the executable would pass the value of __dirname from this example to local-nbb-edn . Would you be open to a PR that provides such an option? I'm not sure if this overlaps with #281 as that seems to be a larger change with classpath which this use case doesn't necessarily need

@borkdude
Copy link
Collaborator

Yes but that might not be the only place that needs a little change.

Btw, another way to solve this problem is to make an "uberscript" which you can do with the bundle command:

https://github.com/babashka/nbb/tree/main/doc/bundle

@borkdude
Copy link
Collaborator

Should work in 1.2.166 (building on CI right now)

@borkdude
Copy link
Collaborator

Need to fix one more thing, the .nbb directory should be created relative to the nbb.edn I think

@cldwalker
Copy link
Author

Thanks! ❤️ 🕺 Simpler solution than I was thinking of and works great with nbb-logseq. Released a new nbb-logseq version for this

@borkdude
Copy link
Collaborator

Note that the newest nbb version is v1.2.169

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants