E2B icon indicating copy to clipboard operation
E2B copied to clipboard

Template build stuck at file copy

Open quincyqu opened this issue 1 month ago • 10 comments

Describe the bug I'm using python SDK building custom template with e2b cloud (free tier). It stuck at one step like for an hour:

[2025-11-08T07:40:59.120903+00:00] [info] CACHED [builder 46/66] COPY path/to/file /app/path/to/file   [...]

then error without much information:

... in wait_for_build_finish
    raise BuildException(build_status.reason or "Build failed")

e2b.template.exceptions.BuildException: BuildStatusReason(message='polling received unrecoverable error: rpc error: code = DeadlineExceeded desc = context deadline exceeded', step=<e2b.api.client.types.Unset object at 0x7fa2c88d3800>, additional_properties={})

Retry doesn't work. The error persisted with my current e2b cloud account and API key, it stuck on the exact same step almost every time (happens on other step as well).

Some other observations on caching for context: The template caching is enabled. I changed to use another account api key, the same code / template builds and upload successfully. Not sure if cacheing is the one to blame, but clearly changing account gets it a fresh start without caching. It builds slower but it succeeded.

And the question:

  • How does template caching work on e2b cloud?
  • A way to clear cache?

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Browser console output Console logs from your browser's developer tool console.

Terminal commands & output Commands you used to start the app and the terminal output.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

quincyqu avatar Nov 12 '25 01:11 quincyqu

ENG-3295

linear[bot] avatar Nov 12 '25 01:11 linear[bot]

Hey, thanks for reporting!

Can you give us some more information like template + build id from the logs? Feel free to do so in case you see a stuck build again.

mishushakov avatar Nov 12 '25 12:11 mishushakov

Hey, thanks for reporting!

Can you give us some more information like template + build id from the logs? Feel free to do so in case you see a stuck build again.

Sure. We hit this stuck issue almost every time. Here are some recent builds:

[2025-11-11T07:35:02.391821] [info] Template created with ID: 261q2v6u2c44bak2y8jq, Build ID: cc49cf48-a4de-49c0-97d1-21a5c83df13c [2025-11-13T01:26:21.870718] [info] Template created with ID: jpstgujd3ajx1arudolt, Build ID: 488d95c7-6fad-49a5-9f99-62b6544f6444

quincyqu avatar Nov 13 '25 07:11 quincyqu

Would you be able to share the template source code (files included)?

mishushakov avatar Nov 13 '25 15:11 mishushakov

Would you be able to share the template source code (files included)?

I'm afraid that's hard if not impossible. It's company project code that can't be shared publicly.

Nothing special with the template code, it's basically a translation from dockerfile to python script, like copy files, run commands including apt-get, pip install, npm etc. The template build DID succeeded a few times for new accounts.

quincyqu avatar Nov 14 '25 01:11 quincyqu

Okay thanks, we will investigate 👍

mishushakov avatar Nov 14 '25 14:11 mishushakov

I see a similar issue where the copying fails consistently with the error ERROR Build failed: error building step 8: failed to extract files: exit status 2. I've included the stack below. It happens both for the TemplateBuilder.copy and TemplateBuilder.copy_items

Here's my tempalte:

template = (
    Template()
    .from_base_image()  # Uses default Ubuntu base image
    .apt_install(["s3fs"])  # Install s3fs for S3 bucket mounting
    .set_envs(
        {
            "WORKSPACE": S3_MOUNT_PATH,
        }
    )
    .run_cmd("sudo apt-get update")
    .run_cmd(f"sudo apt-get install -y {' '.join(APT_PACKAGES)}")
    .run_cmd("sudo apt-get install -y python3 python3-pip python3-venv")
    .run_cmd(f"sudo pip3 install --no-cache-dir {' '.join(PYTHON_PACKAGES)}")
    # Copy excel-cli tool files to /home/user/excelx
    .run_cmd("mkdir -p /home/user/excelx")
    .copy_items(
        [
            {
                "src": "/Users/noorvir/code/excel-agent/excelx/cli.py",
                "dest": "/home/user/excelx/",
            },
            {"src": str(EXCELX_TOOLS_PATH), "dest": "/home/user/excelx/"},
        ]
    )
    # .copy(EXCELX_TOOLS_PATH, "/home/user/excelx/")
    # Create bash alias for excel-cli command
    .run_cmd(
        'echo "alias excel-cli=\\"python3 /home/user/excelx/cli.py\\"" >> /home/user/.bashrc'
    )
    # Setup workspace directory
    .run_cmd(f"sudo mkdir -p {S3_MOUNT_PATH}")
    .run_cmd(f"sudo chmod 755 {S3_MOUNT_PATH}")
    .run_cmd(f"sudo chown user:user {S3_MOUNT_PATH}")
    .run_cmd("sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/*")
)


