I've been having trouble with opening visual studio code.
The scenario is that I have a server filesystem mounted in my local pc (UBUNTU WSL) using SSHFS.
In normal cases, I can open file using visual studio code using the command code <filename>
.
However, when I am inside the server filesystem directory and I try to use this command I get the error
/mnt/c/Users/kurti/AppData/Local/Programs/Microsoft VS Code/Code.exe: Invalid argument
Surprisingly, I can use gedit in the same manner without any problem e.g. gedit <filename>
.
Then what is weird is that I can use the code to open a file/directory in the server filesystem when I am any folder in my local fileystem. With this I can easily open the server file using code </full/path/to/file>
.
Is this a possible bug in visual studio code or a problem with my system ?
Edit:
I created a new work around function/command which is
command name: vcode
#!/bin/bash
fpath=$(realpath $1)
(cd $HOME; code fpath)
Update:
I reported it in the WSL github page as an issue https://github.com/microsoft/WSL/issues/7890
More specific details as follows
Repo steps
In WSL terminal,
- Mount a server filesystem using sshfs (in my case it is a university supercomputer)
sshfs -C <server_name_and_ip> <mount_location>
designated mount_location is an empty directory called smith_server with path /home/k/smith_server/
- Go to directory
cd /home/k/smith_server
- Open directory in visual studio code
code .
Expected behavior
The expected behavior is that visual studio will open the directory/file regardless of the current working directory.
Actual behavior
The actual behavior is that when the current working directory is inside the mounted server filesystem, launching the command code .
or code <filename>
will result in the error code.
/mnt/c/Users/kurti/AppData/Local/Programs/Microsoft VS Code/Code.exe: Invalid argument
Some examples that are working,
- When the working directory is not part of the mounted server filesystem,
code .
or code <file>
works fine.
- When the working directory is not part of the mounted server filesystem, using code to a full path of a file/directory in the server filesystem e.g.
code /home/k/smith_server
can successfully open the file/directory without problems.
- When the working directory is inside the mounted server filesystem,
gedit <file>
works fine
- When the working directory is inside the mounted server filesystem,
code $HOME
also gets an error.
The conclusion on my end is that there are problems when invoking code command when inside the mounted server filesystem. Additionally, this doesn't happen when gedit was used. However, when outside the mounted server filesystem, the code
command can be invoked and also access the mounted filesystem by using a full path. Perhaps for something is happening when tracing the Code.exe file. Linux-based software like gedit is not affected but perhaps the Windows-based software like Code.exe, that are just being interfaced are affected?