OpenHands / OpenHands/enterprise

[Bug]: .openhands/setup.sh from repository not working

Open Beginner friendly
#41 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
4
Forks
2
Avg merge
1d 22h
Merged PRs (30d)
101

Description

Is there an existing issue for the same bug?
  • I have searched existing issues and this is not a duplicate.
Bug Description

When checking out a branch from a repo, the agent should automatically run .openhands/setup.sh, but this is currently broken.

Expected Behavior

.openhands/setup.sh should run as documented here: https://docs.openhands.dev/openhands/usage/customization/repository#setup-script
For the example below, a file called somefile.txt should be created.

Actual Behavior

The script is not executed. The script under "steps to reproduce" does not create a file somefile.txt.

Steps to Reproduce

Make a repo with an .openhands/setup.sh, e.g. with the content:

#!/bin/bash
touch somefile.txt
OpenHands Installation Method

Local GUI (Docker web interface)

If you selected "Other", please specify

No response

OpenHands Version

1.8.0

Version Confirmation
  • I have confirmed this bug exists on the LATEST version of OpenHands
Model Name

No response

Operating System

No response

Browser (if using web UI)

No response

Logs and Error Messages

No response

Screenshots and Additional Context

Look at this code in openhands/app_server/app_conversation/app_conversation_service_base.py from maybe_run_setup_script:

        await workspace.execute_command(
            f'chmod +x {setup_script} && source {setup_script}',
            cwd=project_dir,
            timeout=600,
        )

source is a command that only exists in bash, but this command is probably executed in sh.
Not sure if there is any way to let the setup script export environment variables which would also be available for the agent. Would certainly be nice.
The docs (https://docs.openhands.dev/openhands/usage/customization/repository#setup-script) suggest that you can change the current directory in the script, which would have an effect for the agent. That's very similar to sharing environment variables, since both depend on the shell interpreter.

I tested a partial fix by changing:
f'chmod +x {setup_script} && source {setup_script}', to f'chmod +x {setup_script} && . {setup_script}',. That works, but current dir and environment variables wouldn't be shared. Still, better than before.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in openhands/app_server/app_conversation/app_conversation_service_base.py at maybe_run_setup_script, then inspect how workspace.execute_command invokes the command. Reproduce the documented .openhands/setup.sh example and verify that it executes successfully and creates somefile.txt; consider the reported current-directory and environment-variable behavior separately.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.