Skip to content

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

@jaysnoddy

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!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions