docker-alpine icon indicating copy to clipboard operation
docker-alpine copied to clipboard

Using version pinning and virtual packages results in unsatisfiable constraints

Open allanlei opened this issue 8 years ago • 11 comments

When using virtual packages in-conjunction with version pinning results in the package not found. I am trying to install gdal-dev which is not in v3.4 but is in edge/testing. If I remove the virtual package, it installs.

Is this possible or bug?

/etc/apk/repositories:

http://dl-cdn.alpinelinux.org/alpine/v3.4/main
http://dl-cdn.alpinelinux.org/alpine/v3.4/community
@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing

Commands:

# apk --no-cache add --virtual .build-deps gdal-dev@edge-testing
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  gdal-2.1.0-r1:
    masked in: @edge-testing
    satisfies: gdal-dev-2.1.0-r1[gdal] gdal-dev-2.1.0-r1[gdal=2.1.0-r1]
  gdal-dev-2.1.0-r1:
    masked in: @edge-testing
  .build-deps-0:
    masked in: cache
    satisfies: world[.build-deps]

Without virtual packages

# apk --no-cache add gdal-dev@edge-testing
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
(1/9) Installing libgcc (5.3.0-r0)
(2/9) Installing giflib (5.1.4-r1)
(3/9) Installing libjpeg-turbo (1.4.2-r0)
(4/9) Installing libstdc++ (5.3.0-r0)
(5/9) Installing tiff (4.0.6-r3)
(6/9) Installing gdal@edge-testing (2.1.0-r1)
(7/9) Installing pkgconf (0.9.12-r0)
(8/9) Installing pkgconfig (0.25-r1)
(9/9) Installing gdal-dev@edge-testing (2.1.0-r1)
Executing busybox-1.24.2-r9.trigger
OK: 72 MiB in 41 packages

allanlei avatar Aug 15 '16 05:08 allanlei

I'm seeing the same thing.

msnelling avatar Sep 09 '16 14:09 msnelling

@ncopa is this an upstream bug?

andyshinn avatar Sep 30 '16 18:09 andyshinn

In general using the edge/testing repo should require using edge/main. edge/testing is similar to Debian's "experimental" repo, which implies that you're running "unstable"... same idea basically.

With that said, it might be a problem in the dependency resolver. It is most certainly an apk-tools bug at any rate, as using --virtual shouldn't cause such a radical change in dependency resolution.

kaniini avatar Nov 30 '16 07:11 kaniini

Still the same with Alpine 3.6

apk add --no-cache --virtual foo gosu@testing=1.9-r0
ERROR: unsatisfiable constraints:
  gosu-1.9-r0:
    masked in: @testing
  foo-0:
    masked in: cache
    satisfies: world[foo]

No problem w/o --virtual foo

udondan avatar Jul 31 '17 09:07 udondan

I will look into it in apk-tools as time permits.

kaniini avatar Jul 31 '17 13:07 kaniini

any update on this?

raoofm avatar Feb 20 '18 18:02 raoofm

The problem is that gosu@testing=1.9-r0 is an invalid dependency (because dependencies aren't allowed to be masked, only "world dependencies").

kaniini avatar Feb 20 '18 19:02 kaniini

In other words, the problem is that apk does not properly explain that a child dependency cannot be tagged.

Improving apk diagnostics is something I am actively working on at this moment.

kaniini avatar Feb 20 '18 21:02 kaniini

I added a diagnostic for this, but pinned child dependencies are explicitly not allowed by the solver for a multitude of reasons.

When you use --virtual what you're doing is creating a package on the fly and then attaching the dependencies to it. If a pinned repo becomes unavailable, or the pinning itself changes later, then the dependency tree will have orphaned nodes and become unsolvable.

This will be in the apk-tools 2.10 release.

kaniini avatar Feb 20 '18 22:02 kaniini

Final thoughts:

  • There was an apk-tools bug -- it was attempting to modify the dependency graph with something that was impossible, but the dependency resolution behaviour was working as expected upon closer examination.

  • If you're using masking in a docker container, don't use --virtual. If you need --virtual with a masked package, you're probably thinking about the problem wrongly: consider using version constraints instead.

  • If you are using packages from the testing repo, your base image really needs to be on Alpine edge anyway, so there's not much point in masking. If you mix packages from different Alpine releases, welp, you get to keep both pieces if it breaks.

kaniini avatar Feb 20 '18 22:02 kaniini

I've been using --virtual for my build deps, but version pinning an edge package. Then, trying to apk del the virtual was throwing this unsatisfiable constraints error.

@kaniini Your advice to use alpine:edge as my base image solved my issue, thanks!

seanpianka avatar Sep 29 '19 21:09 seanpianka