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

`nb browse` doesn't work on Windows #298

Closed voxelv closed 5 months ago

voxelv commented 5 months ago

Some debugging happened on #112. I opened this issue since that one was closed.

I'd really like to see if we can get it working on Windows, as nb has all the features I'd like (git-backed, markdown, quick notes from terminal, no proprietary web-sync subscription).

xwmx commented 5 months ago

ncat should work on Windows, so I'd recommend trying to determine what is causing the error. If you can install nc / netcat (there appear to be Window builds available), then that might work since there is now an implementation using netcat. You can test it with NB_BROWSE_SERVER_TOOL="netcat" nb browse -s and then see if it loads in the browser. There's also now a socat implementation that can be tested with NB_BROWSE_SERVER_TOOL="socat" nb browse -s if socat is available for Windows.

voxelv commented 5 months ago

socat is available through msys, and it works!

voxelv commented 5 months ago

I was also trying out fish shell, and was forgetting to use the -x option to set environment variables. I went back and checked with gnu-netcat and openbsd-netcat with proper environment variables and they still didn't work. I didn't bother checking nmap/ncat, since I knew I tested with correct environment variables at that time.

xwmx commented 5 months ago

Awesome. Good to hear. socat on my machine still is erroring when attempting to serve static files, like images and Ace editor JavaScript files. Everything else should work fine. I'll keep refining this.

voxelv commented 5 months ago

Neat! I just noticed that w3m is also showing just raw html when I nb browse (without -g). Also, it seems that nb browse -g doesn't work (while nb browse -s and navigating to the served address does work).

Edit: In the case of nb browse -g, this is the output:

> nb b -g
Listening: http://localhost:6789

Then it immediately stops with error code 1. firefox (my setting for NB_GUI_BROWSER) doesn't open.

xwmx commented 5 months ago

I just pushed a commit that seems to resolve the raw HTML issue and also enables serving static files and images. If you can, please try and let me know if that works.

The GUI browser is opened using a helper that calls wslview from wslu. Does this require a different, non-WSL way to open the browser? Do any of the options in the following link work? https://stackoverflow.com/questions/3739327/launching-a-website-via-windows-commandline

voxelv commented 5 months ago

nb browse works in w3m now! Thanks!

I'm not using WSL, I'm guessing that's why nb browse -g isn't working.

explorer "https://google.com" does work, but returns error code 1. rundll32 url.dll,FileProtocolHandler https://www.google.com also works without an error code. I'm guessing that these two go through the Windows Default Programs and might ignore NB_GUI_BROWSER.

start firefox "https://www.google.com/" works correctly, and would seem to be compatible with using NB_GUI_BROWSER!

xwmx commented 5 months ago

Awesome. I've updated it to use start "${NB_GUI_BROWSER}" "${url}" when $NB_GUI_BROWSER is assigned, and rundll32 url.dll,FileProtocolHandler "${url}" otherwise. Please let me know if it works.

voxelv commented 5 months ago

nb b -g works great now!

xwmx commented 5 months ago

@voxelv Awesome. Thank you so much for all the help!