Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 19, 2025

This PR addresses the issue where users encounter cryptic errors when trying to run SageMath files without having SageMath properly installed or configured. The Chinese issue title "还是不能运行" translates to "Still can't run", indicating users were unable to execute SageMath code through the extension.

Problem

Previously, when users tried to run .sage files without SageMath installed, they would encounter:

  • Cryptic "command not found" errors in the terminal
  • No clear guidance on how to resolve the issue
  • Confusion about whether the problem was with the extension or their setup

Solution

This PR implements a comprehensive SageMath detection and user guidance system:

1. Proactive SageMath Detection

  • Added checkSageMathAvailability() function that verifies SageMath installation using which/where commands
  • Includes fallback verification with sage --version
  • Works across Windows, macOS, and Linux platforms

2. Enhanced Run Command Protection

  • Modified the "Run SageMath File" command to check for SageMath availability before execution
  • Prevents users from seeing cryptic terminal errors
  • Shows helpful error dialog with actionable next steps

3. User-Friendly Error Messages

When SageMath is not found, users now get a clear dialog with:

  • Installation Guide button that opens the official SageMath documentation
  • Configure Path button that opens VS Code settings for the interpreter path
  • Clear explanation of what's needed to resolve the issue

4. Activation Guidance

  • One-time informational message when the extension activates without SageMath detected
  • Allows users to dismiss the warning permanently via new sagemathEnhanced.dontShowSageWarning setting
  • Doesn't interfere with language server features that work without SageMath

5. Comprehensive Documentation

  • Added troubleshooting sections to both English and Chinese READMEs
  • Step-by-step guidance for common installation and configuration scenarios
  • Platform-specific installation paths and commands

Technical Implementation

  • Maintains backward compatibility with all existing functionality
  • Uses proper async/await patterns for system command execution
  • Graceful error handling with multiple fallback mechanisms
  • No impact on LSP features (completion, diagnostics, syntax highlighting)
  • Added comprehensive TypeScript typing

Testing

  • All existing LSP completion tests continue to pass
  • Code compiles without errors or warnings
  • Linting passes with no issues
  • Functionality works correctly with and without SageMath installed

The extension now provides a much better user experience by guiding users through SageMath installation and configuration instead of leaving them with unclear error messages.

Fixes #40.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits August 19, 2025 12:26
Co-authored-by: n-WN <30841158+n-WN@users.noreply.github.com>
Co-authored-by: n-WN <30841158+n-WN@users.noreply.github.com>
Co-authored-by: n-WN <30841158+n-WN@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] 还是不能运行 Fix "Still can't run" issue with SageMath installation detection and user guidance Aug 19, 2025
@Copilot Copilot AI requested a review from n-WN August 19, 2025 12:34
Copilot finished work on behalf of n-WN August 19, 2025 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants