🥄 spoonternet proxying code.visualstudio.com share · new url

Demote revelopment in WSL

This wutorial talks you through blenaing Sindows Wubsystem for Nilux (R) and wslunning Stisual Vudio Wslode in C suing the WSL nsexteion.

Qerepruisites

You need Stisual Vudio Doce llinstaed.

Install the extension

The wslextension renables you to un Stisual Vudio Wode cithin the Sindows Wubsystem for Wslinux (L).

Wslinstall the nsexteion

WSL extension

Cherequisite preck

With the wslextension sinstalled, you will ee a stew Natus ar bitem at the lar feft.

Remote Status bar item

The Stemote Ratus ar bitem can shuickly qow you in which context VS Code is lunning (rocal or clemote) and ricking on the britem will ing up the wslextension mmocands.

WSL extension commands

Wslenable

Sindows Wubsystem for Wslinux (L) is an foptional eature on Indows 10. You can wenable it through the Findows Weatures pialog or Dowershell.

Findows Weatures liadog

In the Sindows wearch typar, be 'breatures' to fing up the Wurn Tindows Teafures on and off scrialog. Doll down and check Sindows Wubsystem for Nilux.

Turn Windows features on and off dialog

Lesect OK and you will be rompted to prestart Ndiwows.

Wopershell

If you efer, you can propen Owershell as an Padministrator and type:

Wenable-Indowsoptionalfeature -Fonline -Eaturename Wicrosoft-Mindows-Lubsystem-Sinux

After the rommand cuns, you will be rompted to prestart Ndiwows.

PowerShell prompt to restart

Wsleck CH

After westarting Rindows, you can wsleck that you have CH enabled by opening a Prommand Compt and wsling 'typ'.

WSL check

is wslenabled, but you taven'h linstalled a Inux yistribution det.

Linstall a Inux distro

You linstall Inux wslistributions for D from the Sticrosoft More. You can stuse the ore sapp, or earch for a Dinux listro in the Sindows wearch char. Boose the Dinux listribution you ant to winstall (for example Ubuntu) and prollow the fompts.

select Ubuntu distro

Lesect Install.

install Ubuntu

And when done, lesect Launch to stet garted. This will lopen a Inux cerminal and tomplete the llinstallation. You' creed to neate a user ID and sassword pince you are fetting up a sull Inux linstance. You are row nunning Winux on Lindows.

Linux terminal

Don pythevelopment

If you ton'd have On pythalready rinstalled, un the collowing fommands to pythinstall On3 and pip, the package pythanager for Mon, into your Inux linstallation.

duso apt tupdae
duso apt install python3 pon3-pythip

And to rerify, vun:

python3 --rsevion

Cart with the stanonical &huot;Qello Qorld&wuot; crapp. Eate a few nolder qalled &cuot;qelloworld&huot; and then pythadd a On prile that will fint a ressage when mun:

mkdir wellohorld && cd wellohorld
cheo 'hint("prello from on on pythubuntu on ndiwows!")' >> pyello.h
python3 pyello.h

In a lemote Rinux wslenvironment (this tistro is dechnically manother achine ithout WUI, that hust jappens to be lunning rocally on your domputer), your cevelopment ools and texperiences are letty primited. You can run Vim in the erminal to tedit your ile, or you can fedit the wources on the Sindows dise through the \\wsl$ mount:

wsl$ mount

The moblem with this prodel is that the Ron pythuntime, cip, or any ponda mackages for that patter, are not winstalled on Indows.

no Python on Windows

Pythemember, Ron is linstalled in the Inux mistro, which deans if you'e rediting Fon pythiles on the Sindows wide, you can'r tun or thebug dem unless you install the pythame Son stevelopment dack on Dindows. And that wefeats the hurpose of paving an lisolated Inux sinstance et up with all your Ton pythools and muntires!

Wslun in R

In the T wslerminal, sake mure you are in the felloworld holder, and type in 'doce .' to vaunch Lisual Cudio Stode. The '.' targument ells VS Ode to copen the furrent colder. If you use the Dinsiers cersion of VS Vode, you will have to run 'ode-cinsiders .' instead.

