| 492 | self.log_file = _loggers.get_log_directory() / "github-copilot-lsp.log" |
| 493 | |
| 494 | def validate_requirements(self) -> str | Literal[True]: |
| 495 | if not DependencyManager.which("node"): |
| 496 | return "node.js binary is missing. Install node at https://nodejs.org/." |
| 497 | |
| 498 | # Check Node.js version |
| 499 | try: |
| 500 | result = subprocess.run( |
| 501 | ["node", "--version"], |
| 502 | capture_output=True, |
| 503 | text=True, |
| 504 | timeout=5, |
| 505 | ) |
| 506 | if result.returncode == 0: |
| 507 | version_str = result.stdout.strip() |
| 508 | version_str = version_str.removeprefix( |
| 509 | "v" |
| 510 | ) # Remove 'v' prefix |
| 511 | |
| 512 | # Parse major version |
| 513 | major_version = int(version_str.split(".")[0]) |
| 514 | if major_version < 20: |
| 515 | return ( |
| 516 | f"Node.js version {version_str} is too old. " |
| 517 | "GitHub Copilot requires Node.js version 20 or higher. " |
| 518 | "Please upgrade at https://nodejs.org/." |
| 519 | ) |
| 520 | else: |
| 521 | # Fail open: If the node version check fails we don't want to not start the server. |
| 522 | # If it fails again, the user will be alerted again. |
| 523 | LOGGER.info( |
| 524 | "Failed to get Node.js version, stderr: %s", result.stderr |
| 525 | ) |
| 526 | except Exception as e: |
| 527 | # Fail open: If the node version check fails we don't want to not start the server. |
| 528 | # If it fails again, the user will be alerted again. |
| 529 | LOGGER.info("Failed to check Node.js version: %s", e) |
| 530 | |
| 531 | return True |
| 532 | |
| 533 | def _lsp_dir(self) -> Path: |
| 534 | lsp_dir = marimo_package_path() / "_lsp" |