Skip to content

fix: resolve relative path sources in --sandbox uv export#9052

Merged
dmadisetti merged 7 commits intomarimo-team:mainfrom
VishakBaddur:fix/sandbox-relative-path-sources
Apr 23, 2026
Merged

fix: resolve relative path sources in --sandbox uv export#9052
dmadisetti merged 7 commits intomarimo-team:mainfrom
VishakBaddur:fix/sandbox-relative-path-sources

Conversation

@VishakBaddur
Copy link
Copy Markdown
Contributor

Fixes #8980

Problem

marimo edit --sandbox fails when a script's inline metadata uses relative path sources in [tool.uv.sources]. uv export --script returns paths relative to the script file, but those lines get written to a temp requirements file. When uv run --with-requirements processes that file, it resolves paths relative to CWD - not the script's directory - causing path resolution failures.

Fix

In _uv_export_script_requirements_txt (marimo/_cli/sandbox.py), convert any relative paths (.-prefixed) to absolute paths using the script's parent directory as the base. Handles both editable (-e ../../) and non-editable (../../) path sources. Non-path deps and already-absolute paths are left unchanged.

Test

Added test_uv_export_script_requirements_txt_resolves_relative_paths covering:

  • Editable relative paths (-e ../../) → resolved to absolute
  • Non-editable relative paths (../other_pkg) → resolved to absolute
  • Regular deps (numpy==1.26.0) → unchanged
  • Already-absolute paths → unchanged

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Apr 22, 2026 9:36pm

Request Review

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 5, 2026

Bundle Report

Bundle size has no change ✅

Affected Assets, Files, and Routes:

view changes for bundle: marimo-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/dist-*.js 27 bytes 164 bytes 19.71% ⚠️
assets/dist-*.js -79 bytes 104 bytes -43.17%
assets/dist-*.js -39 bytes 137 bytes -22.16%
assets/dist-*.js 82 bytes 259 bytes 46.33% ⚠️
assets/dist-*.js -33 bytes 104 bytes -24.09%
assets/dist-*.js -174 bytes 102 bytes -63.04%
assets/dist-*.js 152 bytes 335 bytes 83.06% ⚠️
assets/dist-*.js -220 bytes 183 bytes -54.59%
assets/dist-*.js -119 bytes 137 bytes -46.48%
assets/dist-*.js -158 bytes 177 bytes -47.16%
assets/dist-*.js 299 bytes 403 bytes 287.5% ⚠️
assets/dist-*.js 79 bytes 183 bytes 75.96% ⚠️
assets/dist-*.js 96 bytes 256 bytes 60.0% ⚠️
assets/dist-*.js -218 bytes 169 bytes -56.33%
assets/dist-*.js 223 bytes 387 bytes 135.98% ⚠️
assets/dist-*.js 58 bytes 160 bytes 56.86% ⚠️
assets/dist-*.js 107 bytes 276 bytes 63.31% ⚠️
assets/dist-*.js -83 bytes 176 bytes -32.05%
assets/__vite-*.js 5 bytes 98 bytes 5.38% ⚠️
assets/__vite-*.js -5 bytes 93 bytes -5.1%

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes sandbox failures when uv export --script emits relative local path requirements by rewriting those paths to be absolute based on the script’s directory before writing the temp requirements file used by uv run --with-requirements.

Changes:

  • Resolve .-prefixed path requirement lines from uv export --script into absolute paths in the sandbox CLI.
  • Add a regression test covering editable and non-editable relative path lines as well as unchanged “normal” and already-absolute deps.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
marimo/_cli/sandbox.py Converts relative path lines from uv export --script output to absolute paths rooted at the script directory.
tests/_cli/test_sandbox.py Adds a unit test to ensure relative paths in exported requirements are resolved correctly.

Comment thread marimo/_cli/sandbox.py Outdated
Comment thread tests/_cli/test_sandbox.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread marimo/_cli/sandbox.py Outdated
dmadisetti
dmadisetti previously approved these changes Apr 21, 2026
Copy link
Copy Markdown
Collaborator

@dmadisetti dmadisetti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VishakBaddur Thanks! The helper function means we can test directly

@dmadisetti
Copy link
Copy Markdown
Collaborator

Thanks @VishakBaddur !

@dmadisetti dmadisetti merged commit ccc1841 into marimo-team:main Apr 23, 2026
45 checks passed
@github-actions
Copy link
Copy Markdown

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.3-dev37

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--sandbox fails for scripts with relative path sources in [tool.uv.sources]

5 participants