conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.1k stars 960 forks source link

[bug] graph_info.json generated in unexpected directory for editables #10373

Open jkuebart opened 2 years ago

jkuebart commented 2 years ago

Environment Details (include every applicable attribute)

Steps to reproduce (Include if Applicable)

After running the following script, there is a spurious file lib/graph_info.json generated by the last step, conan install app. It is expected that graph_info.json is generated in the lib/generators folder like files created by other generators.

#!/bin/sh -efu

mkdir -p app lib
cat >lib/conanfile.py <<EOF
from conans import ConanFile

class LibConan(ConanFile):
    generators = ()

    def layout(self):
        self.folders.build = "build"
        self.folders.generators = "generators"
EOF

cat >app/conanfile.py <<EOF
from conans import ConanFile

class AppConan(ConanFile):
    generators = ()
    requires = "lib/[>=0]"

    def layout(self):
        self.folders.build = "build"
        self.folders.generators = "generators"
EOF

export CONAN_USER_HOME=$PWD

conan install -if lib/install lib lib/0.0@
conan editable add lib lib/0.0@
conan install -if app/install app app/0.0@
tree

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

Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=13.0
os=Macos
os_build=Macos
[options]
[build_requires]
[env]

conanfile.py (lib/0.0): Installing package
Requirements
Packages

Installing (downloading, building) binaries...
conanfile.py (lib/0.0): Generator txt created conanbuildinfo.txt
conanfile.py (lib/0.0): Aggregating env generators
conanfile.py (lib/0.0): Generated conaninfo.txt
conanfile.py (lib/0.0): Generated graphinfo
Reference 'lib/0.0@' in editable mode
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=13.0
os=Macos
os_build=Macos
[options]
[build_requires]
[env]

Version ranges solved
    Version range '>=0' required by 'conanfile.py (app/0.0)' resolved to 'lib/0.0' in local cache

conanfile.py (app/0.0): Installing package
Requirements
    lib/0.0 from user folder - Editable
Packages
    lib/0.0:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Editable

Installing (downloading, building) binaries...
lib/0.0: Rewriting files of editable package 'lib' at '/Users/joki/src/conanbug/lib/generators'
lib/0.0: Aggregating env generators
lib/0.0: Generated toolchain
lib/0.0: Generated conan.lock
conanfile.py (app/0.0): Generator txt created conanbuildinfo.txt
conanfile.py (app/0.0): Aggregating env generators
conanfile.py (app/0.0): Generated conaninfo.txt
conanfile.py (app/0.0): Generated graphinfo
.
├── app
│   ├── conanfile.py
│   └── install
│       ├── conan.lock
│       ├── conanbuildinfo.txt
│       ├── conaninfo.txt
│       └── graph_info.json
├── lib
│   ├── conanfile.py
│   ├── graph_info.json
│   └── install
│       ├── conan.lock
│       ├── conanbuildinfo.txt
│       ├── conaninfo.txt
│       └── graph_info.json
└── test

4 directories, 12 files

The tree output shows the file lib/graph_info.json which isn't supposed to exist in this location. It should be in the lib/generators folder as specified by layout(self) in lib/conanfile.py.

memsharded commented 2 years ago

Actually, this was a explicit decision. The graph_info.json file is deprecated, and already removed in Conan 2.0. In theory, only the new generators (those in from conan.tools.xxxx like CMakeDeps) will be following the layout() definition, but the previous generators will still output files in the previous locations.

jkuebart commented 2 years ago

Ok, but then I don't understand why I'm even getting a graph_info.json file at all? In the example I explicitly set generators to empty, but it also happens when I use generators = "CMakeDeps", "CMakeToolchain" and these are both modern, right?

I've also seen the same happen for conanbuildinfo.txt which even appears to be required by conan.tools.cmake.CMake, at least I'm getting an error message when it's not present.

fjp commented 1 year ago

I'd be also interested why files such as graph_info.json and conanbuildinfo.txt are "polluting" the root folder where the conanfile.py is located. When using the new generators (CMakeDeps, CMakeToolchain) including the cmake_layout() why not place those files in the build/generators location or any other location inside build folder?

@memsharded is it possible to set a default install folder, for example through the conan client config? We want to avoid having those temporary files checked in by accident and we don't want to force everyone to use --install-folder for every conan command (conan install, build, etc). Currently we've added all those temporary files to .gitignore and use git clean to get rid of them. All those workarounds definitely not increase the user experience. Having all those temporary files by default in the build folder could avoid these workarounds. Is that something which can be done for conan 1.X and would this be a change to cmake_layout()?

memsharded commented 1 year ago

Hi @fjp

Moving those files to a different place would be breaking behavior, because they are needed by conan build command that do not evaluate the layout() at all.

We understand this is not the best user experience, but a potential fix is not simple and would be risky. Conan 2.0 has removed this file and is getting very, very close, so efforts are focused on it.