Skip to content

copy_in creates directory when destination is a file path #238

@yingjunwu

Description

@yingjunwu

Description

copy_in("/host/file.py", "/guest/file.py") creates a directory named file.py at the destination instead of copying the file. The user must use a directory destination with trailing slash: copy_in("/host/file.py", "/guest/").

Reproduction

import asyncio, os, boxlite

async def main():
    os.makedirs("/tmp/test_copy", exist_ok=True)
    with open("/tmp/test_copy/script.py", "w") as f:
        f.write("print('hello')\n")

    async with boxlite.SimpleBox(image="python:slim") as box:
        await box.exec("mkdir", "-p", "/workspace")
        
        # Copy file to file path (as documentation shows)
        await box.copy_in("/tmp/test_copy/script.py", "/workspace/script.py")
        
        result = await box.exec("ls", "-la", "/workspace/")
        print(result.stdout)
        # Shows: drwxr-xr-x 2 root root 4096 ... script.py  ← directory!

asyncio.run(main())

Expected

/workspace/script.py is a regular file containing the script content.

Actual

/workspace/script.py is a directory (tar extraction creates dir for the archive entry).

Workaround

Use a directory destination:

await box.copy_in("/tmp/test_copy/script.py", "/workspace/")
# Now /workspace/script.py is a file ✓

Environment

  • boxlite 0.5.10
  • macOS Apple Silicon

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