Hey there! I´m trying to run the headless version ...
# questions
w
Hey there! I´m trying to run the headless version in docker and get the following error. I have the correct (same token as on the webinterface version) set as env variable
GITHUB_TOKEN
and verified it with a
env
command. Any ideas?
Copy code
08:58:10 - openhands:DEBUG: base.py:193 - Adding env vars: dict_keys([])
08:58:10 - openhands:DEBUG: base.py:235 - Added env vars to IPython
08:58:10 - openhands:DEBUG: docker_runtime.py:197 - [runtime a526746a-8869-45-a6173daba1fb6da] Container initialized with plugins: ['agent_skills', 'jupyter']. VSCode URL: None
08:58:10 - openhands:DEBUG: setup.py:120 - Selected repository ******/*********.
08:58:10 - openhands:ERROR: provider.py:352 - Failed to access repository ******/********* with all available providers. Errors:
ERROR:root:  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/app/openhands/core/main.py", line 303, in <module>
    asyncio.run(
  File "/usr/local/lib/python3.12/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 691, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/app/openhands/core/main.py", line 117, in run_controller
    repo_directory = initialize_repository_for_runtime(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/openhands/core/setup.py", line 121, in initialize_repository_for_runtime
    repo_directory = call_async_from_sync(
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/app/openhands/utils/async_utils.py", line 54, in call_async_from_sync
    result = future.result()
             ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/openhands/utils/async_utils.py", line 44, in run
    return asyncio.run(arun())
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 691, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/app/openhands/utils/async_utils.py", line 37, in arun
    result = await coro
             ^^^^^^^^^^
  File "/app/openhands/runtime/base.py", line 396, in clone_or_init_repo
    remote_repo_url = await self.provider_handler.get_authenticated_git_url(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/openhands/integrations/provider.py", line 422, in get_authenticated_git_url
    raise Exception('Git provider authentication issue when getting remote URL')

ERROR:root:<class 'Exception'>: Git provider authentication issue when getting remote URL
b
How are you running the docker command? Mind showing your docker run command? Are you running it similar to https://docs.all-hands.dev/usage/how-to/headless-mode#with-docker
w
This is the script I prepared to run it:
Copy code
#!/bin/bash
set -e

# --- Prompt handling ---
if [ $# -eq 0 ]; then
  echo "Usage: $0 \"Your task here\""
  exit 1
fi

USER_PROMPT="$*"
FULL_PROMPT="Use a shallow clone (--depth 1). $USER_PROMPT"

# --- Workspace setup ---
if [ -z "$OPENHANDS_WORKSPACE" ]; then
  TIMESTAMP=$(date +"%Y%m%d-%H%M%S")
  WORKSPACE_HOST_PATH="$PWD/openhands-workspace-$TIMESTAMP"
else
  WORKSPACE_HOST_PATH="$OPENHANDS_WORKSPACE"
fi

mkdir -p "$WORKSPACE_HOST_PATH"

# --- Configuration ---
export SANDBOX_VOLUMES="${WORKSPACE_HOST_PATH}:/workspace:rw"
export SANDBOX_SELECTED_REPO="${REPO}"
export GITHUB_TOKEN="${GITHUB_TOKEN}"  # Ensure this is set in your shell
export LLM_MODEL="${LLM_MODEL:-anthropic/claude-sonnet-4-20250514}"
export LLM_API_KEY="${LLM_API_KEY}"

# --- Run OpenHands in headless mode ---
docker run --rm -it \
  --pull=always \
  -e DEBUG=1 \
  -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.51-nikolaik \
  -e SANDBOX_USER_ID=$(id -u) \
  -e SANDBOX_VOLUMES="$SANDBOX_VOLUMES" \
  -e SANDBOX_SELECTED_REPO="$SANDBOX_SELECTED_REPO" \
  -e GITHUB_TOKEN="$GITHUB_TOKEN" \
  -e LLM_MODEL="$LLM_MODEL" \
  -e LLM_API_KEY="$LLM_API_KEY" \
  -e LOG_ALL_EVENTS=true \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v ~/.openhands:/.openhands \
  --add-host host.docker.internal:host-gateway \
  docker.all-hands.dev/all-hands-ai/openhands:0.51 \
    python -m openhands.core.main -t "$FULL_PROMPT"
b
If you echo your GITHUB_TOKEN right before the export, is it set correctly?
w
Just tested, it is set correctly
b
Then it looks like a bug. Can you please open a github issue