(excel-agent) ➜  excel-agent git:(noorvir/sandbox) ✗ python -m sandbox.build_template
/Users/noorvir/code/excel-agent/excelx/cli.py
/Users/noorvir/code/excel-agent/excelx/tools.py
Building E2B template...
============================================================
0.0s  | 20:36:56 INFO  Requesting build for template: zauber-sandbox-dev
1.0s  | 20:36:57 INFO  Template created with ID: kbe9xjlngk7imvihmk55, Build ID: 
cb42dfc7-cd62-4423-94d4-7b59f0836c1a
1.1s  | 20:36:57 INFO  Skipping upload of '/Users/noorvir/code/excel-agent/excelx/cli.py', 
already cached
1.2s  | 20:36:57 INFO  Skipping upload of 
'/Users/noorvir/code/excel-agent/excelx/tools.py', already cached
1.2s  | 20:36:57 INFO  All file uploads completed
1.2s  | 20:36:57 INFO  Starting building...
1.6s  | 20:36:58 INFO  Waiting for logs...
1.8s  | 04:36:58 INFO  Building template 
kbe9xjlngk7imvihmk55/cb42dfc7-cd62-4423-94d4-7b59f0836c1a
5.2s  | 04:37:01 INFO  CACHED [base] FROM e2bdev/base 
[0756fa3c0f039e0998830d04b48c6c6a208f23472225a7c4c461c6a1e4b12a56]
5.2s  | 04:37:01 INFO  CACHED [base] DEFAULT USER user 
[49434a4e844bb0bffe413bc881e55470342c3d91477c6df09e272c8e6d56c8d5]
5.2s  | 04:37:01 INFO  CACHED [builder 1/14] RUN apt-get update && 
DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes apt-get install -y s3fs root 
[771cefd3cec09ef76f8698239884be8687e40dfa2a13c80f18e0e6894db8a0b4]
5.5s  | 04:37:01 INFO  CACHED [builder 2/14] ENV ZAUBER_WORKSPACE /home/zauber 
[999d426383c6f5a63b5e20ebc8acc98a37f28c405a9227f99a256bc45400b381]
5.5s  | 04:37:01 INFO  CACHED [builder 3/14] RUN sudo apt-get update 
[3e1361127c76e820bd67a0153a0a3cec05b0621e6c346632c857c644aabc985f]
5.5s  | 04:37:01 INFO  CACHED [builder 4/14] RUN sudo apt-get install -y jq yq xmlstarlet 
csvkit sqlite3 ripgrep fd-find bat silversearcher-ag zip unzip p7zip-full bzip2 xz-utils 
curl wget netcat-openbsd httpie tree file rename rsync git make vim nano htop tmux screen 
less [c77649c66034fdc2e121b045e24373f11efd42d009e61934169ee53425ac6119]
5.5s  | 04:37:01 INFO  CACHED [builder 5/14] RUN sudo apt-get install -y python3 
python3-pip python3-venv [27f6d754c3d03f84578fc79b6961f764e3a7569975ad0e23f44e00c31079760a]
5.7s  | 04:37:01 INFO  CACHED [builder 6/14] RUN sudo pip3 install --no-cache-dir pandas 
openpyxl xlrd python-magic openpyxl click 
[929e5cef423902eaac8ac349dd49db903ba4945ae5f9542c7a0945596d15f525]
5.7s  | 04:37:01 INFO  CACHED [builder 7/14] RUN mkdir -p /home/user/excelx 
[b78127bd518f9b9b008615cf674f107f6519cc299bd398be1637d65f244ac022]
5.7s  | 04:37:02 INFO  [builder 8/14] COPY /Users/noorvir/code/excel-agent/excelx/cli.py 
/home/user/excelx/   [d0e7207e1c74491a37374db2f4680ddfa2afb24792331ba79a174831a1aab9c3]
16.7s | 04:37:12 ERROR Build failed: error building step 8: failed to extract files: exit 
status 2
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/noorvir/code/excel-agent/sandbox/build_template.py", line 25, in <module>
    result = Template.build(
             ^^^^^^^^^^^^^^^
  File "/Users/noorvir/code/excel-agent/.venv/lib/python3.12/site-packages/e2b/template_sync/main.py", line 251, in build
    wait_for_build_finish(
  File "/Users/noorvir/code/excel-agent/.venv/lib/python3.12/site-packages/e2b/template_sync/build_api.py", line 191, in wait_for_build_finish
    raise BuildException(
  File "/Users/noorvir/code/excel-agent/sandbox/template.py", line 77, in <module>
    .copy_items(
     ^^^^^^^^^^^
e2b.exceptions.BuildException: failed to extract files: exit status 2

noorvir avatar Nov 14 '25 17:11 noorvir

@noorvir can you try with relative file path?

mishushakov avatar Nov 14 '25 18:11 mishushakov

I tried all these combinations. Still doesn't work. Is there some way I can see a more detailed error log? Hard to debug with the failed to extract files error.

{"src": "/Users/noorvir/code/excel-agent/requirements.txt", "dest": "/"},
{"src": "/Users/noorvir/code/excel-agent/excelx/tools.py", "dest": "/"},
{"src": "../excelx/tools.py", "dest": "/"},
{"src": "../excelx/tools.py", "dest": "/home/user/excelx/"},
{"src": "../excelx/tools.py", "dest": "excelx/"},

noorvir avatar Nov 14 '25 22:11 noorvir

I think the error is on the backend, my colleague will be looking at it 👍

mishushakov avatar Nov 14 '25 23:11 mishushakov

Related issue reported: https://github.com/e2b-dev/E2B/issues/1028

The E2B Template SDK's .copy() method consistently fails with "exit status 2" when attempting to copy .tgz (tarball) files to the template during build. This prevents installation of npm packages from local tarballs, forcing reliance on external registries.

Error Message Build failed: error building step 12: failed to extract files: exit status 2 Expected Behavior The .copy() method should successfully copy .tgz files to the template filesystem, allowing subsequent installation via npm install -g /path/to/package.tgz.

Actual Behavior .copy() fails immediately when source file is a .tgz archive Error occurs during template build phase Same .tgz files work correctly when manually transferred or base64-encoded

khalid-halo avatar Nov 18 '25 02:11 khalid-halo