Skip to content

[bug] conan source does not properly handle the root folder #18376

@timviola-cmi

Description

@timviola-cmi

Describe the bug

When following the package development workflow

self.source_folder in the source() method is <conanfile_dir>/self.folders.source
however self.source_folder in all other methods is <conanfile_dir>/self.folders.root/self.folders.source

This makes it impossible to follow the package development workflow particularly when no_copy_source is true as both the source and build methods need to reference self.source_folder, but the path is different.

How to reproduce it

The issue is easily reproducible with the below simple conan file

from conan import ConanFile

class BasicConanfile(ConanFile):
    name = "conan_source_bug"
    version = "0.1"
    description = "Demonstrate a bug in conan source() method"
    no_copy_source = True
    
    def layout(self):
        self.folders.root = "root_folder"
        
    def source(self):
        self.output.info(f"In the source() method the Source folder is: {self.source_folder}")

    def build(self):
        self.output.info(f"In the build() method the Source folder is: {self.source_folder}")

Running conan source . and conan build . will yield the below results

Image

Image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions