Skip to content

install.sh fails with non-default git config clone.defaultRemoteName #3547

Open
@ryan-williams

Description

@ryan-williams

Dockerfile:

FROM ubuntu:24.04
RUN apt update -y && apt install -y git wget

# ‼️ non-standard remote name causes `install.sh` to fail
ARG defaultRemote=upstream
RUN git config --global clone.defaultRemoteName $defaultRemote
RUN wget -q https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh

# ❌ fatal: 'origin' does not appear to be a git repository
RUN bash install.sh

Build fails when the default cloned remote name is not origin:

docker build -t nvm .  # ❌ Fails when default remote name is `upstream`
docker build -t nvm --build-arg defaultRemote=origin .  # ✅ OK

Here's the full failure output:

$ docker build -t nvm .
[+] Building 13.2s (9/9) FINISHED                                                                   docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                0.0s
 => => transferring dockerfile: 288B                                                                                0.0s
 => [internal] load metadata for docker.io/library/ubuntu:24.04                                                     0.4s
 => [auth] library/ubuntu:pull token for registry-1.docker.io                                                       0.0s
 => [internal] load .dockerignore                                                                                   0.0s
 => => transferring context: 2B                                                                                     0.0s
 => CACHED [1/5] FROM docker.io/library/ubuntu:24.04@sha256:72297848456d5d37d1262630108ab308d3e9ec7ed1c3286a32fe09  0.0s
 => [2/5] RUN apt update -y && apt install -y git wget                                                             12.2s
 => [3/5] RUN git config --global clone.defaultRemoteName upstream                                                  0.1s
 => [4/5] RUN wget -q https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh                               0.1s
 => ERROR [5/5] RUN bash install.sh                                                                                 0.3s
------
 > [5/5] RUN bash install.sh:
0.103 => Downloading nvm from git to '/root/.nvm'
=> Cloning into '/root/.nvm'...
0.303 fatal: 'origin' does not appear to be a git repository
0.303 fatal: Could not read from remote repository.
0.303
0.303 Please make sure you have the correct access rights
0.303 and the repository exists.
0.304 Failed to fetch origin with v0.40.2. Please report this!
------
Dockerfile:6
--------------------
   4 |     RUN git config --global clone.defaultRemoteName $defaultRemote
   5 |     RUN wget -q https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh
   6 | >>> RUN bash install.sh
   7 |
--------------------
ERROR: failed to solve: process "/bin/sh -c bash install.sh" did not complete successfully: exit code: 1

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/15rwdgslgqiro3al8ak02cver

install.sh assumes the cloned remote will be named origin in a few places, most significantly here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions