marimo icon indicating copy to clipboard operation
marimo copied to clipboard

Inline script metadata when using an URL instead of filepath

Open gerritjandebruin opened this issue 1 year ago • 3 comments

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

Image

Will you submit a PR?

  • [ ] Yes

Environment

When using WSL: ``` { "marimo": "0.14.16", "editable": false, "OS": "Linux", "OS Version": "5.15.167.4-microsoft-standard-WSL2", "Processor": "x86_64", "Python Version": "3.13.5", "Binaries": { "Browser": "--", "Node": "--" }, "Dependencies": { "click": "8.2.1", "docutils": "0.22", "itsdangerous": "2.2.0", "jedi": "0.19.2", "markdown": "3.8.2", "narwhals": "2.0.1", "packaging": "25.0", "psutil": "7.0.0", "pygments": "2.19.2", "pymdown-extensions": "10.16.1", "pyyaml": "6.0.2", "starlette": "0.47.2", "tomlkit": "0.13.3", "typing-extensions": "missing", "uvicorn": "0.35.0", "websockets": "15.0.1" }, "Optional Dependencies": { "loro": "1.5.3" }, "Experimental Flags": {} } ``` Same problem also in Powershell.

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()

gerritjandebruin avatar Aug 05 '25 07:08 gerritjandebruin

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.

manzt avatar Aug 05 '25 17:08 manzt

Update: I'm pretty sure this is a challenge with windows.

manzt avatar Aug 05 '25 17:08 manzt

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!

gerritjandebruin avatar Aug 06 '25 12:08 gerritjandebruin