xwmx / nb

CLI and local web plain text note‑taking, bookmarking, and archiving with linking, tagging, filtering, search, Git versioning & syncing, Pandoc conversion, + more, in a single portable script.
https://xwmx.github.io/nb
GNU Affero General Public License v3.0
6.43k stars 180 forks source link

headless browse server #301

Closed OldDragon2A closed 4 months ago

OldDragon2A commented 5 months ago

Was planning to use port forwarding to get at the local site but I can't find an option to start a headless server. nb browse and nb browse --serve both give an Error: no DISPLAY environment variable specified. Am I missing something?

xwmx commented 5 months ago

nb doesn't appear to reference $DISPLAY directly. It seems like $DISPLAY is generally used by something accessing the GUI, but nb browse --serve shouldn't use the GUI, so I don't know what's triggering it. You can try setting it to a standard value like DISPLAY=:0 (more info: [1], [2]).

In case it helps, there's also an undocumented nb browse --daemon option, which is like --serve, but requires <CTRL-C> to exit.

OldDragon2A commented 5 months ago

Weird, I thought it might have been trying to open the browser automatically and that was what was causing it. Tried it with daemon and get the same result.

$ nb browse --daemon
Listening: http://localhost:6789
Error: no DISPLAY environment variable specified

I tried setting DISPLAY but that just changes it to an error about the display. Error: cannot open display: :0

Not sure what could be causing it to try if that isn't part of the program. Tried it with bash --noprofile --norc in case of a conflict but that didn't change anything. As far as I can tell, all of the other commands still work as expected.

xwmx commented 4 months ago

What's the OS? I just tried in Ubuntu and Arch virtual machines with blank $DISPLAY values and wasn't able to reproduce the error.

OldDragon2A commented 4 months ago

It is running Arch Linux.

Tried it with X and it does open up the browser when I run nb browse or nb browse --serve. Must be something on my system but I'm drawing a blank on what it could be. Slowly looking through a strace now to see if anything jumps out at me.

OldDragon2A commented 4 months ago

Found the main problem. I have BROWSER set and it will always open the browser if that is set. It works normally if I clear that before hand.

xwmx commented 4 months ago

Awesome. Thanks for the info! This should be fixed in the latest version in the repo.

OldDragon2A commented 4 months ago

Grabbed a copy and it looks good. Thank you for the quick turn around!