VSCode & The Spaces!

Who would win?: Visual Studio Code vs. File path spaces?

If your answer was Visual Studio Code, you were wrong! Or if you were just confused by the question, let me explain.

So over the course of the past two weeks, I was tasked with setting up the source code for VSCode and slowly work my way to becoming a contributor to the open source project. So off I went, downloading all the necessary prerequisites (Yarn, Python 2.7, and C/C++ Compiler Tool Chain).

After all the downloads and installations had finished, it was time to start working with VSCode Dev itself.

Step 1.  Open up a terminal where your cloned copy of VSCode Dev is and run the following command: yarn

The command ran successfully and downloaded for me all the necessary dependencies which would enable me to build and run the source code. So far so good!

Step 2.  In the same terminal, run the command: yarn run watch

This command would build the source code and keep watch for any changes you might make to it. In the event a change is made, it will rebuild the source code. Now when I ran this command, it ran a little too fast (according to a very smart friend of mine). But I didn’t think too much of it, fast program is a good thing, no? Boy was I wrong!

Enter the spaces!

It was time to run the third and final step to getting VSCode to build and successfully run. All that was left was one simple command: ./scripts/code.bat

Write the line, I did, press enter, I did, got what I expected, I did not. Shocked, I was! (Okay, I’ll stop).

I kept getting a dreaded “The system cannot find the specified path” error. At this point I thought I might have missed a download somewhere at some point. Because as the error explains, a folder/path is missing, meaning that something that should be there, isn’t. So I deleted my copy of VSCode, re-downloaded, and re-ran steps 1-3. Same error occurred. “Uhm, okay?” I said to myself. So I deleted, re-downloaded, re-ran steps 1-3, again. same error. “You’re joking lol…” I said. But no, that error message was not joking at all. In fact, I was the joke. I had no idea what path it was trying to find, so I couldn’t properly diagnose the problem at all. So I was stuck on thins problem for about one week. Even had the help of my dear friend (Marco Beltempo), and his efforts as well couldn’t amount to a solution. We were both honestly stumped, and I felt too defeated to even try any longer. So I gave it a rest for a few days.

Eventually I decided to give it another try,  again, same error. But I didn’t give up this time! I kept playing around with it and had the rather silly idea of running the build code for Macs. The command ./scripts/code.bat is meant for Windows machines, which I had. On the other hand, the command ./scripts/code.sh is used for Mac PCs. Write the line, I did, press enter I did, (sorry, I’ll stop). So I got the same error as before when I ran the Windows specific command, however, the Mac command came with more details on the error. “Electron is missing”!!!!!! And there it was!! Turns out I was missing Electron. Now for those of you that aren’t familiar with Electron, it’s a very useful framework that enables a developer to create web applications that can be ran on a desktop as if it were an application. You can read more about it here. Now Electron is a big deal here, as it enables me to even see the built version of VSCode. I had no idea how I didn’t download it!

So after some digging around the various folders, turns out Electron WAS indeed downloaded, and was in the exact folder that the error message said it wasn’t. Hmmmm, :thinking:. I was honestly lost at this point. The command line said it wasn’t there, but my eyes said otherwise when I checked.

Enter Mr. Beltempo! He had the idea of re-downloading the entire package, but just keeping the folder VSCode is cloned on my desktop. So we did that, and everything worked, it actually built and ran…

What the problem was

It all makes sense now! In the same week I took on this task, my professor had introduced us to a bug that is going on with VSCode and absolute paths. It does not know how to parse them if they have spaces! And as it turned out, the path I had stored my VSCode folder had spaces in its path name. My professor actually submitted a fix for this bug. So it seems that the same method that Microsoft uses to find files/folders in VSCode was used to find files/folders in the bat file as well.

Conclusion

And there it was. Only took me about two weeks to successfully download, build and run VSCode, no biggie! But in all seriousness, I had fun getting this thing to work. It was a great learning experience and insight on how it is that Microsoft handles spaces, haha.

I’d like to thank you for taking the time to read this far. If you have any questions, please don’t hesitate to leave them in the comments section!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s