Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The terminal can't execute the "cd xxx" command #442

Open
XitaoLi opened this issue Sep 18, 2024 · 2 comments
Open

The terminal can't execute the "cd xxx" command #442

XitaoLi opened this issue Sep 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@XitaoLi
Copy link

XitaoLi commented Sep 18, 2024

Describe the bug
I want to test if the E2B sandbox executes all commands well, as it's required for LLM Agent to do anything, but some issues appear:

  1. the cd command doesn't work. This may be caused by the fixed parameter "cmd" in the initialization of TerminalManager
  2. the terminal also can't set the environment variables,

To Reproduce
Steps to reproduce the behavior:

    sandbox = Sandbox()
    while True:
        cmd = input("Enter command: ")
        if cmd == "exit":
            break
        proc = sandbox.terminal.start(lambda data: print(data), 1, 1, cwd="/home/user", cmd=cmd)
        proc.wait()

Expected behavior
E2B terminal works as the real terminal.

Terminal commands & output

Enter command: ls
java
jdk-11.0.2
jdk-11.0.2_linux-x64_bin.tar.gz

Enter command: cd java
Enter command: ls -a
.
..
.bash_logout
.bashrc
.profile
.sudo_as_admin_successful
java
jdk-11.0.2
jdk-11.0.2_linux-x64_bin.tar.gz

Enter command: export TEST=1        
Enter command: echo $TEST


Enter command: 

Desktop:

  • OS: Ubuntu18

Any feedback will be helpful.

@XitaoLi XitaoLi added the bug Something isn't working label Sep 18, 2024
@ValentaTomas
Copy link
Member

Hey @XitaoLi , we recommend using the Beta SDK (https://e2b.dev/docs/guide/beta-migration) — it has module for terminal (pty) that should work more clearly.

Here is the implementation (https://github.com/e2b-dev/E2B/blob/beta/packages/python-sdk/e2b/sandbox_sync/pty/main.py) and here is an analogous usage in our CLI (in TypeScript) (https://github.com/e2b-dev/E2B/blob/beta/packages/cli/src/terminal.ts#L12).

If you want just to execute a command, the sandbox.process.start_and_wait (or sandbox.commands.run in Beta SDK) might be a better solution here — the terminal/pty is made to be connected to an actual terminal emulator, outputting all the colored output and taking into account things like terminal size, which might not be relevant for you.

@XitaoLi
Copy link
Author

XitaoLi commented Sep 19, 2024

@ValentaTomas Thanks for your quick response. I have tried the commands.run method in the latest version, similar to sandbox.process. It still can't change the working directory flexibly according to the cd command.

Any other suggestions for connecting an actual terminal emulator using E2B? It's essential for LLM Agnets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants