Skip to content

neuron open (xdg-open) does not work on WSL #301

Closed

Description

@jaysnoddy

Using neuron open in WSL1 (Windows Subsystem for Linux) creates an error.
Not a dealmaker for me: I have been avoiding the command and use imperfect kludges.
(For users with this problem, see at bottom of this issue for one such kludge.)
However, this may be frustrating for other potential neutron users on WSL.

Thank, for the great tool! Aside from this, neuron within WSL works great!.

--jay

The Problem

Using 'neuron open' in WSL will create error messages similar to following.

Start : This command cannot be run due to the error: The system cannot find the file specified.
At line:1 char:1
+ Start "/mnt/c/REALPATH/REMOVED/BY/ME/.neuron/output/index.html ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand "

Even though I was working in the bash shell of WSL, this error message is from Windows Powershell.
WSL bash seems to be passing execution to Windows Powershell.

I am using WSL1. (This is a Ubuntu distro, although I doubt this is relevant).

The error seems to be largely about passing a file path in the wrong format. (If unfamiliar, WSL uses Posix-style paths like /mnt/c/foobar to refer to windows paths like C:\foobar).

Towards a solution?

In doing some investigation to hack a solution, I wonder if the problem could be fixed near neuron/src/app/Neuron/CLI.hs line 67????
I suspect primary problem is xdg-open incorrectly passes off a posix-style WSL path to windows.

I lack the Haskell programming skills to be sure this is the problem or try to fix this, though.

Perhaps the logic should include checking if in windows subsystem for linux, then...

An imperfect current solution for WSL 1 users.

Try updating to the most recent release of WSL--perhaps this xdg-open issue is fixed there?
If not fixed, then, perhaps, use explorer.exe from WSL command line. This windows program can work if it does not have to worry about paths! To avoid paths, you may need to cd where neuron rib output is (i.e. if using defaults, ~/zettelkasten/.neuron/output).

To be more explicit...

   EITHER...
   cd ~/zettelkasten/.neuron/output # alter if using non-default directory
    explorer.exe . # (note period!)
    cd - # (to return to prior directory you were in)
    
    OR replace second line with...
    explorer.exe FILENAME 
    # (where FILENAME is index.html, search.html, etc)

The former will open the Windows explorer window and you can choose to open a file with its default program or
The latter will directly open the named file in a web browser, if an html mimetype.
You can recreate these commands in a script, of course. Though I actually just typed the following in once and then reverse-search (ctrl-r) for 'neuron open' when i need the line again.

cd ~/zettelkasten/.neuron/output &&  explorer.exe search.html &&  cd - # to replace 'neuron open'  

This opens the file in my default web browser and NOT in windows explorer!

Activity

  1. changed the title [-]Problem with neuron open on WSL (Windows Subsystem for Linux)[/-] [+]neuron open (xdg-open) does not work on WSL[/+] on Jul 22, 2020
  2. jaysnoddy commented on Jul 26, 2020

    @jaysnoddy
    Author

    I forgot to add that I am using WSL 1. This might be relevant! I have edited this issue to reflect this.

    xdg-open might be fixed or to be fixed soon in WSL2. If some Windows users do not have issue, this might explain it.

    I updated with your latest , and still have this problem.
    (via nix-env -if https://github.com/srid/neuron/archive/master.tar.gz)

    (Given general update problems Microsoft is having, I--and others--have been holding off updating. sorry, I forgot I was not up-to-date with WSL. I will probably update WSL soon.)

  3. srid commented on Jul 26, 2020

    @srid
    Owner

    I lack the Haskell programming skills to be sure this is the problem or try to fix this, though.

    FWIW, I have been using WSL 2 after switching to Windows yesterday. It is much faster than WSL (which I tried last some time ago). If you are interested in tweaking neuron (around CLI.hs where it invokes xdg-open), you could use the bin/run script on WSL 2's Ubuntu shell while making the code changes (in VS code); the script should give you live feedback on your changes. Then you just run nix-build which will produce the new neuron under ./result/bin for testing.

    But then, I suppose making xdg-open work seemlessly on WSL is probably the right approach. Then you don't need to change neuron at all.

  4. jaysnoddy commented on Jul 27, 2020

    @jaysnoddy
    Author
  5. srid commented on Jul 27, 2020

    @srid
    Owner

    @jaysnoddy We have a project chat area on both Zulip and Matrix; see links in README.

  6. jaysnoddy commented on Jul 28, 2020

    @jaysnoddy
    Author
  7. srid commented on Jul 28, 2020

    @srid
    Owner

    Interesting; do let us know if you get to mention neuron in your textbook!

    About the chat tags, that's a good observation-- I'll fix that.

  8. added a commit that references this issue on Jul 28, 2020
  9. Repository owner locked and limited conversation to collaborators on Aug 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions