Guide To Having PhpStorm Use Windows Subsystem For Linux’s Git

I’m one of the rare Windows users at Automattic but thanks to the introduction of Windows Subsystem for Linux, my life is way easier. I can now run pretty much any Bash script without having to spin up a virtual machine like I used to have to. While it’s possible to build Node.js-powered projects natively under Windows thanks to the Windows-Build-Tools package, it’s a lot easier to just do everything within Linux. This is largely because building in one environment means that you can’t run the tools in the other environment.

The main time that this bites you is when the project you’re working on has a pre-commit hook in Git. If you build your project in Linux but attempt to commit from Windows, it won’t work. IDEs such as PhpStorm do all of their Git operations from Windows. This blog post will explain how to get it to use the copy of Git within Linux.

  1. Install Pageant from PuTTY or if you’re signing your commits, then Gpg4win (its gpg-connect-agent can be set to be PuTTY compatible). Have it start with Windows in order to load your SSH keys.
  2. Verify that the agent is working by using PuTTY to connect to github.com with the username git. GitHub won’t let you open a shell but it’ll let you know that you have successfully authenticated. Note that command line ssh won’t work because it’s not Pageant-compatible.
  3. Install weasel-pageant to allow you to use SSH keys from within Linux.
  4. Verify that the agent is working by running ssh-add -l in Linux. Your key(s) should be listed.
  5. Verify SSH is working by running ssh git@github.com. If it doesn’t work, append -vvv to the end of the command to enable debug output to see what’s wrong.

Now that you have Git authentication working within Linux, it’s time to get PhpStorm (or whatever IDE you use) to use Linux’s Git.

The trick here is instead of having PhpStorm use git.exe, you need to point it at a batch script. This Stack Overflow question helped me a ton, but I needed to modify it a little bit.

For whatever reason, my .bashrc file wasn’t being loaded when calling bash.exe -c which meant that agent wasn’t being loaded. So as a part of my batch script, I’m manually loading my personal file that contains my shell customizations. Here’s my full batch file:

@echo off
setlocal enabledelayedexpansion
set command=%*
set find=C:\Users\%USERNAME%\AppData\Local\Temp\git-commit-msg-.txt
set replace=/mnt/c/Users/%USERNAME%/AppData/Local/Temp/git-commit-msg-.txt
call set command=%%command:!find!=!replace!%%
If %PROCESSOR_ARCHITECTURE% == x86 (
    C:\Windows\sysnative\bash.exe -c 'source ~/.viper-common; git %command%'
) Else (
    bash.exe -c 'source ~/.viper-common; git %command%'
)

In PhpStorm, go to File → Settings (or Default Settings) → Version Control → Git and set the “Path to Git executable” to point at the batch file. Verify that it works by clicking the Test button.

With that, everything should work now!

Questions? Problems? Leave a comment below.

Driving The Viper For The First Time In 11 Months

It’s been 11 months since I’ve been physically able to drive my Viper, but yesterday I finally got the chance! My clutch pedal leg is sore today but it was all worth it.

I thought I’d make a video of the long overdue startup to celebrate:

New WordPress Plugin: SmartCrop

I’ve written and released a new WordPress plugin called SmartCrop. Instead of creating cropped thumbnails from the center of an uploaded image, SmartCrop attempts to automatically determine the most interesting part of the image and centers the crop there.

It’s most easily explained with this example:

Bone Marrow Transplant #2 And GVHD

Apologies for the long overdue update post. I’ve been procrastinating hard on this one.

Way back on November 22nd, the day before Thanksgiving, I received a second bone marrow transplant in order to help treat my leukemia relapse. The stem cells were from the same donor as my first transplant but thankfully the procedure was nothing like it. This time it was simply being hooked up to an IV bag for a bit and then having my vitals monitored for a while to make sure I didn’t have any issues.

I’m very happy to report that it was a complete success and all tests have come back as completely negative for leukemia! As a side effect of the transplant however, I’ve been having some Graft-Versus-Host Disease (GVHD) meaning my donor immune system has been attacking me because technically I’m a foreign body to it despite the close match. This has mainly resulted in a rash across a lot of my body and my mouth being sore. I’m on some steroids now though to treat that and things are improving. The one good thing about GVHD though is that people who get it have higher long-term success rates because if the donor immune system is attacking me, then it’s also likely attacking any leftover cancer as well. I didn’t get any GVHD after the first transplant, which could have been part of the reason that I had the relapse.

The second transplant has also increased the amount of blood products that my body is making meaning that I’m no longer anemic. I don’t easily get out of breath by just doing things like taking a shower or going for a short walk. My heart rate is also way down, nearly back to normal. For a while, my resting heart rate was stupidly high as my heart worked hard to move oxygen around my body.

I’m still neutropenic though which means my white blood cell count is below normal and I’m more prone to infection. So I still can’t eat out at a restaurant or be around large groups of unknown people without wearing a mask. It means I’ve had to miss a couple work meetups but hopefully my counts return to normal soon. I’m anxious to be able to eat at my favorite places with friends!

I’m also starting to recover physically from everything and getting stronger by the day. I was on some fairly high dose steroids for a while and it completely wrecked my major muscles, such as those in my legs. Even things like climbing stairs required effort and worst of all, I’m still not able to drive a car with a clutch pedal!

I resumed working in December. My employer, Automattic, has been absolutely amazing throughout all of this and really has strengthened my desire to never work anywhere else. The support I received from all of my coworkers was overwhelming and really helped, especially on some of those tough days. They really are like a family to me.

One Year

I can’t believe it’s already been this long but last Wednesday the 18th marked one full year since my cancer diagnosis. Between all of the chemotherapy to get me into remission, the bone marrow transplant, the twice weekly clinic visits, and now the relapse, it’s been quite the year.

I still have a long ways to go but I received good news on Friday that it looks like the the drug I’m on is working well and has knocked back the cancer in my bone marrow. I meet with my doctor tomorrow to get the full results of a bone marrow biopsy that I had on the 13th (results take a while) and what the future holds for me in terms of treatment. With any luck, the current treatment will be enough and I can finally return to work.

Leukemia Relapse

Things had been going extremely smoothly and uneventful since my bone marrow transplant in May, making it easy to procrastinate writing a post here on my blog with updates. No news is good news, right? Well unfortunately that’s changed.

The stem cell transplant went as expected including me spending most of May in the hospital as the doctors waited for my donor immune system to take root and start producing new white blood cells. There were side effects such as a sore mouth (you’d be surprised how much healing your mouth is doing on a regular basis) that required being hooked up to intravenous fluids and nutrients, but overall no real surprises. Just my body being put through the ringer.

I was discharged near the end of May and moved back in with my amazing mom who took over 3 months off work to be my caregiver. This is because I required 24/7 supervision in the case of complications such as a fever or graft-versus-host disease (GvHD). I was also extremely fatigued early on, feeling like I had done a full workout despite just sitting on the couch all day. My body was working hard on the inside!

Things improved steadily until the end of August when I started feeling weaker again. I was more easily getting out of breath and my heart would race more than usual. I had hoped it was just some GvHD or something as getting a little bit of it is actually a good sign as it means the new immune system is strong.

Unfortunately when they did the blood lab work at my next weekly clinic visit, they detected a high white blood cell count which signaled a return of my leukemia. Worse, further testing revealed that a mutation had occurred in the leukemia meaning that the medication I had been taking before my transplant was no longer as effective at treating my Philadelphia chromosome–positive (Ph+) acute lymphoblastic leukemia (ALL).

The relapse resulted in me being readmitted to the hospital for nearly two weeks earlier this month while they got the leukemia in check using the old medication (better than nothing) and dealt with some complications such as a bit of bleeding in my lungs.

Thankfully there’s a different medication that I’m now taking that is designed specifically for treating leukemia with this mutation. The crazy thing is that it apparently costs $65,000 a month according to my pharmacist but luckily my insurance knocks it down to only a $10 copay. Phew!

My understanding is that the hope is that with this new medication, my new immune system will be able to battle back and kill off the leukemia, putting me back into remission and back on the road to being considered cured. Initial blood labs indicate that this is trending in the right direction as my white blood cell count has dropped back to normal levels but I’ll know more over the coming weeks as I’ve only been on this new medication for less than a week.

If the medication isn’t as effective as desired, I’m told such things as getting a stem cell booster from my previous donor or even a transplant from a new donor could be on the table. Then there’s even the stuff that I don’t want to think about. For now though, it’s just a wait and see.

One good piece of news is despite being on an absolute ton of different medications, I’m actually feeling pretty good. I’m still physically weak due to extended hospital stays but mentally I’m pretty much all there (well, as much as before that is, heh). I’ve been slowly getting back into writing code in preparation for returning to work next month or so, assuming I don’t need to get admitted back into the hospital yet again.

The big thing that has kept me going through all of this though has been the amazing support and love from both my friends and coworkers. It really has helped keep my spirits up and I hope all of them know how much it has meant to me!

Great Friends Visiting Me In The Hospital

Great Friends Visiting Me In The Hospital Earlier This Month