Runner behavior different than expected for artifactory packages

I have an AWS EC2 instance that’s acting as a shell executor for my CICD pipeline.

When I ssh into the machine as ubuntu and run activate /path/to/my/venv py311 along with pip install -r requirements.txt, I’m able to install the packages from a private JFrog artifactory repository without any issue.

However, when my gitlab runner does the same two steps that I do manually, I’m met with:

ERROR: Could not find a version that satisfies the requirement package>=1.4.2 (from versions: none)
ERROR: No matching distribution found for package>=1.4.2

I’ve added steps in my .gitlab-ci.yml to echo $USER along with checking that .netrc exists. Both return that the $USER is ubuntu and that .netrc exists so I’m not sure why it’s having trouble installing the packages.

My .gitlab-ci.yml looks like this:

  - build

  stage: build
    NETRC: '$HOME/.netrc'  
    - export PIP_CACHE_DIR=~/pip_store/pip_cache
    - echo $USER
    - echo "Verifying .netrc at $HOME/.netrc"
    - if [[ -f "$HOME/.netrc" ]]; then echo ".netrc exists"; fi
    - activate /path/to/my/venv py311
    - echo "Installing packages..."
    - pip install -r requirements.txt

I’ve also attached the job trace for verifying that $USER and .netrc exists as well:


This NETRC: '$HOME/.netrc' is expanded in the context of GitLab, not in context of your shell. So when pipeline config is generated, this is expanded to ‘/.netrc’, because there is no “$HOME” variable (it’s empty string) as far as GitLab is concerned. GitLab (or YAML in general) doesn’t distinguish between single quotes and double quotes like Bash (for example).

If you want to disable variable expansion you need to define it as ‘$$HOME/.netrc’. This is explained here.