Why do no programs run in visual studio code? - visual-studio-code

I recently got a new computer and reinstalled visual studio code but I haven't been able to run any of my files. The error has occurred with both python and C++, so I feel as though it is the IDE that is the problem. I have looked online and there are no straight answers as I have tried following some solutions which have resulted in different errors.
The error above comes up when I run (F5) a simple line of code in c++. Does anyone have a solution?
Thanks, Jacob
[EDIT]
For my python files to work I have to manually select 'Python: current file' but for c++ files they still have the same error.

First step, uninstall python from this machine.
Second, reinstall and make sure that you check the box "add to path".
It's pretty easy to miss as it's a small box, and I missed it my first time installing python earlier in the year. Here's the box you may have missed while installing.

It could be your extensions.
I had a similar error message and simply updated all of my extensions and then my SDK. I was then able to run my code within the IDE. I was using VSCode for c++ and also updated my GCC compiler along with the extensions.
Also look into your computer's environment variables, if you have changed the %PATH variables it may be affecting your ability to run/compile programs.

Related

Cannot find Arduino IDE path. In Visual Studio Code

I wants to use Arduino in vs code Visual Studio Code.
I installed arduino IDE on my local machine on C:\Program Files\Arduino IDE I also added arduino path my Visual Studio Code's setting .json
"arduino.path": "C:\\Program Files\\Arduino IDE",
setting .json
I am using arduino extension.
This is the pic of extension
Any suggestion or recommendations would greatly aid me. I've been struggling to find a solution for this problem for 6 hours.
This was giving me issues for the longest time, too. It seems that the Arduino 2.X IDE doesn't work well with VSCode.
To resolve, use the legacy IDE (Arduino 1.8.X). First, uninstall the 2.X version of Arduino. As of February 2023, you can download the legacy version by going to the Arduino Downloads page and scrolling down to the "Legacy IDE (1.8.X)" section. There's a few different download options. I opted for the one labeled "Windows Win 7 and Newer" since it's a neatly contained executable to install Arduino.
From here, run the executable and install normally. I also reinstalled the Arduino plugin in the Visual Studio marketplace (not sure if necessary, but it doesn't hurt). There's at least three places you could potentially enter the arduino.path:
The one in YOUR PROJECT FILEPATH/.vscode/settings.json
The one in the VS Code User Settings (File>Preferences>Settings> User tab> Search for arduino.path in the search bar)
Same as above, but on the "Workspace" tab instead of "User"
For me, leaving all three empty worked fine. I believe that's because the installer added Arduino to the Windows Path variable. Here's a related post, though, where someone had to configure the path variable in case that doesn't work for you.

Elixir: VS Code ExUnit cannot find Mix

I cannot load or run my tests, from within VS Code.
I'm a new user to Elixir, and to VS Code. I'm running Lubuntu 21.10 (Impish). I've downloaded Erlang/OTP 25 (.deb), and Elixir 1.14 (precompiled binary in /usr/share/elixir), and can get anything I need running in a Bash terminal. Again, in a standard QTerminal window,
erl, iex, mix, elixir, etc. all work fine.
In VS Code, however, I get some errors. I feel stupid, but I'm coming from Sublime Text, so please forgive me.
In the left pane of VS Code, ExUnit shows an error (red):
Clicking on this error gives me this, on the bottom right pane. The command line options, passed to mix test, seem to be the default configuration:
This result is bizarre to me, because I can open the integrated terminal, execute /bin/sh, and then run the exact mix test line that's displayed:
/usr/share/elixir/bin has been added to my PATH variable, in ~/.bashrc, ~/.profile, and /etc/environment.
However, I am further confused by all tests being excluded, and wonder if there's some connection to the core issue:
Note that I can run my tests just fine, using different command line options. I've tried adding tags, but that didn't fix the problem.
I tried Google'ing this, and played around with my settings. Here is what I have configured in the "User" settings.json, and I made sure nothing overrides this in "Workspace" settings:
Changing the useNativeTesting setting doesn't solve the problem.
On another (?) note, I get a "failed to run elixir" upon VS Code startup:
Again, I have no problem running commands from a Linux terminal, or from a terminal within VS Code.
Plot twist: If I remove the precompiled Elixir 1.14, and downgrade to an older version, via apt, the problem goes away. But Lubuntu 21.10 doesn't offer Elixir 1.14, and I'm really into using the new dbg() feature.
But for now, I cannot load or run my tests, from within VS Code, apparently because Mix cannot be found.
Thanks to Daniel Imms, from the VS Code team, for answering my question on Twitter:
"Try moving where ever you init mix and elixir (.bashrc?) into your .bash_profile and then logging out and in again or restarting. I'm guessing it's in your bashrc which doesn't run in non-interactive sessions like in tasks."

Missing Photon Pun assembly reference with Visual Studio Code 1.50.1

I am developing Unity game apps on a PC using C#, using Visual Studio Code as the editor. The apps are targeted at PC and Android. Multiplayer uses Photon Pun 2.
The Unity version is 2019.3.14F1 - I don't want to move forward just yet in case of 'unexpected problems'.
The VS Code version was 1.48.3 - and everything was fine, no compile errors, all code working OK etc.
Stupidly, I took Microsoft's advice to update VSC, and VS Code went to 1.50.1. Result of this is that there are all sorts of errors showing up in VS Code relating to the Photon code. All these errors stem back to the 'using Photon.Pun;' line. It says "the type or namespace name 'Pun' does not exist in the namespace 'Photon' (are you missing an assembly reference?)".
The code however does not come up with any compile errors in the Unity editor itself, and it all runs fine, including the Photon parts. The problem is in VS Code.
I realise this is almost certainly as VS Code problem, not Photon, but I am wondering if anyone has met this before and knows how to fix it?
(This is why I do not want to move from 2019.3.14F1 to 2020.whatever at the moment - you never know what might happen).
I had the same problem. Installing different versions of VS Code / VS Community Edition didn't fix anything for me, but this did:
With the project open in VS Code, find all occurrences of
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
in *.csproj files, and replace them with
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
Tried rebuilding project files, swapping to a different editor (VS Community Edition 2019 - that was fine), but no difference - VSC persisted with the errors. Rest of intellisense working OK.
In the end, totally uninstalled VSC and reinstalled, and that sorted it out. No idea what the actual fault was.
I was wrong.
To-day, the errors are back.
The reason appears to be that in the process of trying to sort this, I installed VS Community Edition 2019 to see if that worked OK (it did). Then went back to VSC, and - that was fine too. Later I uninstalled VS Community Edition 2019 (it is taking about 4GB). It was uninstalling that which brought the errors back into VSC. Reinstalled VS Community Edition 2019, and it is all fine again.
So, VS Community Edition 2019 installs something that VSC needs - but I haven't yet figured out what it is.
UPDATE:
Gave up. Never managed to find out what VSC wanted and wasn't getting. Instead, reinstalled old version of VSC (1.48.2 from code.visualstudio.com/updates) and it is all fine again.
If still having this problem, all you have to do to fix it is by going to Package manager and install "visual studio editor package"
windows>Package Manager> All Packages /or Unity Registry (depeding on your unity version) search of visual studio editor
if it's already installed delete it and reinstall.
Got it FIXED!
Solution (it was a Unity issue):
In Unity, goto Edit > Preferences > External Tools > External Script Editor, and point it to Visual Studio..
Why this was so hard to find, I have no idea. But now my Photon solutions and namespaces properly transfer from Unity to Visual Studio. Hooah!
Also moved the script to where the photon scripts are
Uninstall the Visual studio community and re-install with latest VSC 2022. It will fix the issue

VS code, julia linter doesn't work (on mac)

having assured myself that julia is enabled and that the linter is too (in vs code settings: Julia › Lint: Run), i get syntax highlighting on my xxx.jl script but no linting at all.
im on the latest vs code + latest julia 1.07 extension + latest macosx.
i did a clean installation of vs code, wiping all old related folders prior to installation (https://stackoverflow.com/a/53839847/11608725)
so julia is the only extension/package installed, no conflicts should be present.
what am i missing?
thanks!
edit/update:
i also found that i can NOT run an open script (via the leftmost button)
a pop-up says
and clicking on open launch.json gives
from which point on im pretty much stuck. googling around, a couple of very similar issues appeared (eg. https://stackoverflow.com/a/61284896/11608725, https://github.com/microsoft/vscode/issues/94725#issuecomment-612062020), but which should presumably have been fixed with vs code 1.44 and i am on 1.49.
perhaps the no-linting is related to this?
Have you tried Julia Formatter 0.3.0 for vs code? This has always worked for me.
similar message "Please first open a folder in order to .." pretty annoyingly appeared, my end, on a different platform [Win] [Visual Studio Code version: 1.56.2], too
meaning : it's likely the workflow/settings logic specific to VS Code, not an os/platform issue as such
all problems solved, my end, simply by
after launching VS Code
via "File" > "Open Folder..." : just do first -- before doing anything else in VS Code and/or with code-files -- open the current/working project folder [ie. the very folder with a ".code-workspace"-file in it for the given project (source file dir) ]

Input does not work in Visual Studio Code

So I just started learning programming and I think something is messed up with my code runner in Visual Studio Code. When I try to use input in Python I can not write anything in the terminal. This problem came out recently. It writes that when I try to input anything that it "cannot edit in read-only editor". I also checked in here what could be the solution, but it did not help. Input still does not work. I am on Linux, and I also tried to uninstall the program and code runner as well, none of them worked so far.
Ps: I tried the Code-runner: Run in Terminal box check method, which did not work at all.