{"id":2107,"date":"2022-08-22T17:42:37","date_gmt":"2022-08-22T15:42:37","guid":{"rendered":"https:\/\/nguenkam.com\/blog\/?p=2107"},"modified":"2022-08-22T17:42:37","modified_gmt":"2022-08-22T15:42:37","slug":"how-to-open-vscode-from-a-windows-linux-subsystem","status":"publish","type":"post","link":"https:\/\/nguenkam.com\/blog\/index.php\/2022\/08\/22\/how-to-open-vscode-from-a-windows-linux-subsystem\/","title":{"rendered":"How to open VSCode from a Windows Linux Subsystem"},"content":{"rendered":"\n<p><strong>Issue :<\/strong> <em>When typing<span class=\"has-inline-color has-vivid-cyan-blue-color\"> &#8220;code .&#8221;<\/span> command on WSL , we get the following error-message :<span class=\"has-inline-color has-vivid-red-color\"> &#8220;Command &#8216;code&#8217; not found&#8221; <\/span>. <\/em><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4>SOLUTION 1<\/h4>\n\n\n\n<p>Assuming you have installed VSCode in its default place, then in WSL you can do :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PATH=\"$PATH:\/mnt\/c\/Users\/your-user-name\/AppData\/Local\/Programs\/Microsoft VS Code\"<\/code><\/pre>\n\n\n\n<p>and run\u00a0<code>code.exe .<\/code><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4>SOLUTION 2<\/h4>\n\n\n\n<p>PS: <em> First, try installing the\u00a0<code>Remote - WSL<\/code>\u00a0extension in VSCode (or the meta\u00a0<code><strong>Remote Development<\/strong><\/code>\u00a0extension pack, which includes the WSL work).<\/em>  (<span class=\"has-inline-color has-luminous-vivid-orange-color\"><em>Not sure that\u00b4s is the main problem, but it could help<\/em>.<\/span>)<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/08\/image-6.png\" alt=\"\" class=\"wp-image-2108\" width=\"351\" height=\"179\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/08\/image-6.png 960w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/08\/image-6-300x154.png 300w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/08\/image-6-768x394.png 768w\" sizes=\"(max-width: 351px) 100vw, 351px\" \/><\/figure><\/div>\n\n\n\n<p>try running\u00a0<code><span class=\"has-inline-color has-vivid-cyan-blue-color\">code .<\/span><\/code>\u00a0under<strong> PowerShell <\/strong>&#8211; Does that work? If not, then <strong>VSCode <\/strong>isn&#8217;t in the <strong>Windows path<\/strong>. Try reinstalling it &#8212; If it&#8217;s not in the path, some other associations may not be correctly installed either. I don&#8217;t recall if there&#8217;s an option during installation to add or not add it to the Windows path, but if so, it could be that it was deselected during installation.<\/p>\n\n\n\n<p>If it does launch in Windows, then obviously it&#8217;s in the Windows path. <em>By default, WSL appends the Windows path to the default path in Ubuntu during init. So (again, by default)<span class=\"has-inline-color has-vivid-cyan-blue-color\">\u00a0<code>code .<\/code><\/span>\u00a0should work in <span class=\"has-inline-color has-vivid-cyan-blue-color\">WSL<\/span> if it is working under<span class=\"has-inline-color has-vivid-cyan-blue-color\"> PowerShell.<\/span><\/em><\/p>\n\n\n\n<p>Check your\u00a0<code>$PATH<\/code>\u00a0under Ubuntu (<code>echo $PATH<\/code>). Is the <em><strong>&#8230;<code>\/Microsoft VS Code\/bin<\/code><\/strong><\/em>\u00a0<span class=\"has-inline-color has-vivid-cyan-blue-color\">directory<\/span> (wherever it is installed) in the path? If not, then WSL may not be doing its default append. Edit\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/wsl\/wsl-config\"><code>\/etc\/wsl.conf<\/code><\/a>\u00a0under Ubuntu and look to see if there&#8217;s an\u00a0<code>[interop]<\/code>\u00a0section, as in:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;interop]\r\nappendWindowsPath=false<\/code><\/pre>\n\n\n\n<p>If so, then change it to\u00a0<code>true<\/code>\u00a0(or, delete it entirely) to allow WSL to add the Windows path. While it&#8217;s the default setting if missing, you might try adding it and setting it to\u00a0<code>true<\/code>\u00a0(although that shouldn&#8217;t have any effect).<\/p>\n\n\n\n<p>If that still doesn&#8217;t work, then check your startup scripts (e.g.\u00a0<code>.profile<\/code>,\u00a0<code>.bash_profile<\/code>,\u00a0<code>.bashrc<\/code>) to see if there are any modifications to the\u00a0<code>PATH<\/code>\u00a0which could be causing this problem.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Issue : When typing &#8220;code .&#8221; command on WSL , we get the following error-message : &#8220;Command &#8216;code&#8217; not found&#8221; . SOLUTION 1 Assuming you have installed VSCode in its default place, then in WSL you can do : and run\u00a0code.exe . SOLUTION 2 PS: First, try installing the\u00a0Remote &#8211; WSL\u00a0extension in VSCode (or the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1721,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[250,193,140,502,161,217,571,299,501],"_links":{"self":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2107"}],"collection":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=2107"}],"version-history":[{"count":1,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2107\/revisions"}],"predecessor-version":[{"id":2109,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2107\/revisions\/2109"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media\/1721"}],"wp:attachment":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=2107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=2107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=2107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}