Is there any way to use Npp with WSL?

  • Hello,

    i know, it is possible)

    but question is for FULL_CURRENT_PATH env var.
    for example, i want to use python3, which is installed on WSL… and command wsl python3 works fine.
    but if i open Notepad++ and trying to run it with wsl python3 "$(FULL_CURRENT_PATH)" it fails, cause there is no file:
    python3: can't open file 'c:Usersusernamedir1': [Errno 2] No such file or directory

    and question: is it possible to forward correct path?
    in example it should be “c:/Users/username/dir\ 1”

  • I don’t have Win10 so can’t really test but what if you try to replace within wsl - don’t know if
    this is possible at all. Something like wsl python3 "${"$(FULL_CURRENT_PATH)"//\\//}"

  • thanks, but it doen’t work too (

  • @Yaroslav-Nakonechnikov ,

    I haven’t used WSL yet, so I’m not an expert. However, linux uses different path styles compared to Windows, so passing a Windows path thru wsl.exe to python3 will probably not be valid from the linux perspective.

    I just found this MS doc which gives an example of /mnt/c/Users/sarah as the equivalent path to C:\Users\sarah. I don’t think there’s an easy way to transform $(FULL_CURRENT_PATH) into that /mnt/c/... notation. However, those same MS Docs imply that when you run wsl.exe, it will be in the same current-directory you ran it from. Thus, maybe doing cd /d "$(CURRENT_DIRECTORY)" && wsl python3 "$(FILE_NAME)" will accomplish what you desire.

  • @Yaroslav-Nakonechnikov

    I’ve installed win10 in virtual box and did some test and to my surprise I found a tool called wslpath which does what you want.
    this test worked for me

    cmd /k wsl python3 `wslpath -u "$(FULL_CURRENT_PATH)"`

  • @Ekopalypse ,

    I just installed WSL with the ubuntu 18.04 on Windows 10 Enterprise, 1709 (Fall Creators Update), build 16299. I couldn’t find that wslpath in my ubuntu path. What version/build of Win10 did you virtualize? Which linux did you install? Where in linux was the wslpath command?

  • @PeterJones
    gimme a sec … :-)

  • @PeterJones

    Windows 1803 - OS Build 17314.376
    Ubuntu shell from windows store -> Version 1804.2018.817.0

  • it is called
    Ubuntu on Windows allows one to use Ubuntu Terminal and run Ubuntu command line utilities including
    bash, ssh, git, apt and many more
    so it is not a fully fledged OS I guess.

  • Bummer. Apparently, they added /bin/wslpath in Windows 1803, because the ubuntu 18.04 install from Windows 1709 does not have that utility.

    Yeah, according to WSL release notes, wslpath was added in Build 17046, which is available for 1803. (The latest build for 1709 is 16299).

  • I recently made a script to aid the use of Npp within WSL with the help of wslpath. I was trying to make an easy way to edit files in the WSL filesystem without breaking the rule that Linux files must not be directly edited by Windows software. It seems to work as far as my initial tests go. Take a look here, and feel free to modify it for your own use. (Let me know if you find any better ways to do this).

Log in to reply