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

[Bug]: Gets stuck while trying to activate virtual environment #2799

Closed
2 tasks done
anjor opened this issue Jul 4, 2024 · 22 comments
Closed
2 tasks done

[Bug]: Gets stuck while trying to activate virtual environment #2799

anjor opened this issue Jul 4, 2024 · 22 comments
Labels
bug Something isn't working severity:critical Critical issues or affecting all users Stale Inactive for 30 days

Comments

@anjor
Copy link

anjor commented Jul 4, 2024

Is there an existing issue for the same bug?

Describe the bug

OpenDevin gets stuck while trying to activate an existing virtual environment.

OpenDevin often wants to install packages to be able to test locally. I would prefer it to use a virtual environment, so I usually ask it to activate the virtual environment. And I have consistently seen it get stuck:

==============
CodeActAgent LEVEL 0 STEP 1

19:55:20 - opendevin:INFO: llm.py:239 - Cost: 0.02 USD | Accumulated Cost: 0.04 USD
19:55:20 - ACTION
**CmdRunAction**
THOUGHT: Great! Now, let's activate the Python virtual environment stored in `.venv`.
COMMAND:
source .venv/bin/activate

Current OpenDevin version

ghcr.io/opendevin/opendevin:0.7

Installation and Configuration

WORKSPACE_BASE=$(pwd)/workspace
docker run -it \
    --pull=always \
    -e SANDBOX_USER_ID=$(id -u) \
    -e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \
    -v $WORKSPACE_BASE:/opt/workspace_base \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -p 3000:3000 \
    --add-host host.docker.internal:host-gateway \
    --name opendevin-app-$(date +%Y%m%d%H%M%S) \
    ghcr.io/opendevin/opendevin:0.7

Vanilla configuration using default gpt-4o and my api key.



### Model and Agent

- Model: gpt-4o
- Agent: CodeActAgent

### Operating System

Mac OS

### Reproduction Steps

1. set up a python virtual environment in the workspace
2. Ask OpenDevin to activate the virtual environment
3. It should try to execute the command but then get stuck.

### Logs, Errors, Screenshots, and Additional Context

_No response_
@anjor anjor added the bug Something isn't working label Jul 4, 2024
@tobitege
Copy link
Collaborator

tobitege commented Jul 4, 2024

If you'd run the command manually, check what interactive prompt messages you get.
Not sure, if you could ask the LLM to use sudo?

@anjor
Copy link
Author

anjor commented Jul 4, 2024

When I do it from the opendevin terminal, It get's stuck the same way with nothing in the logs.

If I do it from just the native mac terminal it works.

@amosk
Copy link

amosk commented Jul 4, 2024

Same issue. I create a new project and it gets stuck trying to activate the environment. Apple M1, Docker Desktop w/ 26.1.4.

image

Terminal:
image

Workspace directory: workspace directory: /Users/amosk/opendevin

Started with

~ % docker run -it \
    --pull=always \
    -e SANDBOX_USER_ID=$(id -u) \
    -e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \
    -v $WORKSPACE_BASE:/opt/workspace_base \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -p 3000:3000 \
    --add-host host.docker.internal:host-gateway \
    --name opendevin-app-$(date +%Y%m%d%H%M%S) \
    ghcr.io/opendevin/opendevin:0.7

@tobitege
Copy link
Collaborator

tobitege commented Jul 4, 2024

OpenDevin is using miniforge3, that might be the reason. 🤔
@Shimada666 wdyt?

@anjor
Copy link
Author

anjor commented Jul 4, 2024

Is there any way to get more logs? How do I switch on debug logging?

@Faultyskullslayer
Copy link

Hope some expert comes in here with a solution this really needs to be fixed makes doing certain things pointless.

@mamoodi mamoodi added the severity:critical Critical issues or affecting all users label Jul 5, 2024
@mamoodi
Copy link
Collaborator

mamoodi commented Jul 5, 2024

I'll try to ping some people to take a look at this ASAP.

@Faultyskullslayer
Copy link

344762419-25541142-7f25-4645-895f-1b59e3ff577b
Dropping a screenshot here as well of the issue

@iFurySt
Copy link
Collaborator

iFurySt commented Jul 5, 2024

It may be that the virtual environment changes the shell prompt. My first thought is that the prompt in the shell is being modified, which prevents the proper detection of command completion, similar to the following:

➜  ~
(base) ➜  ~

However, I'm not 100% sure if this is the issue.

@anjor
Copy link
Author

anjor commented Jul 5, 2024

Oh yes. I have a oh-my-zsh setup that shows the current branch. So the prompt does in fact change!

@xingyaoww
Copy link
Collaborator

xingyaoww commented Jul 5, 2024

It may be that the virtual environment changes the shell prompt.

