Skip to content

Fix GitHub Codespaces setup - #42596

Open
cxzhong wants to merge 3 commits into
sagemath:developfrom
cxzhong:fix-42201
Open

Fix GitHub Codespaces setup#42596
cxzhong wants to merge 3 commits into
sagemath:developfrom
cxzhong:fix-42201

Conversation

@cxzhong

@cxzhong cxzhong commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a dedicated Codespaces configuration that installs the prebuilt conda-forge Sage package in an activated environment
  • make the default contributor container refresh its Conda environment and editable build when repository content or a prebuild changes
  • move the contributor container from the legacy Bullseye image to the official Debian Trixie image required by the generated Conda lock
  • expose provisioning and Ninja failures instead of swallowing them, and select the correct terminal and VS Code Python environment
  • update the downstream conda-forge configuration from retired Mambaforge to Miniforge and remove the retired Gitpod badge

Root cause

The default container performed dependency setup and the editable install only in onCreateCommand, which runs once when a prebuild is created. Setup failures were hidden by || true, and later terminals stayed in Conda's base environment. A reused stale prebuild could therefore combine an old Python environment and Meson build directory with a newer Sage checkout, producing the Python 3.11/Ninja failure reported in #42201.

A live Codespaces launch also exposed a second incompatibility: the old Debian Bullseye base provides glibc 2.31, while the generated Linux lock pins sysroot_linux-64=2.39, whose package metadata requires __glibc >=2.39. The contributor configuration now uses the official major-pinned Debian Trixie image, which provides glibc 2.41 while preserving the vscode user and Debian-based setup.

The new updateContentCommand hashes the complete Conda lock, detects a mismatched Python environment, frees generated Meson builds and caches before Conda transactions, synchronizes dependencies, reinstalls Sage editable, runs pip check, and forces a real Sage smoke test before recording success.

The README now uses a separate Miniforge configuration for users who want prebuilt Sage rather than a contributor source build.

Validation

  • live Codespaces launch reached the fail-fast updateContentCommand and reproduced the Bullseye/glibc incompatibility
  • exact sysroot_linux-64=2.39=hc4b9eeb_6 dry-run solve fails with a simulated glibc 2.31 and succeeds with glibc 2.39
  • complete environment-3.12-linux.yml dry-run solve succeeds with Trixie's glibc 2.41
  • the mcr.microsoft.com/devcontainers/base:2-trixie manifest exists for amd64 and arm64
  • @devcontainers/cli@0.83.3 read-configuration (the Codespaces log version) parses the updated contributor configuration
  • sh -n and bash -n for all lifecycle hooks
  • @devcontainers/cli@0.86.0 read-configuration for the default, downstream, and dedicated Codespaces configurations
  • controlled lifecycle checks for fresh creation, an unchanged rerun, a changed lock, and recovery from a stale Python 3.11 environment
  • verified stale generated builds are removed before environment replacement
  • sage -c 'assert ZZ(2) + ZZ(2) == 4'
  • git diff --check

The PR remains a draft pending one fresh live Codespaces rebuild on the Trixie image.

Fixes #42201

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown

Documentation preview for this PR (built with commit 8def099; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@cxzhong
cxzhong requested a review from soehms July 29, 2026 15:17
@cxzhong

cxzhong commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Could you help me verify this? @soehms

@cxzhong

cxzhong commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

I have verified this works in codespace.

@cxzhong
cxzhong marked this pull request as ready for review July 29, 2026 17:20
@soehms

soehms commented Aug 3, 2026

Copy link
Copy Markdown
Member

Could you help me verify this? @soehms

I ran a test using the link from the README.md:

codespace_fix_42201a

Is the following expected behavior?

codespace_fix_42201b

However, after accepting the blue button, I was able to start and use Sage in the GH-Codespace:

(sage-dev) @soehms ➜ /workspaces/sage (fix-42201) $ sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.10.beta7, Release Date: 2026-07-26             │
│ Using Python 3.12.13. Type "help()" for help.                      │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Ctrl click to launch VS Code Native REPL
sage: KnotInfo.L6a1_0.inject()
Defining L6a1_0
sage: L6a1_0.kauffman_polynomial()
a^5*z^3 + a^4*z^4 + a^3*z^5 - 2*a^5*z + 3*a^2*z^4 + a*z^5 + a^5*z^-1 - a^4 - a^3*z - 3*a^2*z^2 + 2*z^4 + a^3*z^-1 - 3*z^2 + a^-1*z^3 - a^-1*z

But I'm probably not the right person to review the code, since I'm not familiar with devcontainer.json files. @tobiasdiez , could you take a look at this?

@cxzhong

cxzhong commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GH Codespaces is broken (at least when launched by default via the README.md)

2 participants