Skip to content

Conversation

@mishushakov
Copy link
Member

@mishushakov mishushakov commented May 14, 2025

Changelog:

Example:

import { Sandbox } from "@e2b/code-interpreter";

const sbx = await Sandbox.create({ debug: true });

const code = await sbx.runCode(`console.log(process.env.TEST);`, {
  language: "javascript",
  envs: { TEST: "hello" },
});

console.log(code.logs);

Before:

{
  stdout: [ "undefined\n" ],
  stderr: [],
}

After:

{
  stdout: [ "hello\n" ],
  stderr: [],
}

@linear
Copy link

linear bot commented May 14, 2025

@mishushakov mishushakov self-assigned this May 14, 2025
@mishushakov mishushakov added the improvement Improvement for current functionality label May 14, 2025
@mlejva
Copy link
Member

mlejva commented May 15, 2025

@mishushakov can you add tests for this case? it would be good to catch if setting env var breaks

@mishushakov
Copy link
Member Author

yes, these will be in a separate PR as otherwise we would be unable to merge this (the CI is using deployed template version)

Copy link
Member

@jakubno jakubno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are not setting global env vars for the default context. Can you try to create the context in lifespan in server instead of the startup script, so we can make in all cleaner?

Can you clean up 0001_envs.py from template? it shouldn't be used anymore

@mishushakov mishushakov requested a review from jakubno June 3, 2025 14:58
@mishushakov
Copy link
Member Author

Let's wait for #116 here

Copy link
Member

@jakubno jakubno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add tests to this PR? 🙏🏻

@mishushakov
Copy link
Member Author

I need to rewrite the tests. I don't know what went south last time, but they don't look correct to me.

@mishushakov
Copy link
Member Author

Env vars set during build:

Screenshot 2025-06-06 at 19 30 49

@jakubno
Copy link
Member

jakubno commented Jun 10, 2025

Env vars set during build:

I don't think this is correct, try this:A

from e2b_code_interpreter import Sandbox

sbx = Sandbox(envs={"TEST": "ABC"})
execution = sbx.run_code(
    """
import os
os.getenv("TEST")
"""
)
print(execution.results[0])

@mishushakov mishushakov requested a review from jakubno July 8, 2025 15:30
@jakubno jakubno merged commit 8511114 into main Jul 9, 2025
6 checks passed
@jakubno jakubno deleted the environment-variables-are-not-accessible-when-running-r-code-e2b-1977 branch July 9, 2025 11:43
mishushakov added a commit that referenced this pull request Jul 9, 2025
jakubno pushed a commit that referenced this pull request Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement for current functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Environment variables inaccessible in javascript/typescript Environment Variables are not Accessible when running R code in sandbox

4 participants