EC2: `bash -lc` drops the image's PATH

Open Beginner friendly
#4,320 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
bash, python

Research direction

Start in ec2.py at _exec_main_detached, where the exec command is built, and compare it with how the Docker backend invokes a task and how _MAIN_LOGIN_SHELL is meant to be consulted; the GKE fix in #4310 is the sibling reference. Reproduce with a golang:1.24-bookworm image by checking command -v go under bash -c versus bash -lc. Done means the EC2 path no longer resets PATH while still honoring any configured login shell, verified by the existing EC2 tests and a DeepSWE reference run.

Written by the indexing model from the issue text.

Description

On EC2 sandboxes, a task can't find tools its image added to PATH (a venv, Go binaries), even though the same task works on Docker.

Running DeepSWE on EC2, I had a reference solution fail with missing pytest that passes fine on Docker. Turns out _exec_main_detached in ec2.py runs everything with bash -lc, so /etc/profile resets PATH and whatever the image set with ENV PATH is gone. It doesn't look at _MAIN_LOGIN_SHELL either.

Easy to see with any Debian-based image:

$ docker run --rm golang:1.24-bookworm bash -c 'command -v go'
/usr/local/go/bin/go
$ docker run --rm golang:1.24-bookworm bash -lc 'command -v go'
$

Looks like the same thing #4310 fixes for GKE. Switching both to -c locally fixed it for me, and I reran all 113 DeepSWE reference solutions on EC2 afterwards. Can open a PR if that's useful.

Dominant language
Python
Stars
5.6k
Forks
1.9k
Avg merge
1d 17h
Merged PRs (30d)
156

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from harbor-framework/harbor

All issues in harbor-framework/harbor

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.