windows10 vscode - netdisco/netdisco GitHub Wiki

⚠️
still very much work in progress!
⚠️
still very much work in progress!
⚠️
still very much work in progress!
⚠️
still very much work in progress!
⚠️
still very much work in progress!
⚠️
still very much work in progress!

windows 10, vs code and wsl2

the goal of this document is NOT to make netdisco work under windows!

it is however a starting point for those wanting to develop under windows.

things that work

  • git and github support

  • perl syntax checking

  • template toolkit syntax checking

  • sql (postgresql specific) syntax checking

  • building

    • Build.PL

    • Build

    • Build install

    • Build distclean

    • Build distcheck

    • Build makemeta

    • Build manifest

    • Build test

  • code analysis

  • local::lib

things that don’t work

  • building

    • Build test (for some modules)

  • everything that uses #/usr/bin/env perl

  • some mro based modules

  • perl critic support (should work, most likely local config)

  • the perl module does not yet support all perl syntax variations, in particular it will think dancer exported functions are not defined.

Introduction

Netdisco is not supported on windows. Using wsl2 however we have a linux environment at our disposal on windows, and with vs code we can run our ide on windows but the actual compilation and binaries on linux.

wsl2 will be needed with a distro of your choice.

for now the rancid plugin is a simple project to experiment with (also has working tests) https://github.com/netdisco/nd2-web-plugin-rancid/

Requirements

  • windows 10 x64 version 20h2 or later

  • wsl2 and a linux distribition from the ms store

  • visual studio code 1.54 or higher

wsl2

wsl2 install

first you need to enable wsl2 on your system, a detailed guide from microsoft can be found here.

short overview (run in powershell as adminstrator):

  • enable wsl feature

    • dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

  • enable virtual machine feature

    • dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

  • reboot windows

  • update linux kernel

  • set wsl to version 2

    • wsl --set-default-version 2

  • install a linux distro via ms store

    • debian or opensuse leap recommended

depending on the distro you have chosen, follow the install guide for that distro to set up the required packages.

for debian these packages will be needed in perl localenv: cpanm --local-lib ~/perl5 AnyEvent::AIO

netdisco install under wsl

install netdisco and it’s dependencies on the system, under your own user.

mkdir ~/bin
curl -L https://cpanmin.us/ | perl - --notest --local-lib ~/perl5 App::Netdisco
ln -s ~/perl5/bin/{localenv,netdisco-*} ~/bin/

vs code

installation

this is just running through the setup tools.

required extensions

TODO FROM HERE

setting up perl support

in the intellij settings menu, go to:

  • languages & frameworks

    • perl5

add a new perl5 interpreter as system perl. select c:\cygwin64\bin\perl.exe.

this should show up as "Local, System: Perl 5.26.3 for x86_64-cygwin-threads-multi".

then add the following external libraries:

  • C:\cygwin64\home_yourusername_\perl5\

  • C:\cygwin64\lib\perl5\

  • C:\cygwin64\usr\share\perl5

TODO TILL HERE

setting up tasks

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "distclean",
            "type": "shell",
            "command": "./Build",
            "args": ["distclean"],
            "options": {
                "cwd": "${workspaceFolder}",
                "env": {
                    "PERL_MM_OPT": "INSTALL_BASE=/home/user2448/perl5",
                    "PERL_LOCAL_LIB_ROOT": "/home/user2448/perl5",
                    "PERL5LIB": "/home/user2448/perl5/lib/perl5",
                    "PERL_MB_OPT": "--install_base \"/home/user2448/perl5\""
                }
            }
        },{
            "label": "build.pl",
            "type": "shell",
            "command": "perl",
            "args": ["Build.PL"],
            "options": {
                "cwd": "${workspaceFolder}",
                "env": {
                    "PERL_MM_OPT": "INSTALL_BASE=/home/user2448/perl5",
                    "PERL_LOCAL_LIB_ROOT": "/home/user2448/perl5",
                    "PERL5LIB": "/home/user2448/perl5/lib/perl5",
                    "PERL_MB_OPT": "--install_base \"/home/user2448/perl5\""
                }
            }
        },{
            "label": "build",
            "type": "shell",
            "command": "./Build",
            "options": {
                "cwd": "${workspaceFolder}",
                "env": {
                    "PERL_MM_OPT": "INSTALL_BASE=/home/user2448/perl5",
                    "PERL_LOCAL_LIB_ROOT": "/home/user2448/perl5",
                    "PERL5LIB": "/home/user2448/perl5/lib/perl5",
                    "PERL_MB_OPT": "--install_base \"/home/user2448/perl5\""
                }
            }
        },{
            "label": "test",
            "type": "shell",
            "command": "./Build",
            "args": ["test", "--test_files", "t/", "--test_files", "xt/"],
            "options": {
                "cwd": "${workspaceFolder}",
                "env": {
                    "PERL_MM_OPT": "INSTALL_BASE=/home/user2448/perl5",
                    "PERL_LOCAL_LIB_ROOT": "/home/user2448/perl5",
                    "PERL5LIB": "/home/user2448/perl5/lib/perl5",
                    "PERL_MB_OPT": "--install_base \"/home/user2448/perl5\""
                }
            }
        }
    ]
}
⚠️ **GitHub.com Fallback** ⚠️