loading...

Protecting the Environment ... by starting from scratch

mariel profile image mariel ・8 min read

I just started a new job (woohoo, first job as a real-live junior dev) and with every new job comes ... getting your environment squared away. Everyone does things a little differently and the way your machine is set up might not work at your new place. This is probably even more of an issue now that we're all at home and can't rely on walking into the office and our standardized equipment. I'm getting a new Apple machine sent to me from work(!) but it's going to take [redacted] time to get here, so in the meantime, I'm using my own Microsoft machine.

I use a Surface Book 2 that I got in 2017 - I had gotten a good bonus, needed a new laptop, and wanted something powerful that I wouldn't need to replace in 2 years. Once I saw the display separate from the base and become a 15" tablet:

I'm working with 16GB of RAM and an i7, so I generally don't have any issues. And, WSL exists! I started using WSL in 2018 when I set up my initial environment for my work at Flatiron. I used these instructions to get the setup done. You should have SEEN the stress of me trying to figure this out and the PATIENCE exercised by my boyfriend (a career/traditional SWE) when he had to help me start over because I'd messed something up and I was sobbing. Being a n00b was good times.

EVENTUALLY, after much gnashing of teeth and...carefully following the instructions, things were set up properly and I was good to go. I was able to use my Windows machine, run Ubuntu in the command line, and otherwise live the dream. Over the next 2 years, I added things little by little so I had exactly what I wanted where I wanted it. Yarn? Npm? Nvm? Rvm? Rails? etc etc etc - all the things a new full stack dev would use. During my internship earlier this year, I spent most of my time working with Highcharts.js which required nothing but a CDN and a js file. No install/finagling to be done there.

....And then I started work this week and had to install Docker.

How things went all the way sideways

Getting Docker installed for Windows was fine (initially). Easy, fast, install, short tutorial built-in. And THEN...I tried to use it in the command line to get one of our projects going. See supra, fail whale.

It got upset that I was running WSL1 instead of WSL2, which was interesting because I didn't know there is a WSL2.

So I thought okay, no big deal I guess I'll just google WSL2 and find an install? One does not simply upgrade WSL and Ubuntu. Because - plot twist - Ubuntu also has a new version to run with the new WSL. I think I figured this out because WSL2 didn't want to set my original Ubuntu install as default but it's all kind of hazy right now. Also hazy: trying to upgrade Ubuntu from the command line. It took forever and at some point I may or may not have ended up like this:

I moseyed on over to the Microsoft store because the instructions said to BUT LO AND BEHOLD:

WHY ARE THERE THREE, I asked myself. Keep in mind this is during the day when I'm trying to just get something working so I can keep moving forward at work with getting set up, etc. etc.

I figured okay, well, I guess I'll install 20.04 in addition to my existing install? I looked at this blog post, which was incredibly helpful, except...I kept getting stuck on wsl.exe --set-version Ubuntu 2. PowerShell got mad, I got sad, and it was generally a mess. So I uninstalled my original Ubuntu install and thought that would help, but LOL NO. Then I reinstalled it, and was able to set it as default in PowerShell and just be done. I went back to VSCode, kept running Docker, it cooperated, and I was DONE. DONE DONE.

I thought.

The Docker build took literal hours. Setting up my SSH key for working with our repos was way more difficult than it should have been. Every single thing I did was annoying.

AND THE WORST PART: MY TERMINAL WAS COMPLETELY DIFFERENT.

Somewhere between the installs and uninstalls I'd fubar'd my terminal and the configs I had were gone and it was just incredibly disorienting. But I didn't have time to mess with it and was half convinced I was just stuck with it. My original settings cleanly told me (1) where I was in my files and (2) where I was in git. I vented to my boyfriend and he said, "I always know where I am. Because I just type 'pwd'."

Somehow my manager and I were able to get through what we were trying to do - clone down the repo, make some changes, make a commit, push it back up.

But it BOTHERED ME that things weren't working well, and I KNEW there was something wrong. Soooo later in the evening, I decided to start over...and get my boyfriend to help me. Not only is he a command line wizard who is very kind and patient with all of my questions and good at explaining things to me - he's a big fan of carefully reading instructions.

Getting back on track

Uninstall before you fall...apart.