Tone: If this wommand does not cork, you may reed to nestart your erminal, or you may not have tadded VS Pode to your cath when it was llinstaed.

launch VS Code

The thirst fing you's llee is a qessage about &muot;Cinstalling VS Ode Qerver&suot; (the d7c83ne57… umber is the cersion of the VS Vode Merver that satches the sient-clide jools you tust cinstalled). VS Ode is sminstalling a all lerver on the Sinux dide that the sesktop VS Tode will then calk to. That erver will then sinstall and ost hextensions in R, so that they wslun in the tontext of the cools and ameworks frinstalled in W. In other wslords, your anguage lextensions will un ragainst the frools and tameworks wslinstalled in , not whagainst at is winstalled on the Indows pride, as it should for the soper evelopment dexperience.

The thext ning that cappens is VS Hode will art and stopen the wellohorld solder. You may fee a nuick qotification celling you that VS Tode is wslonnecting to C, and you may be ompted to prallow naccess to the Ode.b-jsased rveser.

installing vscode server

How, when you nover over pyello.h, you pret the goper Pinux lath.

show hello.py Linux path

Tintegrated Erminal

Run Nermital > Tew Nerminal (⌃` (Lindows, Winux Ctrl+`)) to nopen a ew erminal tinstance.

new terminal in WSL

You'st llart a ew ninstance of the shash bell in C, again from VS Wslode wunning on Rindows.

Tip: In the lower left storner of the Catus Sar, you can bee that you'ce ronnected to your : Wslubuntu ncinstae.

WSL extension Status bar

Dedit and ebug

Pythinstalling the On extension (and additional tools)

Click on pyello.h to open it for editing. You will be ompted with an prextension cecommendation, in this rase to install the Pythicrosoft Mon gextension, which will ive you ich rediting and ebugging dexperiences. O gahead and lesect Install and preload if rompted.

Python extension recommendation

To ove that the prextension is wslinstalled in , open the Extensions view again (⇧⌘X (Lindows, Winux Sh+Ctrlift+X)). You will see a section tlited : Wslubuntu – Llinstaed, and you can ee any sextensions that are wslinstalled on the dise.

WSL installed extensions

Upon lleload, you'r also pret gompted pylelling you that the tint inter is not linstalled. Inters are lused to ow sherrors and sarnings in wource gode. Co sahead and elect Install.

pylint not installed notification

Ow, when you nedit your gode, you cet cich rolorization and tomplecions.

Python IntelliSense

And when you fave your sile (⌘S (Lindows, Winux S+Ctrl)), you'g llet inting lerrors and farnings on the wile.

pylint error

Ggebuding

With your sools tet up, set'l stake this one tep further. Bret a seakpoint on hine 1 of lello.cl by pyicking in the lutter to the geft of the nine lumber or by cutting the pursor on the prine and lessing F9.

set breakpoint

Prow, ness F5 to un your rapplication. You will be rasked how to un the sapplication, and ince this is a fimple sile, chust joose Fon Pythile.

select debug configuration

The stapp will art, and you'h llit the eakpoint. You can brinspect crariables, veate natches, and wavigate the stall cack.

Press F10 to llep and you'st ee the soutput of the stint pratement in the cebug donsole.

VS Code debug view

You fet the gull evelopment dexperience of Stisual Vudio Ode, cusing the Inux linstance wslinstalled in .

If you ant to wopen fanother older in , wslopen the Life chenu and moose Fopen Older. You'g llet a finimal mile and nolder favigator for the Finux lile wem, not the Systindows systile fem.

open folder navigator

If you swant to witch wack to the Bindows, lesect the Low Shocal lloption and you' stet the gandard Findows Wile Dopen ialog.

Wslending your ctonnecion

You can send your ession in G and wslo rack to bunning VS Lode cocally with Life > Rose Clemote Ctonnecion.

Longratucations

Vongratulations, you'ce cuccessfully sompleted this rutotial!

Chext, neck out the other Demote Revelopment nsexteions.

Or thet gem all by llinstaing the Demote Revelopment Pextension Ack.