<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>VSCode on Daniel Zhang</title><link>https://zhangdapeng.dev/tags/vscode/</link><description>Recent content in VSCode on Daniel Zhang</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Sat, 31 Oct 2026 05:18:00 +0800</lastBuildDate><atom:link href="https://zhangdapeng.dev/tags/vscode/index.xml" rel="self" type="application/rss+xml"/><item><title>Developing with WSL and VS Code: Resolving `code: command not found` and Optimizing Performance</title><link>https://zhangdapeng.dev/p/wsl-vscode-command-not-found-performance/</link><pubDate>Sat, 31 Oct 2026 05:18:00 +0800</pubDate><guid>https://zhangdapeng.dev/p/wsl-vscode-command-not-found-performance/</guid><description>&lt;p&gt;Pairing WSL (Windows Subsystem for Linux) with VS Code has become one of the most popular development workflows for full-stack and indie developers on Windows. However, during configuration, it is common to run into shell errors or performance bottlenecks caused by cross-filesystem file handling. This post documents the journey from encountering the issue to diagnosing the root cause and implementing the final solution.&lt;/p&gt;
&lt;h2 id="1-encountering-the-issue"&gt;1. Encountering the Issue
&lt;/h2&gt;&lt;p&gt;After switching the default WSL shell to an efficient &lt;code&gt;zsh&lt;/code&gt; environment, attempting to launch the editor directly from the project directory via the command line resulted in a roadblock:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;➜ zhangdapeng.dev git:&lt;span style="color:#f92672"&gt;(&lt;/span&gt;main&lt;span style="color:#f92672"&gt;)&lt;/span&gt; code .
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;zsh: command not found: code
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is a classic issue: &lt;strong&gt;The terminal inside WSL (especially after configuring zsh) fails to recognize the Windows-side VS Code executable.&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id="2-root-cause--deep-dive"&gt;2. Root Cause &amp;amp; Deep Dive
&lt;/h2&gt;&lt;p&gt;There are two primary reasons why this error occurs:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;WSL Configuration Disables Interoperability&lt;/strong&gt;: In &lt;code&gt;/etc/wsl.conf&lt;/code&gt;, if &lt;code&gt;appendWindowsPath&lt;/code&gt; is set to &lt;code&gt;false&lt;/code&gt;, WSL prevents Windows environment variables (&lt;code&gt;PATH&lt;/code&gt;) from being appended to Linux. This isolates the Linux environment and stops it from invoking Windows &lt;code&gt;.exe&lt;/code&gt; applications.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;zsh&lt;/code&gt; Path Inheritance Miss&lt;/strong&gt;: When migrating from the default &lt;code&gt;bash&lt;/code&gt; to &lt;code&gt;zsh&lt;/code&gt;, certain cross-system environment variables might not refresh or inherit correctly inside the new shell profile.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="the-slow-vs-fast-debate-where-to-store-your-code"&gt;The &amp;ldquo;Slow&amp;rdquo; vs &amp;ldquo;Fast&amp;rdquo; Debate: Where to Store Your Code?
&lt;/h3&gt;&lt;p&gt;While fixing the connection issue, developers often face a choice of directory location (&lt;code&gt;/mnt&lt;/code&gt; vs &lt;code&gt;~&lt;/code&gt;), which fundamentally shapes the speed of the development experience:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The Slow Path (Code on Windows side: &lt;code&gt;/mnt/c/...&lt;/code&gt;)&lt;/strong&gt;: Storing code on a Windows partition and accessing it through WSL incurs heavy I/O performance degradation. Because data must constantly cross two entirely different file systems (NTFS and ext4), operations like &lt;code&gt;git status&lt;/code&gt;, &lt;code&gt;npm install&lt;/code&gt;, or project compilation feel visibly sluggish.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The Fast Path (Code inside WSL side: &lt;code&gt;~/...&lt;/code&gt;)&lt;/strong&gt;: Storing projects natively within the Linux file system ensures near-native performance. The Remote-WSL extension deploys a highly optimized, lightweight background server inside Linux, unlocking maximum compilation speeds.&lt;/li&gt;
&lt;/ul&gt;

 &lt;blockquote&gt;
 &lt;p&gt;&lt;strong&gt;Is there anything wrong with staying on the &amp;ldquo;slow&amp;rdquo; path?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Not necessarily! Launching VS Code from a &lt;code&gt;/mnt/&lt;/code&gt; directory might introduce a slight lag during heavy file tasks, but if the execution speed is acceptable to you, it is perfectly fine. The biggest advantage? Security and simplicity. Even if your WSL instance gets corrupted, your source code remains safe on your host Windows drive, allowing easy backups and management using standard Windows GUI tools.&lt;/p&gt;

 &lt;/blockquote&gt;