Step 1 in undoing whatever-the-h*ck I did was just uninstall everything. We looked at my files and realized ... Ubuntu 20.04 was a lot smaller than Ubuntu, and Boyfriend surmised most of my problem was that I had two installs. We confirmed whennnn...I was able to open two different terminals - one with my original settings, one the new/default Linux terminal. Oops. We also figured that trying to install/run Docker before having WSL squared away didn't help. I couldn't figure out how I'd gotten which Ubuntu version running in VS Code and at this point I was TIRED and GRUMPY so I decided to torch it all:

  • Uninstall Ubuntu
  • Uninstall Ubuntu 20.04
  • Uninstall VS Code
  • Uninstall Docker

I left WSL2 alone because I at least knew that it was in there and set to my default.

Reinstall and READ

Step 2, obviously, was putting things back - carefully. Boyfriend pulled up Ubuntu in the Microsoft store and scrolled to the bottom of the description and ...oh.


A series of "WHY DIDNT THEY PUT THAT AT THE TOP" and "I don't know why didn't you read?" and "BECAUSE THAT SHOULD BE AT THE TOP" and "See, the problem here is really that most developers are lazy." and "WHICH IS WHY IT SHOUD BE AT THE TOP" ensued, and we decided to just reinstall Ubuntu, by itself. Not with 20.04, not 20.04 instead. Just the regular old "Ubuntu" option. Because you download from the MS store it's A+ easy peasy.

Customize carefully

Since I'd gotten the Ubuntu terminal reinstalled, I decided to return to the instructions I'd used when setting up my terminal 2 years prior. I figured (1) I knew that works and is (2) what I want and (3) what I'm used to. If I needed to upgrade version managers or packages to things, that wouldn't be hard to do.

I followed the instructions exactly as they said to, closed the terminal, reopened, and HUZZAH, the terminal I knew and loved had returned.

Bring back the editor

I reinstalled VS Code, went into my settings.json and confirmed the integrated terminal was coming from wsl.exe. I checked some other settings and extensions and then crossed my fingers.

Opened a terminal and THERE IT WAS.

Reinstall Docker

This was probably the most painless part - the download was quick and it recognized me from my first install and had me logged in.

Attack of the Clone...d Repo

Because we'd torched everything, I needed to create a new SSH key to use for work BUT - because we'd come back and done things the way they should have been, it was incredibly easy. I was able to follow the instructions (are you sensing a theme) and keep going without issue.

From there, I went to the repo for work and cloned it down.

Test it all together

Here is where we'd find out if all of this worked: I went to the readme, executed the first command, then executed docker-compose up --build and...held my breath.

It took a while but a reasonable while. I was able to get both the backend and the frontend up and THIS WHOLE PROCESS of redoing everything took maybe an hour? AMAZING what happens when you follow the instructions.

How to do better than I did

Upgrading to WSL2

  • Go to the Microsoft Docs and follow the instructions.
    • Open PowerShell as an administrator. It literally says "Run as an Administrator" - do that.
    • Follow the MS docs and enable WSL, check you have a compatible Windows version, and download the WSL2 package.
    • Set WSL2 as the default version. From here, pull up the instructions from Ubuntu to be safe (linked below).

Install Ubuntu

Or whatever, I guess - there are several Linux distribution options. But! either:

  • follow the instructions from Ubuntu re: how to upgrade from the command line OR
  • do what I did and just uninstall whatever you have and reinstall fresh since you'll get the new 20.04 for WSL2.

THEN, install Docker

I did a lot of poking around in GitHub and StackOverflow during all this mess and somehow Docker was possibly probably an issue here - so make sure you're running WSL2 and squared away there before putting Docker on your machine.

Check/update your VS Code settings

Lbh, out of all of these, updating the VS Code settings is the least stressful/painful and hard to screw up. You got this.

FIN

From here, you should have a working Linux terminal and have Docker functioning from the command line. (If you did what I did and uninstalled/reinstalled Ubuntu, you're going to reinstall your various npm, rvm, Rails, etc etc. Not a huge deal though.)

WHAT ELSE CAN A GIRL ASK FOR AMIRITE? Knowing what I know now, this entire process should have taken maybe an hour. Lol @ me.

Go forth and do better. Go team.

Discussion

pic
Editor guide