@iFurySt Yes - I think this is the root cause! So right now the prompt change would break pxssh's parsing logic, which would be hard to fix temporarily. A workaround we used was to set conda config --set changeps1 False before everything starts (https://github.com/OpenDevin/OpenDevin/blob/038e8f8caa3c2f5bedfd2a2d62cedf8fb309cad1/containers/sandbox/Dockerfile#L38), the it will not change the PS1 prompt hence not breaking it.

But it is not perfect, since ideally the agent should know what environment it is dealing with. The slightly long-term plan was to completely replace pxssh with pexcept in the architecture refractor (#2404) and write these parsing logic ourselves to try to address this completely 😢 (but this could take a while).

@anjor
Copy link
Author

anjor commented Jul 6, 2024

@xingyaoww is there an equivalent temporary workaround for virtualenv? Right now this is the main blocker for me.

@Shimada666
Copy link
Contributor

@anjor

Hi anjor. We are working to make the opendevin Python runtime completely transparent to users. Once this PR #2796 is merged, the default Python will point to a clean python environment /usr/bin/python instead of the current opendevin python runtime /opendevin/miniforge3/bin/python. You will then be able to use the default python interpretor /usr/bin/python to install dependencies instead of a virtual environment. Maybe this can solve your problem.

@anjor
Copy link
Author

anjor commented Jul 6, 2024

Sorry maybe I am misunderstanding. I don't want to use the default interpreter. I would prefer to have a virtualenv per project.

Or does opendevin maintain it's own sandbox anyway?

@Shimada666
Copy link
Contributor

@anjor
Maybe you can run each project in a different opendevin container? One container for each of your projects. This way, you won't need to use virtual environments.

@anjor
Copy link
Author

anjor commented Jul 6, 2024

Yeah that will work. Thanks!

@mamoodi
Copy link
Collaborator

mamoodi commented Jul 10, 2024

@xingyaoww just so I understand this for future. Is this an issue we want to tackle and one that should stay open?

@xingyaoww
Copy link
Collaborator

@mamoodi Yes! This is among the first batch of issues we want to address after the architecture refractor.

Copy link
Contributor

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale Inactive for 30 days label Aug 13, 2024
@xingyaoww xingyaoww removed the Stale Inactive for 30 days label Aug 13, 2024
@ywatanabe1989
Copy link

I attempted to run init.sh as follows. However, CUDA was not installed due to an interruption, likely caused by a timeout (43 seconds).

./workspace/requirements.txt

matplotlib
numpy
pandas
pytest
scikit-learn
scipy
torch

./workspace/init.sh

#!/bin/bash
# /workspace/init.sh

# Store original directory
ORIG_DIR=$PWD
cd /workspace

# Display user and home directory
echo $USER
echo $HOME

# Create and setup virtual environment
/opendevin/miniforge3/bin/python -m venv /home/opendevin/env
sudo chmod 7777 /home/opendevin
export VIRTUAL_ENV_DISABLE_PROMPT=1
source /home/opendevin/env/bin/activate

# Check Python and pip locations
which python
which pip

# Update pip and install requirements
pip install -U pip

if [ -f "requirements.txt" ]; then
    echo "requirements.txt found in /workspace"
    pip install -r requirements.txt 2>&1
else
    echo "requirements.txt not found in /workspace"
fi

pip freeze

# Return to original directory
cd $ORIG_DIR

# EOF

Standard Output

Downloading torch-2.4.0-cp310-cp310-manylinux1_x86_64.whl (797.2 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 797.2/797.2 MB 11.7 MB/s eta 0:00:00
Downloading nvidia_cublas_cu12-12.1.3.1-py3-none-manylinux1_x86_64.whl (410.6 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 410.6/410.6 MB 11.6 MB/s eta 0:00:00
Downloading nvidia_cuda_cupti_cu12-12.1.105-py3-none-manylinux1_x86_64.whl (14.1 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.1/14.1 MB 11.4 MB/s eta 0:00:00
Downloading nvidia_cuda_nvrtc_cu12-12.1.105-py3-none-manylinux1_x86_64.whl (23.7 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 23.7/23.7 MB 11.6 MB/s eta 0:00:00
Downloading nvidia_cuda_runtime_cu12-12.1.105-py3-none-manylinux1_x86_64.whl (823 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 823.6/823.6 kB 12.1 MB/s eta 0:00:00
Downloading nvidia_cudnn_cu12-9.1.0.70-py3-none-manylinux2014_x86_64.whl (664.8 MB)
   ━━━━━━━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 131.6/664.8 MB 11.7 MB/s eta 0:00:46
ERROR: Operation cancelled by user

Copy link
Contributor

github-actions bot commented Oct 2, 2024

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale Inactive for 30 days label Oct 2, 2024
Copy link
Contributor

This issue was closed because it has been stalled for over 30 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working severity:critical Critical issues or affecting all users Stale Inactive for 30 days
Projects
None yet
Development

No branches or pull requests

9 participants