A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: copilot path (#5063)
Myles Scolnick3a86451ab825
diff --git a/.github/workflows/test_cli.yaml b/.github/workflows/test_cli.yamlindex 7b23f72ece..fa22cd55d7 100644--- a/.github/workflows/test_cli.yaml+++ b/.github/workflows/test_cli.yaml@@ -87,20 +87,7 @@ jobs:done- name: Run LSP binary- run: |- node marimo/_lsp/index.cjs --port 3000 &- LSP_PID=$!- sleep 3- if ! kill $LSP_PID; then- echo "Failed to kill LSP binary"- exit 1- fi- if ! wait $LSP_PID 2>/dev/null; then- echo "LSP binary exited with error"- exit 1- fi- echo "LSP binary started and killed successfully"-+ run: ./scripts/test-lsp.sh- name: Upload wheeluses: actions/upload-artifact@v4with:diff --git a/lsp/index.ts b/lsp/index.tsindex f913d3018a..35d2a26d5a 100644--- a/lsp/index.ts+++ b/lsp/index.ts@@ -6,6 +6,7 @@ import type * as rpc from "@sourcegraph/vscode-ws-jsonrpc";import * as rpcServer from "@sourcegraph/vscode-ws-jsonrpc/lib/server";import path from "node:path";import fs from "node:fs/promises";+import fsSync from "node:fs";const LOG_FILE = path.join(process.env.XDG_CACHE_HOME || path.join(process.env.HOME || "", ".cache"),@@ -43,18 +44,28 @@ const Logger = {};// Adapted from https://github.com/wylieconlon/jsonrpc-ws-proxy+const COPILOT_LSP_PATH = path.join(+ __dirname,+ "copilot",+ "dist",+ "language-server.js",+);+if (!fsSync.existsSync(COPILOT_LSP_PATH)) {+ Logger.error("Compilation artifact does not exist. Exiting.");+ process.exit(1);+}const argv = parseArgs(process.argv.slice(2));if (argv.help) {- console.log("Usage: index.js --port 3000");- process.exit(1);+ Logger.log("Usage: index.js --port 3000");+ process.exit(0);}const serverPort: number = Number.parseInt(argv.port) || 3000;const languageServers: Record<string, string[]> = {- copilot: ["node", path.join(__dirname, "language-server.js"), "--stdio"],+ copilot: ["node", COPILOT_LSP_PATH, "--stdio"],};function toSocket(webSocket: ws): rpc.IWebSocket {@@ -102,6 +113,15 @@ function toSocket(webSocket: ws): rpc.IWebSocket {};}+async function verifyCopilotLSP() {+ if (!fsSync.existsSync(COPILOT_LSP_PATH)) {+ Logger.error(+ `Copilot LSP not found at ${COPILOT_LSP_PATH}. Likely a build error or missing dependencies.`,+ );+ process.exit(1);+ }+}+// Add error handling for WebSocket server creationtry {const wss = new WebSocketServer(@@ -121,6 +141,8 @@ try {wss.on("connection", (client: ws, request: http.IncomingMessage) => {Logger.log(`New connection from ${request.socket.remoteAddress}`);+ void verifyCopilotLSP();+let langServer: string[] | undefined;Object.keys(languageServers).forEach((key) => {diff --git a/scripts/buildlsp.sh b/scripts/buildlsp.shindex e70ac5c0ab..ad4be529d9 100755--- a/scripts/buildlsp.sh+++ b/scripts/buildlsp.sh@@ -5,8 +5,15 @@ if pnpm build; thenecho "Removing old lsp files..."rm -rf ../marimo/_lsp/echo "Copying new lsp files..."- mkdir -p ../marimo/_lsp/- cp -R dist/* ../marimo/_lsp/+ mkdir ../marimo/_lsp+ cp dist/index.cjs ../marimo/_lsp/+ # There seems to be a discrepancy between CI and mac for pnpm builds+ if [ -d dist/copilot ]; then+ cp -R dist/copilot ../marimo/_lsp/copilot+ else+ mkdir ../marimo/_lsp+ cp -R dist ../marimo/_lsp/copilot+ fiecho "Compilation succeeded.\n"elseecho "LSP compilation failed.\n"diff --git a/scripts/test-lsp.sh b/scripts/test-lsp.shnew file mode 100755index 0000000000..e5e06fde77--- /dev/null+++ b/scripts/test-lsp.sh@@ -0,0 +1,10 @@+#!/usr/bin/env bash+node marimo/_lsp/index.cjs --help > /dev/null+if [ $? -ne 0 ]; then+ echo "LSP binary failed to start"+ # List out contents of the directory+ tree marimo/_lsp+ tree lsp/dist+ exit 1+fi+echo "LSP binary started successfully"