• Login
Community
  • Login

Is there any way to use Npp with WSL?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
11 Posts 4 Posters 3.5k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y
    Yaroslav Nakonechnikov
    last edited by Feb 19, 2019, 2:47 PM

    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 test.py 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”

    1 Reply Last reply Reply Quote 2
    • E
      Ekopalypse
      last edited by Feb 19, 2019, 4:23 PM

      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)"//\\//}"

      1 Reply Last reply Reply Quote 2
      • Y
        Yaroslav Nakonechnikov
        last edited by Feb 26, 2019, 8:40 AM

        thanks, but it doen’t work too (

        E 1 Reply Last reply Feb 26, 2019, 3:06 PM Reply Quote 0
        • P
          PeterJones
          last edited by Feb 26, 2019, 2:50 PM

          @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.

          1 Reply Last reply Reply Quote 2
          • E
            Ekopalypse @Yaroslav Nakonechnikov
            last edited by Feb 26, 2019, 3:06 PM

            @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)"`
            
            1 Reply Last reply Reply Quote 2
            • P
              PeterJones
              last edited by Feb 26, 2019, 5:39 PM

              @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?

              E 2 Replies Last reply Feb 26, 2019, 5:41 PM Reply Quote 2
              • E
                Ekopalypse @PeterJones
                last edited by Feb 26, 2019, 5:41 PM

                @PeterJones
                gimme a sec … :-)

                1 Reply Last reply Reply Quote 1
                • E
                  Ekopalypse @PeterJones
                  last edited by Feb 26, 2019, 5:48 PM

                  @PeterJones

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

                  1 Reply Last reply Reply Quote 1
                  • E
                    Ekopalypse
                    last edited by Feb 26, 2019, 5:51 PM

                    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.

                    1 Reply Last reply Reply Quote 1
                    • P
                      PeterJones
                      last edited by Feb 26, 2019, 6:14 PM

                      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).

                      1 Reply Last reply Reply Quote 3
                      • G
                        Griffin O'Neill
                        last edited by Griffin O'Neill Jun 15, 2019, 6:33 PM Jun 15, 2019, 6:32 PM

                        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).

                        1 Reply Last reply Reply Quote 2
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors