Vcpkg: Dependency on default-features of a port not respected when dependency already installed

Created on 3 Apr 2020  路  10Comments  路  Source: microsoft/vcpkg

Describe the bug

When I install harfbuzz it always installs freetype with configuration [bzip2,core,png] even when I specify [core]. It seems that dependency resolution does not consider manual dependencies specified on command line.

Environment

  • Windows.
  • Version: e1fc03c47. vcpkg_from_git: Add support for git over ssh

To Reproduce
Steps to reproduce the behavior:

  1. vcpkg.exe --triplet x86-windows install freetype[core] harfbuzz[core,ucdn]

Output:

  * bzip2[core]:x86-windows
    freetype[bzip2,core,png]:x86-windows
    harfbuzz[core,ucdn]:x86-windows
  * libpng[core]:x86-windows
  * ragel[core]:x86-windows
  * zlib[core]:x86-windows

Expected behavior

Only install freetype[core] packages:

Expected Output:

    freetype[core]:x86-windows
    harfbuzz[core,ucdn]:x86-windows
  * ragel[core]:x86-windows
  * zlib[core]:x86-windows
vcpkg-bug

Most helpful comment

Ah so the bug is actually the inverse of what I thought.
Well what only matters is that the result is consistent :).

And thanks for the hint about the Build-Depends.

Changing harfbuzz to

Build-Depends: freetype[core], ragel, gettext (osx)

will give:

> vcpkg install harfbuzz[core,ucdn]
Computing installation plan...
The following packages will be built and installed:
  * bzip2[core]:x86-windows
  * freetype[bzip2,core,png]:x86-windows
    harfbuzz[core,ucdn]:x86-windows
  * libpng[core]:x86-windows
  * ragel[core]:x86-windows
  * zlib[core]:x86-windows

> vcpkg install freetype[core] harfbuzz[core,ucdn]
Computing installation plan...
The following packages will be built and installed:
    freetype[core]:x86-windows
    harfbuzz[core,ucdn]:x86-windows
  * ragel[core]:x86-windows
  * zlib[core]:x86-windows

Which is exactly what I would have expected. Thanks! :)

All 10 comments

@Ghabry Thanks for posting this issue. When installing port[feature1], the VCPKG will install all default features + feature1. The related comments: https://github.com/microsoft/vcpkg/issues/7471#issuecomment-516549641

Thanks for the response.

Yeah I know about this feature behaviour without core (and it makes sense this way) but I explicitly specify core:

vcpkg.exe --triplet x86-windows install freetype[core] harfbuzz[core,ucdn]

Freetype is a dependency of harfbuzz. This installs bzip2 and libpng (default features of freetype) even though I specify freetype[core] here BUT when I do

vcpkg.exe --triplet x86-windows install freetype[core]
vcpkg.exe --triplet x86-windows install harfbuzz[core,ucdn]

it will not install bzip2 and libpng.

So imo this is a bug because the behaviour differs for the same package options.

I try to install harfbuzz[core,ucdn], the freetype will install freetype[bzip2,core,png] like this:

.\vcpkg.exe install harfbuzz[core,ucdn]
Computing installation plan...
The following packages will be built and installed:
  * freetype[bzip2,core,png]:x86-windows
    harfbuzz[core,ucdn]:x86-windows
  * ragel[core]:x86-windows
Additional packages (*) will be modified to complete this operation.
Starting package 1/3: freetype:x86-windows
Building package freetype[bzip2,core,png]:x86-windows...
-- Using cached E:/0325/vcpkg/downloads/freetype-2.10.1.tar.xz
-- Using source at E:/0325/vcpkg/buildtrees/freetype/src/2.10.1-ea10bbeefe
-- Configuring x86-windows
-- Building x86-windows-dbg
-- Building x86-windows-rel
-- Performing post-build validation
-- Performing post-build validation done
Building package freetype[bzip2,core,png]:x86-windows... done
Installing package freetype[bzip2,core,png]:x86-windows...
Installing package freetype[bzip2,core,png]:x86-windows... done
Elapsed time for package freetype:x86-windows: 23.76 s
......

Thanks for posting this issue. Please open a new issue if this is still a problem for you.

So, this is a WontFix then?

When you install one port, the VCPKG will install it and its dependency port. The port implies all default features. Even if you specify freetype[core], but the harfbuzz will install freetype, the freetype implies freetype[bzip2,core,png].

I still believe this is a bug because the result differs.
But if you conclude that this is intended behaviour I can workaround it via the second solution.

Installing both at the same time, explicitly specifying freetype[core]:
Result: freetype[core] is fully ignored, installs freetype[bzip2,core,png]

> vcpkg.exe --triplet x86-windows install freetype[core] harfbuzz[core,ucdn]
Computing installation plan...
The following packages will be built and installed:
  * bzip2[core]:x86-windows
    freetype[bzip2,core,png]:x86-windows
    harfbuzz[core,ucdn]:x86-windows
  * libpng[core]:x86-windows
  * ragel[core]:x86-windows
  * zlib[core]:x86-windows

> vcpkg list
bzip2:x86-windows                                  1.0.6-5
freetype:x86-windows                               2.10.1-6
freetype[bzip2]:x86-windows
freetype[png]:x86-windows
harfbuzz:x86-windows                               2.5.3
harfbuzz[ucdn]:x86-windows 
libpng:x86-windows                                 1.6.37-7
ragel:x86-windows                                  6.10-3
zlib:x86-windows                                   1.2.11-6

Doing two invocations of vcpkg: harfbuzz is happy with freetype[core] and doesn't pull in libpng or bzip2.

> vcpkg.exe --triplet x86-windows install freetype[core]
Computing installation plan...
The following packages will be built and installed:
    freetype[core]:x86-windows
  * zlib[core]:x86-windows

> vcpkg.exe --triplet x86-windows install harfbuzz[core,ucdn]
Computing installation plan...
The following packages will be built and installed:
    harfbuzz[core,ucdn]:x86-windows
  * ragel[core]:x86-windows

> vcpkg list
freetype:x86-windows                               2.10.1-6
harfbuzz:x86-windows                               2.5.3
harfbuzz[ucdn]:x86-windows
ragel:x86-windows                                  6.10-3
zlib:x86-windows                                   1.2.11-6

There is a bug here but it isn't the one you originally described.
harfbuzz marks freetype without any features as a Build-Depends. This should cause freetype[core, bzip2, png] to get installed no matter what when you install harfbuzz. If harfbuzz is actually fine with just freetype's core features it should be marked as such in the CONTROL file.

The bug is that installing these two packages in two steps allows you to get freetype without its default features.

Also thanks for the high-effort bug report. It's appreciated.

Ah so the bug is actually the inverse of what I thought.
Well what only matters is that the result is consistent :).

And thanks for the hint about the Build-Depends.

Changing harfbuzz to

Build-Depends: freetype[core], ragel, gettext (osx)

will give:

> vcpkg install harfbuzz[core,ucdn]
Computing installation plan...
The following packages will be built and installed:
  * bzip2[core]:x86-windows
  * freetype[bzip2,core,png]:x86-windows
    harfbuzz[core,ucdn]:x86-windows
  * libpng[core]:x86-windows
  * ragel[core]:x86-windows
  * zlib[core]:x86-windows

> vcpkg install freetype[core] harfbuzz[core,ucdn]
Computing installation plan...
The following packages will be built and installed:
    freetype[core]:x86-windows
    harfbuzz[core,ucdn]:x86-windows
  * ragel[core]:x86-windows
  * zlib[core]:x86-windows

Which is exactly what I would have expected. Thanks! :)

Was this page helpful?
0 / 5 - 0 ratings