{"record":{"id":"3e818488ee8942a1","repo":"charmbracelet/crush","slug":"failed-to-create-lsp-client-w","errorCode":null,"errorMessage":"failed to create lsp client: %w","messagePattern":"failed to create lsp client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/lsp/client.go","lineNumber":223,"sourceCode":"\n\tclientConfig := powernap.ClientConfig{\n\t\tCommand:     home.Long(command),\n\t\tArgs:        args,\n\t\tRootURI:     rootURI,\n\t\tEnvironment: envs,\n\t\tSettings:    c.config.Options,\n\t\tInitOptions: c.config.InitOptions,\n\t\tWorkspaceFolders: []protocol.WorkspaceFolder{\n\t\t\t{\n\t\t\t\tURI:  rootURI,\n\t\t\t\tName: filepath.Base(c.cwd),\n\t\t\t},\n\t\t},\n\t}\n\n\tpowernapClient, err := powernap.NewClient(clientConfig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create lsp client: %w\", err)\n\t}\n\n\tc.client = powernapClient\n\treturn nil\n}\n\n// registerHandlers registers the standard LSP notification and request handlers.\nfunc (c *Client) registerHandlers() {\n\tc.RegisterServerRequestHandler(\"workspace/applyEdit\", HandleApplyEdit(c.client.GetOffsetEncoding()))\n\tc.RegisterServerRequestHandler(\"workspace/configuration\", HandleWorkspaceConfiguration)\n\tc.RegisterServerRequestHandler(\"client/registerCapability\", HandleRegisterCapability)\n\tc.RegisterServerRequestHandler(\"window/workDoneProgress/create\", HandleWorkDoneProgressCreate)\n\tc.RegisterNotificationHandler(\"window/showMessage\", func(ctx context.Context, method string, params json.RawMessage) {\n\t\tif c.debug {\n\t\t\tHandleServerMessage(ctx, method, params)\n\t\t}\n\t})\n\tc.RegisterNotificationHandler(\"textDocument/publishDiagnostics\", func(_ context.Context, _ string, params json.RawMessage) {","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/lsp/client.go#L205-L241","documentation":"Once command, args, and env are resolved, createPowernapClient builds a powernap.ClientConfig and calls powernap.NewClient. If that constructor fails, the error is wrapped as \"failed to create lsp client\". This typically means the underlying client could not be constructed (e.g. invalid combination of transport/command options) and the LSP server process was never started.","triggerScenarios":"Calling New or Restart where powernap.NewClient(clientConfig) returns an error — e.g. the resolved command is not an executable binary on PATH, or the client config is structurally invalid for the transport.","commonSituations":"LSP server binary not installed or not on PATH in the runtime environment (works locally, fails in CI/container); command lacks execute permission; incompatible powernap client options after a version change.","solutions":["Verify the resolved LSP command exists and is executable: `which <command>` / `command -v <command>`.","Install the LSP server or add its directory to PATH in the environment crush runs in.","Check file permissions on the server binary (chmod +x).","Run the command manually with the resolved args to confirm it can start.","Confirm powernap client config fields (Command, Args, RootURI) are valid for the transport."],"exampleFix":"// before\ncommand = \"gopls\" // not installed\n\n// after\n// go install golang.org/x/tools/gopls@latest\ncommand = \"gopls\"","handlingStrategy":"try-catch","validationCode":"cmd, _ := resolver.ResolveValue(lspCfg.Command)\nif _, err := exec.LookPath(cmd); err != nil {\n    return fmt.Errorf(\"lsp server %q is not installed or not executable\", cmd)\n}","typeGuard":"func serverBinaryAvailable(cfg LSPConfig, r Resolver) bool {\n    cmd, err := r.ResolveValue(cfg.Command)\n    if err != nil {\n        return false\n    }\n    _, err = exec.LookPath(cmd)\n    return err == nil\n}","tryCatchPattern":"client, err := lsp.New(cfg)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to create lsp client\") {\n        slog.Error(\"Could not start LSP server; check it is installed and on PATH\", \"error\", err)\n        return nil // degrade gracefully; LSP features disabled\n    }\n    return err\n}","preventionTips":["Document required LSP binaries and install them in provisioning scripts/containers.","Check binary availability at startup and warn instead of hard-failing.","Pin server versions to avoid surprises after upstream releases."],"tags":["lsp","process-spawn","client-creation"],"backgroundTag":"lsp-server-start-failed","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}