Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'${workspaceFolder}' can not be resolved. Please open a folder.' on Visual Studio Code

wondering if you could assist. Really challenging in determining a solution to this from my research.

Ive downloaded Visual Studio code two weeks ago and has come across an error once I try to debug a file. The file appears to open but once I run the debugger it shows accordingly:

'${workspaceFolder}' can not be resolved. Please open a folder.

Can't seem to find or replicate a similar solution. I've also tried to reinstall Visual Studio code (no easy feat). I'm trying to at least understand the problem and its source.

The file is a .js file that I've been working on, running a simple function. It is not meant to operate in tandem with a larger workspace/program.

like image 683
Andrew Trac Avatar asked Dec 11 '22 00:12

Andrew Trac


2 Answers

In VScode go to file --> Add folder to workspace and select the folder where the program files are located.

like image 159
Meysam Avatar answered Apr 25 '23 12:04

Meysam


If you are using the latest Visual Studio 1.44, make sure to upgrade to 1.44.2.

The issue microsoft/vscode issue 94725 has been resolved.
It featured the same error message:

https://user-images.githubusercontent.com/9964210/78838126-65c76d80-79ed-11ea-8572-a092f1576dbc.png

After some investigation the problem is the following for the workspace configuration our debug extensions appends the following attribute

__workspaceFolder:'${workspaceFolder}'

And the configuration resolver properly tries to resolve this and complains because the scope of the folder is not specified.
In a multi root workspace scope has to be specified, otherwise the resolver does not know against which folder to resolve the variables.

Proposed fix: the node extension which adds this attribute should scope it if it sees that we are in a multi root folder.
So instead of ${workspaceFolder} use ${FOLDER_NAME:workspaceFolder}.

This is fixed in commit ae97613.

like image 25
VonC Avatar answered Apr 25 '23 11:04

VonC