&lt;h2 id="3-the-solutions"&gt;3. The Solutions
&lt;/h2&gt;&lt;h3 id="step-1-verify-and-enable-windows-path-appending"&gt;Step 1: Verify and Enable Windows Path Appending
&lt;/h3&gt;&lt;p&gt;First, ensure that WSL is permitted to inherit environment paths from Windows.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open the WSL configuration file:
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo nano /etc/wsl.conf
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Check the &lt;code&gt;[interop]&lt;/code&gt; section and ensure &lt;code&gt;appendWindowsPath&lt;/code&gt; is not set to &lt;code&gt;false&lt;/code&gt; (change it to &lt;code&gt;true&lt;/code&gt; or remove the line entirely):
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;[interop]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;appendWindowsPath&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;If changes were made, open Windows PowerShell and run &lt;code&gt;wsl --shutdown&lt;/code&gt; to restart the subsystem.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="step-2-manually-inject-the-vs-code-path-into-zshrc"&gt;Step 2: Manually Inject the VS Code Path into &lt;code&gt;.zshrc&lt;/code&gt;
&lt;/h3&gt;&lt;p&gt;If interoperability is enabled but the command still fails, the most foolproof method is manually appending the entry to your &lt;code&gt;zsh&lt;/code&gt; configuration:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open your shell configuration file:
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;nano ~/.zshrc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Scroll to the absolute bottom of the file and paste the following line (make sure to replace &lt;code&gt;YourWindowsUsername&lt;/code&gt; with your actual Windows account folder name):
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Manually inject the Windows VS Code binary path into zsh&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;export PATH&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\$&lt;/span&gt;PATH:&lt;span style="color:#e6db74"&gt;&amp;#34;/mnt/c/Users/YourWindowsUsername/AppData/Local/Programs/Microsoft VS Code/bin&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Save, exit (&lt;code&gt;Ctrl + O&lt;/code&gt;, &lt;code&gt;Enter&lt;/code&gt;, &lt;code&gt;Ctrl + X&lt;/code&gt;), and refresh your terminal:
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;source ~/.zshrc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="step-3-the-alternative-workspace-workaround"&gt;Step 3: The Alternative Workspace Workaround
&lt;/h3&gt;&lt;p&gt;If permission restrictions or security policies prevent the terminal workflow from functioning, you can bypass the command line entirely:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Launch &lt;strong&gt;VS Code&lt;/strong&gt; natively from your Windows desktop.&lt;/li&gt;
&lt;li&gt;Press &lt;code&gt;Ctrl + Shift + P&lt;/code&gt; to open the Command Palette, type &lt;strong&gt;WSL&lt;/strong&gt;, and select &lt;code&gt;WSL: Connect to WSL&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Once connected, use the top menu to navigate to &lt;strong&gt;File -&amp;gt; Open Folder&lt;/strong&gt;. You can seamlessly browse and open folders located anywhere inside the WSL instance or your &lt;code&gt;/mnt&lt;/code&gt; drives.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="4-summary--best-practices"&gt;4. Summary &amp;amp; Best Practices
&lt;/h2&gt;&lt;p&gt;Leveraging WSL alongside VS Code&amp;rsquo;s remote architectures provides an incredibly powerful sandbox environment on Windows.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;For Ultimate Speed&lt;/strong&gt;: Migrate your code repositories directly to the Linux home directory (&lt;code&gt;~&lt;/code&gt;) using &lt;code&gt;cp -r&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;For Ease of Mind and Visibility&lt;/strong&gt;: Keep your folders on the Windows side (&lt;code&gt;/mnt/&lt;/code&gt;), map your &lt;code&gt;PATH&lt;/code&gt; variable correctly, and enjoy an interconnected development stack.&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>