How to NOT open Visual Studio Code from the command line - visual-studio-code

I see a lot of posts asking how to open VScode from the command line; I have the opposite problem!
When a type a file name from the CMD terminal, VSCode is launched with the file contents...why is that? I don't want that to happen! Any ideas on how to stop this from happening?

Maybe you should check your environment variables and find path for VScode, then delete it
Also maybe in your file properties VScode is set to default opening app , so it open files by default
For example (In my case Intellij IDEA) it looks something like this:
this mean you should go to properties and change "opens with" options

Thanks for the hints; they both helped on solving the problem.
The one particular file that I wanted to execute and NOT open with vscode is a bash script file with extension " .sh ".
I checked the file manager and it is not associated with vscode; instead, it says "SH Source File".
Then, I followed the link to thisdavej and after seeing the proposed registry entries, I went ahead and looked into my own registry...found that the .sh extension had an "OpenWithProgids/VSCode.sh", deleting that solved my problem. Now, when I type the name of the shell script, it actually executes.
Thanks.

Related

How to stop VScode creating a symlink instead of a file

I have tried to google, this can't find anything or on here so suspect i'm being a noob, so perhaps someone can educate me.
I am copying a file from one directory within by repo in VScode to another. It is a MAKEFILE (which i'm not that familiar with anyway).
I then select copy...
And then i select a sub directory within same directory so i can paste
Once i complete this, rather than the file being copied, it creates a syslink to the file which isn't what i want as i now need to modify the file...
Even if i create the file as a new file, this will still display as a symlink.
Am i doing something stupid here?
I have created the file through the command line but the file still shows as a symlink.
Driving me crazy, please help!
thanks :)
I found the solution here, just complete these steps:
Open VSCode and press Command+Shift+p
Type Uninstall and select option "Uninstall code command from PATH"
Input admin password and then close VSCode once it confirms its been removed
Close VScode application
Re-open VScode and press Command+Shift+p
Type "Install code command to PATH"
Input admin password
Try now and this should work.
I found if i didnt close VScode after removing/adding command to PATH, the setting was lost.
Hope this helps.

Renaming files doesn't take effect in VScode while using WSL2

I have a very annoying problem in my VScode setup.
I'm using WSL as a terminal to work on my projects and occasionally, mistype the name of one of the folder or file that I'm working with.
For example:
I accidentally created the Mainheader.js file in layout folder (without the capitalized L) therefore, I decided to rename the folder with a capital L.
Now on my React app, any changes made to MainHeader.js file will not be reflected. I did update the related import.
So I decided to delete the entire folder and recreate it with MainHeader.js but this is what I end up with.
The file is there in my folder but when I click on it, I get
"Unable to open Mainheader.js - File not found"
So I try to create it then I get this error:
Unable to create file 'wsl\path]to\MainHeader.js' that already exists when overwrite flag is not set
Has anyone run into this type of behavior in WSL before? It's quite annoying because the only workaround I've found so far is to create a completely different folder with a different name...
Any help would be appreciated. I can't really work like this.
I've been having the same problem for the past 2 days. I presume its a permissions issue, but unfortunately I don't know how to permanently fix it.
I did find this work-around though:
Open a new VS Code window. (I'd recommend closing any VS Code window that had
your project directory open.)
Create a duplicate or copy the contents of the problem file so you don't lose
your code.
Delete the problem file.
Now create the file again using VS Code. Go to File > New Text File. Next paste
in your code.
Now save your new file. Go to File > Save As and save your new file with at the same path + filename + extension that was giving you problems previously. VS Code should allow you to save the new file without any issue.
Now you can open this new VS Code window to your project directory and you should be able to continuing accessing the file that was a problem before.
Basically we just deleted the problem file and then created it again from scratch in a new VS Code window.
Hope this work-around works for you!
EDIT 09/20/2022
Following Baza86's answer here solved the issue for me. Seems like it was a permissions issue of sorts, but if you use the Remote-WSL extension VS code can directly access the linux filesystem.
How to run VScode in sudo mode in WSL2?
You may need add the case option to you options in the wsl config. The default is set to off, however you can set this to off, dir or force.
Open your wsl.conf using sudo with any text editor while running window subsystem Linux. The config file resides in /etc/wsl.conf. This file is used to configure settings per-distribution for Linux distros running on WSL 1 or WSL 2.
My default config looked like this yours may be different:
[automount]
options = "metadata"
add
[automount]
options = "metadata,case=dir"
Here is the official Microsoft docs for Advanced settings configuration in WSL - https://learn.microsoft.com/en-us/windows/wsl/wsl-config

An error in the running of kotline in vscode

enter image description here
Can anyone say how to debug it
It seems like your kotlin directory is not added to your PATH variable thus the extension/terminal may not know what to execute, when trying to execute kotlinc.
The easiest way to resolve this issue is by adding the path to your kotlin directory (path/to/your/kotlin/bin) to your PATH variable
(see here), if you are on windows, or here, if you are on a linux system.
You can check, if it works by opening a command line window and trying to execute
kotlinc -version
However, as it seems like you are using Code-Runner extension in vscode, you can also update your settings.json file:
reference here.

What settings do I have to change to make Visual Studio Code automatically run files in the right directory?

Coming from IDLE, I am used to be able to just left-click python files anywhere, it'll launch IDLE, and then pressing F5 just runs the script. In VSCode however, I have to open the terminal, cd into the right directory, and only then can I finally run my python script. Is there a way to change this behavior?
I was recommended to use the Code Runner extention and bound the Run Code (code-runner.run) command to my F5 key.
Then I noticed input() not being ran so I had to make sure code-runner.runInTerminal was on, but that re-started my problem from the beginning because the terminal was at the wrong working directory and then I finally found the code-runner.fileDirectoryAsCwd setting to run it from there.
I think this solution is similar to this one for the python extention, but I'm not sure if that would cause the whole wrong working directory issue again.
choose from menu file then click on auto save

Where are Visual Studio Code log files?

My VS Code frequently shows an error, something like "Error: cannot read property 'name' of undefined". The 'ESLint' tag in the status bar also shows up in red with an exclamation mark.
I suspect my team's custom ESLint plugin. I'd like to see the stack trace of the failure, which would probably confirm or refute my theory.
Does VS Code keep logs for this kind of error? If so, where are they?
(I'm running it on a Mac.)
VSCode has a couple of commands for opening its logs folders. For the VSCode logs, you can use the Developer: Open Logs Folder command, and for VSCode extensions it's Developer: Open Extensions Logs Folder. You can search for those commands in the Command Palette in the usual way.
These commands spawn a new Finder window on OSX, or open in Windows Explorer on Windows.
On Linux there are some log files under ~/.config/Code/logs. Hope this helps.
On Windows, it is at %AppData%\Code\logs
I believe this is the directory you're looking for on MacOS: ~/Library/Application Support/Code/logs/. I'm not sure if extensions typically store their logs and stuff elsewhere, but they'll likely be somewhere in the Code folder.
For clarification if anyone else stumbles on this type '>Developer: Open Logs Folder' with the forward > symbol to start