Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 709
bummings Avatar asked Jun 22 '18 16:06

bummings


People also ask

How do I change the workspace folder in VS Code?

From the menu bar → File → Open Folder.... Navigate to where you want to put your folder and right click to open a new folder. Name it whatever you want, then click on "Select Folder". It will appear in the *Visual Studio Code explorer.

What is workspace folder in Visual Studio Code?

A Visual Studio Code "workspace" is the collection of one or more folders that are opened in a VS Code window (instance).

How do I clean my VS Code workspace?

Just Delete all the folders in the %userprofile%\AppData\Roaming\Code\User\workspaceStorage . You can also delete everything in (to make VS Code a little faster) : %userprofile%\AppData\Roaming\Code\User\Cache. %userprofile%\AppData\Roaming\Code\User\CacheData.

How do I create a workspace folder in Visual Studio Code?

Click the Setup Workspace on the status bar at the bottom of the VS Code IDE. Click New Folder. Enter a name for the folder in the Name of new Folder window. Click Create.


3 Answers

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.

like image 197
Ralph Avatar answered Oct 17 '22 22:10

Ralph


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.

like image 27
moudrick Avatar answered Oct 17 '22 21:10

moudrick


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.

like image 1
Paul Cruz Avatar answered Oct 17 '22 22:10

Paul Cruz