Variable workspace folder cannot be resolved как исправить

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.

Lex Li's user avatar

Lex Li

59.9k9 gold badges116 silver badges146 bronze badges

asked Apr 15, 2020 at 20:28

Andrew Trac's user avatar

1

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

answered Jan 30, 2021 at 21:40

Meysam's user avatar

MeysamMeysam

4094 silver badges14 bronze badges

2

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.

answered Apr 18, 2020 at 6:08

VonC's user avatar

VonCVonC

1.2m516 gold badges4339 silver badges5153 bronze badges

9

Replace ${workspaceFolder} with ${FOLDER_NAME:workspaceFolder} in your *.code-workspace file. (from [here][1])

By the way, same goes to ${workspaceRoot}, you can replace it with ${FOLDER_NAME:workspaceRoot}.

Any more folder variables ca be fixed with this FOLDER_NAME: prefix? My workspaces did not use them so far.

Worked for me in Version: 1.44.2.

answered Apr 30, 2020 at 18:40

moudrick's user avatar

moudrickmoudrick

2,0981 gold badge21 silver badges33 bronze badges

I know this question is very old already and the answers may have been correct but none worked for me on vscode v1.57.1 at the time of this comment on 30.06.2021

I had to replace ${workspaceFolder} with ${workspaceFolder:my-folder-name} in my *.code-workspace file

Ref: Variables scoped per workspace folder

answered Jun 30, 2021 at 13:11

omostan's user avatar

omostanomostan

8108 silver badges9 bronze badges

I recently had this problem and so did I read the answers above but being a beginner I was unable to solve it .In my answer I don’t have exactly what you should do but I will show what worked for me.

  1. Go to the explorer and you will see there is no folder added.
  2. Browse for .vscode folder and select it.
  3. Issue solved {this atleast worked for me.It**(.vscode)** had .json extension file in it}.

DCCoder's user avatar

DCCoder

1,5874 gold badges14 silver badges29 bronze badges

answered Jan 12, 2021 at 3:45

Prasad_k's user avatar

I was having the same issue, but I solved it this way:
1- open VS Code as administrator
2- open the sheet
3- debugging with no problem :)

answered Apr 17, 2021 at 14:29

João Bittencourt's user avatar

  • VSCode Version:
  • OS Version:

Steps to Reproduce:

Have an extension with the following

	const shellExec = new vscode.ShellExecution('ls',
	{
		executable: 'C:WindowsSystem32WindowsPowerShellv1.0powershell.exe', // or '/bin/bash'
		shellArgs: [ '-c' ]
	});

	const task = new vscode.Task(
		{ type: 'get-help' },
		vscode.TaskScope.Global,
		'Get help online',
		'Test HyperLink',
		shellExec);

        vscode.tasks.executeTask(task);

Expected:

The task executes properly

Actual:

«Variable ${workspaceFolder} can not be resolved. Please open a folder.» Error notification

Workaround:

If you add:

to the options of vscode.ShellExecution it works as expected.

Proposal

The default value of cwd should fall back to os.homedir() if workspaceFolder does not resolve.

Does this issue occur when all extensions are disabled?: N/A

I was having the same issue on Windows when I had previously created different projects on the undefined workspace (the default workdspace of VSCode).

When I create a workspace and I placed my root folders inside this one workspace, it will warn that it could not resolve workspace folder.

You have to edit your workspace config file, change the path of your folders and then restart VSCode.

On the VSCode command palette, type: workspace config — then choose «Open workspace configuration file.»
You should have something like this:

{
"folders": [
    {
        "path": "OneProject"
    },
    {
        "path": "AnotherProject"
    }
],
"settings": {}

}

What you want is something like this:

{
"folders": [
    {
        "path": "C:/Somewhere/OneProject"
    },
    {
        "path": "C:/Somewhere/AnotherProject"
    }
],
"settings": {}

}

It’s a known issue, it was fixed here — https://github.com/Microsoft/vscode/issues/50866

As of the 1.24.1 version it’s not yet available. But the fix listed above should correct the problem you are having.

Интересно , могли бы вы помочь. Действительно сложно найти решение этой проблемы из моих исследований.

Я загрузил код Visual Studio две недели назад и обнаружил ошибку при отладке файла. Кажется, что файл открывается, но как только я запускаю отладчик, он показывает следующее:

‘${workspaceFolder}’ не может быть разрешен. Пожалуйста, откройте папку.

