Skip to content

CodeBox.run_script() reads from host filesystem, not from inside VM #235

@yingjunwu

Description

@yingjunwu

Description

run_script(path) reads the script file from the host filesystem, not from inside the VM. This is counter-intuitive and undocumented — the docs show a pattern of creating a file inside the VM and then running it with run_script(), which fails.

Reproduction

import asyncio
import boxlite

async def main():
    async with boxlite.CodeBox() as codebox:
        # Create a script inside the VM
        await codebox.run("""
with open('/tmp/analysis.py', 'w') as f:
    f.write('import json\\nprint(json.dumps({"status": "ok"}))\\n')
""")
        # Try to run the script from VM path
        result = await codebox.run_script("/tmp/analysis.py")
        print(result)

asyncio.run(main())

Expected

run_script("/tmp/analysis.py") runs the script that was created inside the VM.

Actual

FileNotFoundError: [Errno 2] No such file or directory: '/tmp/analysis.py'

The error occurs on the host side, confirming run_script() tries to read from host filesystem.

Environment

  • boxlite 0.5.10
  • macOS Apple Silicon
  • Python 3.12

Suggested fix

Either:

  1. Make run_script() read from inside the VM (consistent with the name), or
  2. Clearly document that run_script() reads from the host and sends content to the VM for execution

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions