Conan: [bug] Deploy() never called with conanfile.txt

Created on 1 Jun 2020  ·  3Comments  ·  Source: conan-io/conan

Environment Details

  • Operating System+version: Windows 10 Pro x64
  • Compiler+version: Visual Studio 2019
  • Conan version: 1.25.2

Steps to reproduce (Include if Applicable)

  1. Create package (https://docs.conan.io/en/latest/creating_packages.html)
  2. Add deploy() method to copy files to userspace. Add output to show execution
  3. Create a consumer project and add the package to the conanfile.txt [requires]

    • mkdir dependencies && cd dependencies

    • conan install ..

Logs (Executed commands with output) (Include/Attach if Applicable)

Log does not show deploy() method log

Expected Behavior

The deploy() method must be called, and the files should be copied to userspace.

Actual Behavior

The script exits after packaging, and does not reach deploy()

Most helpful comment

deploy() is only called in the specific case of conan install foo/1.0. It is not called when a package is part of the transitive [requires], only for a top-level reference

https://docs.conan.io/en/latest/reference/conanfile/methods.html#deploy

The deploy() method is designed to work on a package that is installed directly from its reference, as:

$ conan install pkg/0.1@user/channel

...
pkg/0.1@user/testing deploy(): Copied 1 '.dll' files: mylib.dll
pkg/0.1@user/testing deploy(): Copied 1 '.exe' files: myexe.exe

All other packages and dependencies, even transitive dependencies of “pkg/0.1@user/testing” will not be deployed, it is the responsibility of the installed package to deploy what it needs from its dependencies.

All 3 comments

deploy() is only called in the specific case of conan install foo/1.0. It is not called when a package is part of the transitive [requires], only for a top-level reference

https://docs.conan.io/en/latest/reference/conanfile/methods.html#deploy

The deploy() method is designed to work on a package that is installed directly from its reference, as:

$ conan install pkg/0.1@user/channel

...
pkg/0.1@user/testing deploy(): Copied 1 '.dll' files: mylib.dll
pkg/0.1@user/testing deploy(): Copied 1 '.exe' files: myexe.exe

All other packages and dependencies, even transitive dependencies of “pkg/0.1@user/testing” will not be deployed, it is the responsibility of the installed package to deploy what it needs from its dependencies.

Thanks @puetzk ! Confirmed.

Can anyone please explain what the rationale for this is? Why doesn't conan install follow the same behavior as conan install X?

I was hoping to use the consumer conanfile as a single-source-of-truth for project deps, as well as consolidate fetching/building those deps. Is this possible with the aforementioned flow? Am I misunderstanding the how/why of the conanfile?

Thanks again!

Can anyone please explain what the rationale for this is? Why doesn't conan install follow the same behavior as conan install X?

deploy() and imports() are operations that copy things from the cache to the user folder. When typing conan install <path> there is no package in the cache, it is already local in your folder, so can't be deployed.

We will be changing the cli for Conan 2.0, and probably the commands will be different for <path> and <reference>.

Was this page helpful?
0 / 5 - 0 ratings