VSCode Development Using Remote - WSL

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
a couple weeks ago i blogged about some experiments that i had done installing wsl2 or the windows subsystem for linux on my local development machine and that initial blog post uh which i referenced here and i'll put a link to in the notes um well basically i wanted to document you know the setup process a little bit about wsl2 although there wasn't a whole lot to to getting it set up a little bit about the advantages of it you know the fact that the file system is uh is available here even from the rest of windows so for instance here i can go into my distr linux distribution i can see the file system right here in windows and get really nice interaction but the initial blog post that i did was really focused on uh getting on express set up and installed into wsl2 which worked really well and i've been using it ever since i've updated and actually done a couple installs of hana express into this environment and that's the way i've been using hana express lately but today i wanted to experiment with something a little bit different i've been reading about using the windows subsystem for linux to do local development in vs code and the idea is uh you know today when i when i do say vs code development i do cloud application programming model or fiori development i need all of my additional tools set up in my main windows system so for instance i'm here and i'll just show you um i've just got a command window here open to um to my local environment and this is my uh this is my machine this is my native host os you know microsoft windows 10 enterprise edition and if i were to do development in vs code by default it would run in this environment so that means i need things like just clarisse um i need to have node.js installed locally uh in my windows host installation so i've got you know version 12 patch 19 of node.js installed here and windows and it does mean if i need to do development i want to say experiment with a different version of node.js test something out i have to maybe disrupt everything that i'm doing here in my windows development environment to install a different version of node.js or like i have let's see is it cbs yeah cds-feed so i have uh the cloud application programming model the additional tools installed in my environment and that's installed via node.js package but it's installed in the node.js that's running here in windows and likewise if i want to experiment maybe with a with a different version of node.js yeah i could uninstall globally and install a different version globally but the whole point is i sort of have just one uh one development environment that's impacting also the runtime of my main operating system as well this is this is where i execute things for real right and maybe it would be nicer if i could isolate my development into a separate container but without the overhead of needing a remote container i could use wsl to containerize a little linux distribution and allow me to do my development on my local machine still using vs code running locally and attaching to my my local windows file system and being able to easily get content in and out of there but do that in that containerized environment the other advantage that i'm going to have with setting this up if everything works out okay here is when i execute code in vs code instead of running in the windows operating system it will actually be running in the linux operating system and this gives me a better test and debug environment that's going to match more closely to when i deploy my code to say the cloud platform to to cloud foundry or the kema runtime which of course is going to be running the code containerized in a in a linux kernel there as well just gives me a much better match to the target environment that i'm ultimately going to be deploying it so i want to i want to set up i already have wsl set up and you can refer to the earlier blog if you want to see some details about that some links to resources to help you get it set up in your environment and particularly wsl2 the latest version of windows subsystem for linux because there are some significant performance improvements that we see with that latest version what i want to do now is i want to look into creating a copy of my linux distribution uh so i can set up a a a separate container separate image just for doing cloud application programming model development on my local environment so let's actually start here by looking at what linux environments i have already installed so if i just come to my command prompt here let's just clear that up and let's do uh wsl list verbose and what you see here is i've got one default linux um runtime here uh running open susie leap 15.2 that's actually where my hana express is installed i'm not going to mess around with that i actually want to use a really lean uh pretty bare bones ubuntu installation that's what i want to use as the baseline for my for my development containers uh you see here i also have docker set up and it's using wsl2 as well i'll come back to that later because because i think we're also going to get a really nice feature here where because docker is running in wsl2 we can actually share our central docker installation across all our linux distributions and we don't have to duplicate images or or do any special setup to get access to a single docker uh instance from inside the uh the specific linux distributions that are running here uh but let's first let's uh take a look at this ubuntu um and i'm using uh windows terminal here and i can just directly open a shell to that uh ubuntu image so let's just go to my home directory here there we are um so here i am looking at uh my ubuntu let's just do a cat uh what is this etsy os release and there you see i'm running ubuntu version 20. so give you some idea of what i'm running over here i don't think i've got just a whole lot of stuff installed um in fact here i am in my uh in my main directory although there's a few things i think i did install node.js yeah basic version of version 12 of nodejs node.js i know 14 is out in long-term support but kind of waiting till more of the sap modules have been updated and verified that they work on version 14 before i switch my development platform to that so i'm going to stick with 12 for now which is still in support um but in the future i might want to switch over to to 14 and be able to do it in an isolated environment this is going to help me with that so i've got the i've got the basic tools here i think get is installed by default so i've got most of what i need here maybe just i'm here in my home directory just maybe create a projects directory where i could start doing development in yeah it's empty right now uh but uh but good to go here in the future um maybe already i'll just show you docker ps so docker i just did a listing of docker containers that are available and running and you see i'm running portainer here on port 8000 that's actually not running in this version of ubuntu if i launch my this is my other window give me just a second here to bring it over look at my docker installation i have docker desktop installed this portainer is actually here in the main uh in my main instance of docker because i think if i come over here docker ps yeah i see the same retainer installed and available here and that's not because i've got docker a docker server running in both linux and windows i actually have a single docker image here and it is set up if we look at the general settings of the docker image it's using wsl2 and that was some of the you see the docker desktop docker desktop data one of the really cool things that we can do here is wsl integration and it will automatically enable integration into your your distributions and to add that i just you know clicked it on for the ubuntu distribution and that gave that distribution automatic access to my my central docker so if i'm using docker for development in one of these localized wsl2 distributions i don't need to duplicate images or my docker setup or resources allocated to docker it's actually going to be connecting to the central docker here that my windows development environment would also be connecting to so it's really nice you know if i if i build an image locally and i have it available in my in my local docker desktop then then i can access it without making a copy of it from from the windows side as well so very resource um efficient way of sharing docker here between my between my distributions um so i've got the i you know i've got this ubuntu distribution the way i want it as a baseline here um and i could just start doing development in it but what i want to do is i actually want to take a snapshot of of it so i always have like a clean version of ubuntu that i can go back to but i want to i want to create a version of it i'm going to create a copy of it if you will specifically for doing cloud application programming model development and something that i could maybe throw away update independently you know things like that so what i want to do is here is i want to start with uh wsl uh actually i want to see what yeah um go back up in directory here um so i want to say wsl and i want to sorry i got all the commands over here in my other window to make sure i don't mess them up uh not things that i run every day but so wsl and then say export and i want to export my unto and and i can give it a file name so let's just uh call it ubuntu as well and this will take a minute to export so i'll actually pause the video while this runs and we'll come back here in just a minute once it finishes that's complete now what did that take uh took four minutes that's not too bad and what we should see now if i go to my file system as i got a file named ubuntu and i guess i should probably have put should have named that ubuntu.zip let's just go ahead and add a change the file extension there um three gigs that sounds about right for a complete linux distribution with its whole file system and a little bit of additional content that i had had installed there i think we can even open this up and take a second to open um yeah there's our there's our linux uh there's a linux file system so we've got a complete export of our image and now what we can do is we can go ahead and re-import this and give it a new unique name so we can say wsl and dash dash import and we want to give it a name boon to cap we're doing cloud application programming model development and our installation location let's just say um i probably should have made a directory here first i wasn't thinking ahead there was i so let's just go to directory boom to cap all right so now we can go back over here and we can say we want to install that into my ubuntu cap directory and where do we want to get the file name from uh that's our ubuntu zip so we will go ahead and start the import and once again i assume this is probably going to take about the same amount of time that it took to do the export a couple minutes so go ahead and stop the video and we'll start back up once it's complete all right that import was pretty fast it only took about a minute and we can verify now if i just do a wsl list verbose now i see i also have an ubuntu dash cap has this completely separate uh linux distribution image uh separate running it's not this is not running at the moment but we can go ahead and do a wsl dash d ubuntu cap to shell into it there we are now we're running inside that that distribution we can even come back over here to prove to you that it is running now yep it is running now so there we have um we see a little bit of the log on information about it but we're now running inside here if i were to do a let's just go to my home directory and uh there we have our initial look here yeah where am i at um i'm in root oh i must be logged in as root uh and not as my user i'm used to usually just opening a new shell here so let's actually let's just go ahead and add that as a configuration option here to my windows terminal so let's find ubuntu and oh there it is it was already added yeah okay there it is now i'm logged on as my user which is what i want there we are and still root there we are there's our projects it's very interesting that i got logged on here as as root i did not i did not expect that because if i go into my original ubuntu and i do a who am i and i'm logged on as my windows user um but when i'm logged in now in this copy i'm logged on as root i did not i did not really expect that to uh to work differently but perhaps one uh when i imported the distribution um there's uh something different about the way that works i'm interested now just help uh import let's see if there's a options version i don't see any additional options there i mean it's not the end of the world it just uh is acting a little differently than what i expected that's okay um so it's half the fun of playing around with something like this is figuring out that something's a little different than what you expected so let me go ahead here and go to home there we are we're in projects now uh i think if i do yeah so my node.js version came over uh git it came over as well i'm interested i i don't even remember if i installed the the cds command yeah evidently i did cds v so it came over as well but let's maybe check real quick here and see if there's an update npn install globally sap cds okay let's see if it needs an update well isn't that nice i got an access permission denied okay i have to admit i'm not exactly sure what problem i hit there perhaps because the node module had been installed before i exported it and then maybe the permissions are slightly different on the imported distribution all i know is i did that uninstall uh right at the end of the video before i paused it uh then i did a reinstall now npn install globally sap cd sdk and now everything's working fine if i do my cvs-v actually did get updated that was just one minor level update 4.2.8 but at least now i know my permissions are set up right and i shouldn't have problems moving forward hopefully like i said you're kind of watching me experiment here this is the first time i'm running through this i didn't practice it in advance or anything so yeah so running into stuff we're learning about it together but i i seem to have the cloud application programming model not only installed and working in my in my local environment but in in this separate uh linux distribution image but now i also um i've been able to update it now one other thing that i want to check if you remember earlier my docker i want to make sure that my docker is going to be available to this new copy of ubuntu and let's just check real quick here if i go into wsl integration yeah we're going to turn that on but to get that forced in and have to restart it because i do want to make sure that i have docker available in this environment as well and i don't know if that's enough to get it or let's just or if it has to restart user there we are and yeah so here i am in my new distribution and yes i can i can see i can get access to docker so what we want to do here i'm in yeah i'm in my home and if i go to projects this is where i want to do development so nothing in projects but what i can do is i can just do a code dot and this will work today do that right um yeah that should have worked it should have launched my vs code and okay i had to do a little searching for the solution here evidently when you install a new distribution like this um the path doesn't get injected right away so what you have to do is basically close your terminal window and open a fresh one so i'm going to go ahead and do that now let's go ahead into my ubuntu cap and i'm going to do a switch user to my user go into my projects folder and now fingers crossed when i do code no uh and i think this still has to do with how whatever's going on here with the with the different default user because actually if i go back to my main user here and i go to oh i misspelled it and now if i do code yeah now it works so something something isn't right with compared to my original distribution where it was set up to use my logon user directly and now when i made that copy and the defaulting to root something isn't quite right there it's not setting the path or the profile for my other user um something for me to maybe play around with later but for my purposes of what i want to do in this uh in this separate separate container i guess it doesn't really hurt for me to be logged on by default in root you know i was trying to go back to the way it had been before but like i said something for me to maybe look into but what you see here is my projects no longer looking at a local file system but my vs code is is running here this is still my version of vs code that's running on my windows machine but it's connected remotely into my ubuntu image and in fact if i open a terminal what you see here is once again if i do cat etsy os release i'm connected to ubuntu and you know if i do a run or debug i don't have a project yet but if i have a run or a debug it's going to be running in the um in the windows subsystem for linux um if we see here we also have uh we still have access to docker but we have the central docker um like like we saw before we can see that we're targeting and currently editing on windows subsystem for linux ubuntu cap we have the ability to switch to other distributions or or bounce between distributions here as well i think we can even do a remote explorer and it shows us our various wsl targets and we see which one that we are connected to now um yeah it's interesting the the differences in configuration there it's definitely something i've gotta gotta play around with but but you see how how nice it is uh that that we're connected in here the other thing is um my extensions it didn't automatically load all my extensions see no extensions found i can see the extensions that are available in my in my base installation and this is one of the things that i like is i could take just a subset of those uh extensions maybe i'll search here for um it's not cap let's just do sap and what you'll see here here's our core data services language support for sap cloud platform core data services cloud application programming model and you'll see that it says install extension to enable so it's installed in my main in my main version of vs code but now i can install it into my um this version so it allows me to have you know separate out and and have different sets of extensions that are installed per remote container as well so now if i just come back here let's clear this out and we see inside here the only one that i have installed is the core data services plugin for visual studio code i might want to install a couple others but maybe not everything that i have in my main installation maybe gives me a lighter weight experience here or the ability to play around with uh you know different sets of extensions uh you know maybe i also want the rest client installed in my in this local environment as well so let's you know and now i would have the ability here my projects um let's just do cvs init and you know now i could be off and doing development here in this environment [Music] and uh like i said i'd be be executing it in my windows subsystem for linux in a little isolated container all right and just to close out i thought how can i really prove that i'm executing and debugging in linux here so i just wrote a little node.js script using the os module that's going to go and grab os level information like the platform the architecture and the release and it will output that set that up as the start script in my little project here and then um just told it that uh set up a a run command here to uh to execute that and just once again my vs code is running in windows so i haven't installed haven't really installed vs code or not running it somehow from linux vs code is running in my host os which is windows but when i come here and i kick off a my run script which attaches to and runs code it is running in my linux container and we'll see the output here that we're getting the platform is linux the type is linux in the debugger you're seeing this if i continue then output the os and same here that is running in linux you even see the release here is actually the the kernel the linux kernel is a microsoft linux kernel microsoft provided linux kernel then the distribution runs uh the ubuntu distribution runs on top of that that kernel so isolated development control over the development environment didn't go perfectly with me making the copy of my distribution and and setting that up i have to do a little more research on why the default username changed and i had a little permission problems there but uh but ultimately i wasn't able to set up an isolated development environment in a copy of my linux distribution can connect from vs code running in my uh on my host os to that distribution and do development remotely there uh and install my node.js and my node my node modules like the cloud application programming model and even vs code extensions locally in the container and not in my host os to keep my configuration all very clean and and the setup very very separate and and very isolated so i hope you enjoyed this little video it wasn't meant to be an extensive look at at something um kind of like i said following along as i experiment i hit some roadblocks and we work through them together uh i think that's uh i think that's kind of fun um hopefully uh you enjoyed the video as well and we'll have more of this sort of thing in the future you
Info
Channel: SAP Developers
Views: 1,662
Rating: undefined out of 5
Keywords: SAP, VSCode, WSL, Windows Subsystem for Linux, Containers, Docker, Linux, CAP, Cloud Application Programming Model
Id: tzrHsa2ketc
Channel Id: undefined
Length: 33min 42sec (2022 seconds)
Published: Tue Nov 10 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.