Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vscode-extension): improve console output when tsp-server not found #5428

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- typespec-vscode
---

improve console output when tsp-server not found
2 changes: 1 addition & 1 deletion packages/typespec-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"typespec.tsp-server.path": {
"type": "string",
"default": "",
"description": "Path to `tsp-server` command that runs the TypeSpec language server.\n\nIf not specified, then `tsp-server` found on PATH is used.\n\nExample (User): /usr/local/bin/tsp-server\nExample (Workspace): ${workspaceFolder}/node_modules/@typespec/compiler",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

` doesn't have markdown effect, so I change it back to traditional '.

"description": "Path to 'tsp-server' command that runs the TypeSpec language server. If not specified, then 'tsp-server' will be resolved in following sequence:\n\n1. from workspace node_modules folder\nExample: ${workspaceFolder}/node_modules/@typespec/compiler\n\n2. from PATH environment variable\nExample: /usr/local/bin/tsp-server",
"scope": "machine-overridable"
},
"typespec.initTemplatesUrls": {
Expand Down
12 changes: 9 additions & 3 deletions packages/typespec-vscode/src/tsp-executable-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function resolveTypeSpecServer(context: ExtensionContext): Promise<
options.env.NODE_OPTIONS = nodeOptions;
}

// In production, first try VS Code configuration, which allows a global machine
// In production, first try VS Code extension configuration, which allows a global machine
// location that is not on PATH, or a workspace-specific installation.
let serverPath: string | undefined = workspace.getConfiguration().get(SettingName.TspServerPath);
if (serverPath && typeof serverPath !== "string") {
Expand All @@ -74,13 +74,19 @@ export async function resolveTypeSpecServer(context: ExtensionContext): Promise<
// Default to tsp-server on PATH, which would come from `npm install -g
// @typespec/compiler` in a vanilla setup.
if (serverPath) {
logger.debug(`Server path loaded from VS Code configuration: ${serverPath}`);
logger.info(`Server path loaded from TypeSpec extension configuration: ${serverPath}`);
} else {
logger.info(
"Server path not configured in TypeSpec extension configuration, trying to resolve locally within current workspace.",
);
serverPath = await resolveLocalCompiler(workspaceFolder);
}

if (!serverPath) {
const executable = process.platform === "win32" ? "tsp-server.cmd" : "tsp-server";
logger.debug(`Can't resolve server path, try to use default value ${executable}.`);
logger.warning(
`Can't resolve server path from either TypeSpec extension configuration or workspace, try to use default value ${executable}.`,
);
return useShellInExec({ command: executable, args, options });
}
const variableResolver = new VSCodeVariableResolver({
Expand Down
Loading