Problem
The yaml.schemas setting requires absolute paths or URLs for local schema files. VS Code supports ${workspaceFolder} variable interpolation in many settings (e.g. launch.json, tasks.json, files.watcherExclude), but vscode-yaml does not resolve this variable. Users who work across machines (or share a committed .vscode/settings.json) must either hardcode an absolute path (breaks across machines) or use a schema registry URL (requires internet access).
Steps to Reproduce
- Create
.vscode/settings.json:
{
"yaml.schemas": {
"${workspaceFolder}/schemas/my-schema.json": "*.yaml"
}
}
- Open a
.yaml file in that workspace.
- No schema validation occurs; the Output → YAML channel shows:
Unable to load schema from ${workspaceFolder}/schemas/my-schema.json
Expected Behaviour
The extension should resolve VS Code variable substitutions (${workspaceFolder}, ${workspaceFolder:name} for multi-root) before passing the schema URI to the language server. VS Code exposes these via vscode.workspace.workspaceFolders and the vscode.commands.executeCommand('vscode.resolveWorkspaceSetting') path.
Workaround
Users can use a relative path like ./schemas/my-schema.json, but this is neither documented nor consistently resolved across all YAML files in sub-directories.
Proposed Fix
In the configuration-reading code, after reading the yaml.schemas map keys, run each key through a variable resolver:
function resolveVars(schemaPath: string, folder: vscode.WorkspaceFolder): string {
return schemaPath.replace(/${workspaceFolder}/g, folder.uri.fsPath);
}
Document the supported variables in the extension README and the package.json setting description.
Environment
- OS: Windows 11 + macOS (affects both — different absolute paths per machine)
- VS Code: 1.89+, shared
.vscode/settings.json in git
- Extension: redhat.vscode-yaml latest
Problem
The
yaml.schemassetting requires absolute paths or URLs for local schema files. VS Code supports${workspaceFolder}variable interpolation in many settings (e.g.launch.json,tasks.json,files.watcherExclude), but vscode-yaml does not resolve this variable. Users who work across machines (or share a committed.vscode/settings.json) must either hardcode an absolute path (breaks across machines) or use a schema registry URL (requires internet access).Steps to Reproduce
.vscode/settings.json:{ "yaml.schemas": { "${workspaceFolder}/schemas/my-schema.json": "*.yaml" } }.yamlfile in that workspace.Unable to load schema from ${workspaceFolder}/schemas/my-schema.jsonExpected Behaviour
The extension should resolve VS Code variable substitutions (
${workspaceFolder},${workspaceFolder:name}for multi-root) before passing the schema URI to the language server. VS Code exposes these viavscode.workspace.workspaceFoldersand thevscode.commands.executeCommand('vscode.resolveWorkspaceSetting')path.Workaround
Users can use a relative path like
./schemas/my-schema.json, but this is neither documented nor consistently resolved across all YAML files in sub-directories.Proposed Fix
In the configuration-reading code, after reading the
yaml.schemasmap keys, run each key through a variable resolver:Document the supported variables in the extension README and the
package.jsonsetting description.Environment
.vscode/settings.jsonin git