Кажется, не могу найти или воспроизвести подобное решение. Я также пытался переустановить код Visual Studio (нелегкий подвиг). Я пытаюсь хотя бы разобраться в проблеме и ее источнике.

Это файл.js, над которым я работал, выполняя простую функцию. Он не предназначен для работы в тандеме с большим рабочим пространством / программой.

2020-04-15 23:28

7
ответов

Решение

Если вы используете последнюю версию Visual Studio 1.44, обязательно обновитесь до 1.44.2.

Проблема microsoft/vscodeПроблема 94725 решена.
Там было то же сообщение об ошибке:

После некоторого исследования проблема заключается в следующем: для конфигурации рабочей области наши расширения отладки добавляют следующий атрибут

__workspaceFolder:'${workspaceFolder}'

И преобразователь конфигурации должным образом пытается решить эту проблему и жалуется, потому что объем папки не указан.
В мультикорневой рабочей области область видимости должна быть указана, иначе распознаватель не знает, в какой папке разрешать переменные.

Предлагаемое исправление: расширение узла, которое добавляет этот атрибут, должно охватывать его, если оно видит, что мы находимся в мультикорневой папке.
Так что вместо${workspaceFolder} использовать ${FOLDER_NAME:workspaceFolder}.

Это исправлено в фиксации ae97613.


user6309

18 апр ’20 в 09:08
2020-04-18 09:08

2020-04-18 09:08

В VScode перейдите в файл -> Добавить папку в рабочую область и выберите папку, в которой находятся файлы программы.

2021-01-31 00:40

Заменить ${workspaceFolder} с участием ${FOLDER_NAME:workspaceFolder} в твоем *.code-workspaceфайл. (из [здесь][1])

Кстати, то же самое касается ${workspaceRoot}, вы можете заменить его на ${FOLDER_NAME:workspaceRoot}.

Любые другие переменные папки могут быть исправлены этим FOLDER_NAME:префикс? Мои рабочие места пока ими не пользовались.

Работал у меня в Version: 1.44.2.

2020-04-30 21:40

Я знаю, что этот вопрос уже очень старый, и ответы, возможно, были правильными, но ни один из них не работал у меня на vscode v1.57.1 во время этого комментария 30.06.2021

Мне пришлось заменить
${workspaceFolder} с участием
${workspaceFolder:my-folder-name} в моем
*.code-workspace файл

Ссылка: переменные для каждой папки рабочей области

2021-06-30 16:11

У меня была такая же проблема, но я решил ее следующим образом:1- открыть VS Code от имени администратора 2- открыть лист 3- отладка без проблем :)



17 апр ’21 в 17:29
2021-04-17 17:29

2021-04-17 17:29

У меня недавно была эта проблема, и я прочитал ответы выше, но, будучи новичком, я не смог ее решить. В моем ответе у меня нет точного ответа, что вы должны делать, но я покажу, что сработало для меня.

  1. Зайдите в проводник, и вы увидите, что папка не добавлена.
  2. Найдите папку .vscode и выберите ее.
  3. Проблема решена {это, по крайней мере, сработало для меня. В нем **(. Vscode)** был файл с расширением .json}.



12 янв ’21 в 06:45
2021-01-12 06:45

2021-01-12 06:45

Windows 10: Visual Studio Code Error: «Variable $workspaceFolder can not be resolved. Please open a…

Discus and support Visual Studio Code Error: «Variable $workspaceFolder can not be resolved. Please open a… in Windows 10 Software and Apps to solve the problem; Hello,

I have a laptop and a desktop. In order to keep them in sync with each other, I use One Drive to store my files. I recently downloaded Visual…
Discussion in ‘Windows 10 Software and Apps’ started by Sebastian712, Mar 1, 2021.

  1. Visual Studio Code Error: «Variable $workspaceFolder can not be resolved. Please open a…

    Hello,

    I have a laptop and a desktop. In order to keep them in sync with each other, I use One Drive to store my files. I recently downloaded Visual Studio Code on my desktop to One Drive. When I try to open my HTML file with the Run & Debug feature on Visual Studio Code, I get this error message shown below. Does anyone know how to fix this? I’m assuming that a file can’t be found or something, due to some of the files being downloaded to the Program Files folder in my C drive, rather than to One Drive. If anyone could help me out with this it would be much appreciated

    Visual Studio Code Error: "Variable $workspaceFolder can not be resolved. Please open a... 2ec8e9d2-091f-4e1e-91da-81490f6875f6?upload=true.png

    :)

  2. Emmet 2.0 in Visual Studio Code Read more: Emmet 2.0 in Visual Studio Code

  3. Visual Studio Code Error: «Variable $workspaceFolder can not be resolved. Please open a…

    Visual Studio 2017 C# File Handling

    Compiling a C# program using StreamReader and StreamWriter variables on the command line works fine. On Visual Studio 2017 C# when I try to close() a file, I get an error on the file.close() code. The intelliscense for the StreamReader or StreamWriter
    has no listing for CLOSE. The closest I can get is disposing the file.

Thema:

Visual Studio Code Error: «Variable $workspaceFolder can not be resolved. Please open a…

  1. Visual Studio Code Error: «Variable $workspaceFolder can not be resolved. Please open a… — Similar Threads — Visual Studio Code

  2. Visual Studio Code and HTML

    in Windows 10 Gaming

    Visual Studio Code and HTML: I’ve been setting up Visual Studio Code for a while now.I’m down to attempting to get VS Code to open and execute HTML files.I found a way to do this after watching Tech Decode on YouTube.Google Chrome is installed in C:ProgramsGoogleChromeApplication. It executes without…
  3. visual studio code please help

    in Microsoft Windows 10 Store

    visual studio code please help: is there a way to create code if there is please tell me

    https://answers.microsoft.com/en-us/windows/forum/all/visual-studio-code-please-help/23137ebc-24cf-4b57-a8dc-f5a66fe1c0c3

  4. visual studio code please help

    in Windows 10 Gaming

    visual studio code please help: is there a way to create code if there is please tell me

    https://answers.microsoft.com/en-us/windows/forum/all/visual-studio-code-please-help/23137ebc-24cf-4b57-a8dc-f5a66fe1c0c3

  5. visual studio code please help

    in Windows 10 Software and Apps

    visual studio code please help: is there a way to create code if there is please tell me

    https://answers.microsoft.com/en-us/windows/forum/all/visual-studio-code-please-help/23137ebc-24cf-4b57-a8dc-f5a66fe1c0c3

  6. Visual Studio Code problem

    in Windows 10 Customization

    Visual Studio Code problem: I don’t even know how to ask this question, but what’s up with lines being crossed out and the word Music being there. How do I turn this off? If I right click it says «replace» or «dismiss». If I choose replace it puts the word Music in there. Why does it even think I want…
  7. Visual studio code error while installing

    in Windows 10 Software and Apps

    Visual studio code error while installing: i’m getting this error while trying to install vs code idk why this happens, lets see the photo[ATTACH]

    https://answers.microsoft.com/en-us/windows/forum/all/visual-studio-code-error-while-installing/4f2f0fce-292a-49ad-9054-7b096ee1d405

  8. Error in Visual Studio Code

    in Windows 10 Software and Apps

    Error in Visual Studio Code: I am getting this error. How can i fix it?

    Please help me..[ATTACH]

    https://answers.microsoft.com/en-us/windows/forum/all/error-in-visual-studio-code/db09fc5f-0f8c-4169-bdb2-5934428d5764

  9. Visual Studio Code

    in Windows 10 BSOD Crashes and Debugging

    Visual Studio Code: Does anyone know why VS code keeps looking like this when I move my cursor around? It also happens when I minimize it.

    [ATTACH]

    https://answers.microsoft.com/en-us/windows/forum/all/visual-studio-code/1ef1f542-31a9-4955-b1e6-de5d8347abe2

  10. visual studio code

    in Windows 10 Network and Sharing

    visual studio code: see this error in this main function is there but also the error shows I send u this screen shot

    tell me what is the problem[ATTACH]

    https://answers.microsoft.com/en-us/windows/forum/all/visual-studio-code/967d7874-6286-45e7-b899-b6a91312cffd»

Users found this page by searching for:

  1. Variable S(workspaceFolder) can not be resolved. Please open a folder.

    ,

  2. variable ${workspacefolder} can not be resolved. please open a folder

    ,

  3. visual code ошибка variable can not be resolved. please open a folder

    ,

  4. vsc variable workspacefolder


Windows 10 Forums

Понравилась статья? Поделить с друзьями:
  • Как найти прямые затраты производства
  • Как найти родственников для генеалогического древа
  • Как в ворде найти макросы
  • Как найти логово таракана
  • Как найти работу для бывших заключенных