bummings
bummings

Reputation: 129

VS Code "Can not resolve workspace folder"

I've just started noticing something strange in VSCode 1.24.1 on MacOS 10.12.6 Sierra.

My file explorer has been marking my current working directories as "unresolved". This does not prevent me from doing anything I normally would though I am wondering why this is happening. The folder name will be yellow and will be marked with an ! on the right.

I've tried closing and reopening the directories in my file explorer, restarting VSCode itself and moving the folder to a separate directory. Nothing doing.

I haven't been able to find much on the issue except in the case of people working in Typescript files that aren't properly configured in a manifest file on React projects. These are mostly HTML/CSS/Sass/JS/MySQL.

Any insight would be appreciated, thank you.

Upvotes: 12

Views: 58034

Answers (6)

gdm
gdm

Reputation: 7930

Please, remember to check what you opened. I struggled for this very stupid error for a day. If you open VSCode, and then Open Folder, and then Add Folder, do not execpt theat ${workspaceFolder} will be you last folder, or the folder of your code. Its valeue will be the first folder you added...

Upvotes: 0

Thielicious
Thielicious

Reputation: 4442

I deleted the folder and created a new one with a different name and it was fixed. No workspace config file fix needed as it fixes/updates itself when you change folder structure and update projects.

Upvotes: 0

Mawardy
Mawardy

Reputation: 3818

In my case I resolved this by restarting the WSL machine by writing the following in the windows cmd

wsl --shutdown

take care this might stop running docker containers and other related processes.

Then I started a new wsl terminal and vscode worked like a charm.

Upvotes: 0

moudrick
moudrick

Reputation: 2336

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

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.

Upvotes: 3

Ralph
Ralph

Reputation: 131

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.

Upvotes: 6

Paul Cruz
Paul Cruz

Reputation: 11

I had this issue also with VS and also showing an exclamation mark as well as the error code you have said, my solution was to go into my work folder where my file was located and in that folder i right clicked and re-arranged the folder so it was showing them as application order and it got rid of the error code and exclamation mark.

Upvotes: 1

Related Questions