Community
    • Login

    Is there any way to use Npp with WSL?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    11 Posts 4 Posters 3.4k 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.
    • Yaroslav NakonechnikovY
      Yaroslav Nakonechnikov
      last edited by

      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
      • EkopalypseE
        Ekopalypse
        last edited by

        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
        • Yaroslav NakonechnikovY
          Yaroslav Nakonechnikov
          last edited by

          thanks, but it doen’t work too (

          EkopalypseE 1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones
            last edited by

            @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
            • EkopalypseE
              Ekopalypse @Yaroslav Nakonechnikov
              last edited by

              @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
              • PeterJonesP
                PeterJones
                last edited by

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

                EkopalypseE 2 Replies Last reply Reply Quote 2
                • EkopalypseE
                  Ekopalypse @PeterJones
                  last edited by

                  @PeterJones
                  gimme a sec … :-)

                  1 Reply Last reply Reply Quote 1
                  • EkopalypseE
                    Ekopalypse @PeterJones
                    last edited by

                    @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
                    • EkopalypseE
                      Ekopalypse
                      last edited by

                      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
                      • PeterJonesP
                        PeterJones
                        last edited by

                        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
                        • Griffin O'NeillG
                          Griffin O'Neill
                          last edited by Griffin O'Neill

                          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