Package Manager Dependency Mirroring

The dependency mirroring is not working as I expected.

$ TEMP=$(mktemp -d)
$ cd $TEMP
$ export CI_SERVER_HOST=gitlab.local
$ export CI_JOB_TOKEN=deadbeef1234
$ git clone https://lovelettr:$CI_JOB_TOKEN@$CI_SERVER_HOST/path/parent-repo.git
$ cd parent-repo
$ swift package config set-mirror --package-url git@$CI_SERVER_HOST:path/dependent.git --mirror-url https://lovelettr:$CI_JOB_TOKEN@$CI_SERVER_HOST/path/dependent.git
$ swift build
Fetching git@gitlab.local:path/dependent.git
error: failed to clone; Cloning into bare repository '/private/var/folders/s8/ybwgdx793dv67p21t_mxkqx00000z8/T/tmp.z7w70432/parent-repo/.build/repositories/dependent-cdaa868b'...
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I would have expected swift package config set-mirror to change the fetching. It is still using Git over SSH even though I set a mirror to Git over HTTPS.

What am I missing? :thinking:

Got it. It requires deleting the Package.resolved file.

I re-read the docs/proposal and stumbled across this line:

The Package.resolved file will contain the mirror URLs that were used during dependency resolution.

It occurred to me that since mirroring was writing to that file it was checking that file first. So I deleted it and re-ran and :tada: it used the mirror paths.

1 Like

CC @Aciid .

You seem to be hitting SR-11056 and/or SR-11057. Those bugs are very annoying if you use the mirroring feature. As you report, deleting Package.resolved works around the issue (by also giving up the version pinning that Package.resolved provides).

Maybe you could comment on the bugs how/if it affected you and what your exact setup is (is the mirror config checked into the repo or is it only injected on CI builds)?

Terms of Service

Privacy Policy

Cookie Policy