Inline script metadata when using an URL instead of filepath
Describe the bug
Hi Marimo team,
The inline script metadata is not used when using an URL (e.g. https://raw.githubusercontent.com/gerritjandebruin/marimo-test/refs/heads/main/test_nb.py ) instead of a 'normal' filepath.
E.g. when cloning gerritjandebruin/marimo-test the following commands runs OK:
uvx marimo edit test_nb.py
But this one does not:
uvx marimo edit https://raw.githubusercontent.com/gerritjandebruin/marimo-test/refs/heads/main/test_nb.py --sandbox
Will you submit a PR?
- [ ] Yes
Environment
Code to reproduce
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "pandas",
# ]
# ///
import marimo
__generated_with = "0.14.16"
app = marimo.App()
@app.cell
def _():
import pandas as pd
return (pd,)
@app.cell
def _(pd):
pd.Series([0, 1, 2])
return
@app.cell
def _():
return
if __name__ == "__main__":
app.run()
Hi there, I'm looking into this now. It's surprising—the inline script metadata should be respected when loading from a URL. Did you generate the original file using marimo or uv?
I downloaded the original script and created a Gist for reproducibility:
curl https://raw.githubusercontent.com/gerritjandebruin/marimo-test/refs/heads/main/test_nb.py > broken.py
cp broken.py working.py
sed -i '1,6d' working.py # remove previous script metadata
uv add --script working.py pandas
gh gist create broken.py working.py
Here’s the Gist: https://gist.github.com/manzt/17ad56771acf97bfdcf6089bd7098f2e. The cleaned version is working as expected, but yes your original is failing. I am not quite sure why.
For future bug reports related to this feature, please include a GitHub link (github.com) or Gist (gist.github.com) instead of (or in additional to) the raw API endpoint. When I investigated this originally, I was a little nervous the URL was spoofed and potentially would run something malicious.
Update: I'm pretty sure this is a challenge with windows.
Hi!
Many thanks for the solution! Indeed, I used marimo to convert an existing py-script and then added the dependencies using uv on a Windows device.
I was not entirely sure whether the Github/ Gist would work directly, hence the copying of the raw endpoint. I could not find it in the documentation at places where I would expect such usage (e.g. https://docs.marimo.io/guides/publishing/from_github/, https://docs.marimo.io/api/cli_args/ or https://docs.marimo.io/guides/publishing/playground/) But will do any next time and I understand the bit weird URL is making nervous.
I can confirm it works now as expected (also under Windows):
uvx --from git+https://github.com/marimo-team/marimo@5cf7424 marimo edit https://raw.githubusercontent.com/gerritjandebruin/marimo-test/refs/heads/main /test_nb.py --sandbox
Many thanks again!