OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

It seems that playwright isn't installed correctly in docker

Open smilefufu opened this issue 1 year ago • 15 comments

Describe the bug

Opendevin tried to use playwright to browser online, but failed because playwright isn't installed correctly in docker. playwright install command runned, but failed.(see screenshot below)

Setup and configuration

Current version:

I'm using the latest docker image.

My operating system: MacOS (M1 Max chip)

My environment vars and other configuration (be sure to redact API keys):

export WORKSPACE_DIR=/Users/fufu/codes/playgruond/workspace4opendevin/test_project
export LLM_API_KEY="sk-non-important"
export LLM_BASE_URL="https://someproxydomain2openai.com/v1"

My model and agent (you can see these settings in the UI):

  • Model: GPT3.5
  • Agent: MonologueAgent

Commands I ran to install and run OpenDevin:

docker run \
    -e LLM_API_KEY=$LLM_API_KEY \
    -e LLM_BASE_URL=$LLM_BASE_URL \
    -e WORKSPACE_MOUNT_PATH=$WORKSPACE_DIR \
    -v $WORKSPACE_DIR:/opt/workspace_base \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -p 3000:3000 \
    ghcr.io/opendevin/opendevin:latest

Steps to Reproduce:

  1. Create a pixel style RPG game.

Logs, error messages, and screenshots:

ACTION:
BrowseURLAction(url='https://www.pixelart.com/', action=<ActionType.BROWSE: 'browse'>)
huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
To disable this warning, you can either:
	- Avoid using `tokenizers` before the fork if possible
	- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)

OBSERVATION:
BrowserType.launch: Executable doesn't exist at /root/.cache/ms-playwright/chromium-1112/chrome-linux/chrome
╔════════════════════════════════════════════════════════════╗
║ Looks like Playwright was just installed or updated.       ║
║ Please run the following command to download new browsers: ║
║                                                            ║
║     playwright install                                     ║
║                                                            ║
║ <3 Playwright Team                                         ║
╚════════════════════════════════════════════════════════════╝

image

Additional Context

smilefufu avatar Apr 17 '24 00:04 smilefufu

I think this is caused by PATH env didn't set correctly in docker. Maybe try python -m playwright install ?

smilefufu avatar Apr 17 '24 00:04 smilefufu

I think I've solved the problem by running command playwright install-deps mannually in docker exec (docker image version: opendevin:latest) image

smilefufu avatar Apr 17 '24 02:04 smilefufu

Good catch! We probably just need to add that command here: https://github.com/OpenDevin/OpenDevin/blob/main/containers/app/Dockerfile

rbren avatar Apr 17 '24 03:04 rbren

image

Please add RUN npx -y [email protected] install --with-deps to line 53 in containers/app/Dockerfile then rebuild image to help check if this fix the problem.

Umpire2018 avatar Apr 17 '24 03:04 Umpire2018

@Umpire2018 I think that's for interacting using node.

@rben after 27?https://github.com/OpenDevin/OpenDevin/blob/aed82704a947df6e348a5fcf044c482f8e580f5f/containers/app/Dockerfile#L27

SmartManoj avatar Apr 17 '24 06:04 SmartManoj

@Umpire2018 I think that's for interacting using node.

image

@SmartManoj I believe it's to install playwright system-wide. Below is its suggestion for your reference.

image

Umpire2018 avatar Apr 17 '24 06:04 Umpire2018

Most likely both python and npm can be used to install playwright globally. Since we're calling playwright from python, we should probably use that one.

@SmartManoj yeah I think you found the best spot for it

rbren avatar Apr 17 '24 13:04 rbren

In the original issue at the top, the agent is trying to access Playwright. Does that not mean Playwright needs to be installed on the sandbox image rather than the app image?

foragerr avatar Apr 17 '24 13:04 foragerr

If it does go in the app image, it should be in the runtime stage, so perhaps closer to line # 40

foragerr avatar Apr 17 '24 13:04 foragerr

BrowseURLAction is happening on the app image. The command should be run only once. So, it should be in the backend-builder. right?

The OP installed it in the sandbox itself. It works like the other shell commands instead of a separate action.

SmartManoj avatar Apr 17 '24 13:04 SmartManoj

The OP installed it in the sandbox itself.

It's the Agent that is trying to install playwright (and failing), rather than the OP.

BrowseURLAction is happening on the app image.

👍 did not know that. Someone needs to tell the agent that there's a BrowseURLAction it can use instead of installing playwright. Perhaps in the system prompt.

The command should be run only once. So, it should be in the backend-builder. right?

if you install it in the backend-builder, it wont make it to the final image, unless if you're explicitly copying it over. "runtime" doesn't mean it'll get run everytime the image is launched. see: https://docs.docker.com/build/building/multi-stage/

foragerr avatar Apr 17 '24 16:04 foragerr

I think this is what happened:

  • agent issues a browse action
  • backend (not sandbox) tries to run playwright
  • backend reports an error "playwright not installed" to the agent
  • agent tries to run install playwright in the sandbox
    • but obviously that won't fix the issue, because it's the backend that needs access to the command

rbren avatar Apr 17 '24 17:04 rbren

The OP installed it in the sandbox itself.

@foragerr Manually using the docker GUI

, unless if you're explicitly copying it over.

https://github.com/OpenDevin/OpenDevin/blob/aed82704a947df6e348a5fcf044c482f8e580f5f/containers/app/Dockerfile#L46

Here, it is already copied for poetry packages. Right?

SmartManoj avatar Apr 18 '24 04:04 SmartManoj

Could be, give it a try.

foragerr avatar Apr 18 '24 06:04 foragerr

can anyone try https://github.com/OpenDevin/OpenDevin/pull/1184 to see if it works?

rbren avatar Apr 19 '24 19:04 rbren

Should be fixed by https://github.com/OpenDevin/OpenDevin/pull/1184

neubig avatar Apr 22 '24 15:04 neubig