[bug] the “exported” files are not copied to the self.source_folder before calling the source() method
- Dominant language
- C++
- Stars
- 125
- Forks
- 382
- Avg merge
- 22h 39m
- Merged PRs (30d)
- 21
Description
### Describe the bug
According to the latest conan documentation (v 2.2) https://docs.conan.io/2.2/reference/conanfile/methods/source.html:
> The source() method should not access nor manipulate files in other folders different to the self.source_folder. All the “exported” files are copied to the self.source_folder before calling it.
But the exported files (in the `exports` attribute) don't seem to be copied in the source folder before the `source()` method is called.
### How to reproduce it
Conan version: 2.2.2
Python version: 3.8.10
OS: Ubuntu 20
In an empty directory:
`conanfile.py`:
```python
from conan import ConanFile
class BugReportConan(ConanFile):
name = "bug_report"
exports = ["foo.repos",]
def source(self):
self.output.info("============= 1")
self.output.info(self.source_folder)
self.output.info(self.export_folder)
self.output.info(self.recipe_folder)
with open("foo.repos") as stream:
pass
```
`foo.repos` (can be anything):
```
repositories:
foo/bar:
type: git
url: https://github.com/foo/bar.git
version: 0.0.0
```
Calling:
`conan create . --version 0.0.0`
gives an error that the `foo.repos` does not exist:
```
$ conan create . --version 0.0.0
======== Exporting recipe to the cache ========
bug_report/0.0.0: Exporting package recipe: /home/nathan/flyability/tmp/flya_conan-center-index/bug/conanfile.py
bug_report/0.0.0: Copied 1 '.py' file: conanfile.py
bug_report/0.0.0: Copied 1 '.repos' file: foo.repos
bug_report/0.0.0: Exported to cache folder: /home/nathan/.conan2/p/bug_re7a009f232436/e
bug_report/0.0.0: Exported: bug_report/0.0.0#db2cd895f4402fa553e3e67078d50209 (2024-04-05 09:07:39 UTC)
======== Input profiles ========
[...]
======== Computing dependency graph ========
[...]
======== Computing necessary packages ========
[...]
======== Installing packages ========
bug_report/0.0.0: Calling source() in /home/nathan/.conan2/p/bug_re7a009f232436/s
bug_report/0.0.0: ============= 1
bug_report/0.0.0: /home/nathan/.conan2/p/bug_re7a009f232436/s
bug_report/0.0.0: None
bug_report/0.0.0: /home/nathan/.conan2/p/bug_re7a009f232436/e
ERROR: bug_report/0.0.0: Error in source() method, line 13
with open("foo.repos") as stream:
FileNotFoundError: [Errno 2] No such file or directory: 'foo.repos'
```
Indeed, the file `foo.repos` is correctly exported in the export folder, but the source folder `s/` is empty:
```
$ tree -F /home/nathan/.conan2/p/bug_re7a009f232436/
/home/nathan/.conan2/p/bug_re7a009f232436/
├── d/
│ └── metadata/
├── e/
│ ├── conanfile.py
│ ├── conanmanifest.txt
│ └── foo.repos
├── es/
├── s/
└── s.dirty
5 directories, 4 files
```
And weirdly the `self.export_folder` is `None` and the `self.recipe_folder` is the folder where the files are exported (`/home/nathan/.conan2/p/bug_re7a009f232436/e`)
**Note**: I tested the same example with `conan==1.63.0` using `conan create . bug_report/0.0.0@
` and it works correctly (i.e. the source folder contains the `foo.repos` file)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.