I use WSL as my main command-line for all my git interactions.
I have the habit to open VS Code in the current folder by typing code . &
Recently VS Code started to open the folder as a remote folder instead of as a local folder.
The same thing happens even if I pass a full windows path like
code x:\\repos\\test. Instead of opening the specified folder, a new empty file is opened at ./x:/repos/test
Related
I'm using VS-Code from Windows to remote Linux machine, using SSH, and each file appears twice... once with a relative path to the base project path, and once with a full path (/home/$user/...)
It causes lots of problems, such as opening the same file twice (and then being warned that 'file was changed on disk') or cannot find declarations and stuff.
How can I solve that?
So I have started using Jupyter Notebooks in VS Code but have run into the following problem: when I create a file via the terminal it doesn't save it in the directory from which the command was run and instead it creates it in the directory in which a file was last opened (in VS Code).
Example: the terminal is currently open in C:...\programs and so I use code test.ipynb. However, instead of creating a file there, it creates it in C:...\programs\files since the last file I opened manually in VS Code was from there.
(As a note, when doing this with .py files everything works perfectly.)
I use VSCode's remote development extension fairly regularly. I can use the terminal in VS Code as if it were on my own machine, and even the code command works correctly. That is, when I'm in a remote VSCode session, I can type code path/to/some/file and it will open another editor tab with that file. The terminal session and the file being opened are on the remote machine to which I've connected.
I have VSCode installed on the remote machine, and the code executable is in my PATH. So my question is, how is this functionality implemented behind the scenes? That is, how does VSCode know that when I type code path/to/some/file it should open that file into another editor tab on my machine instead of trying to fire up VSCode on the remote machine?
Literally seconds after I wrote the question I found the answer.
If I run which code in the terminal, it doesn't resolve to the usual VSCode executable, but instead it resolves to one located at $HOME/.vscode-server/bin/a5d1cc28bb5da32ec67e86cc50f84c67cc690321/bin/code.
If I echo $PATH I can see that $HOME/.config/bin and $HOME/.vscode-server/bin/a5d1cc28bb5da32ec67e86cc50f84c67cc690321/bin has been appended to the beginning of the PATH env var that my bash profile generates.
I assume this means that VSCode is executing bash with a different profile script that
Sources my usual bash profile
Creates the directories above and copies some helper programs into them
Modifies my path to include these directories
I also assume that the injected code executable is communicating with my local instance of VSCode in some way, instructing it to open the file in its editor.
The file explorer in my VS Code is stuck on a repo that is three steps down the file tree from the C drive (Flatiron_Work); it will not allow me to access anything further up the tree, such as Users or username (mngav) It is installed correctly in C:\users{username}\AppData\Local\Programs\Microsoft VS Code . I have tried to open files, folders and workspaces further up the tree but nothing works. Am I going to need to remove and reinstall?
I open my vscode with code . command from WSL terminal because I want to work directly in my WSL. It works fine and for example, the file explorer of vscode shows directory structures based on WSL machine and not based on my Windows machine.
My problem is however that, when I save a workspace using File -> Save Workspace As, it saves it again as a workspace in my Windows machine. So when I close and open my vscode again and use Open Workspace... to open the already saved workspace(in previous step), explorer reads directories from Windows machine.
You might ask what's the difference between saving files in /mnt/c/Users/[user]/Desktop or C:\Users\[user]\Desktop, but the problem is two things:
I might open a session from a directory in WSL that is (unlike Desktop) inaccessible from Windows.
Even if my Desktop is my current working directory, I may add another directory to my workspace (using Add Folder to Workspace...) and even if it is a path accessible from Windows, the next time I open the workspace, I will get an exclamation mark and such an error near that directory in explorer:
C:\mnt\d\Files_And_Downloads\Google Drive_Code . Can not resolve workspace folder
I suspect this is a bug, vscode has mixed the WSL path and Windows path. So anyone who uses Remote - WSL extension and can tell me what's going on here?