Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] package_folder not always defined in self.generate #13402

Closed
jsallay opened this issue Mar 9, 2023 · 3 comments
Closed

[bug] package_folder not always defined in self.generate #13402

jsallay opened this issue Mar 9, 2023 · 3 comments
Assignees

Comments

@jsallay
Copy link
Contributor

jsallay commented Mar 9, 2023

Environment details

  • Operating System+version: Ubuntu 22.04
  • Compiler+version: gcc11
  • Conan version: 2.0.1
  • Python version: 3.10

Steps to reproduce

I was attempting to build the pulseaudio recipe from conan-center-index. The generate method references self.package_folder and I discovered that this is not always defined. @prince-chrismc Looked at the issue with me and we discovered the following:
Works:
conan install --requires pulseaudio/14.2 --build=missing

Doesn't: (I did a clone of conan-center-index and went to the pulseaudio folder)
conan install all --version 14.2

I am able to reproduce it with a simpler recipe:

from conan import ConanFile

class T1Conan(ConanFile):
    name = "t1"
    version = "1.0.0"

    def generate(self):
        assert(self.package_folder)

Note that for t1, conan create . succeeds while conan install . fails.

Logs

For pulseaudio, I get the following error on install:
ERROR: conanfile.py (pulseaudio/14.2): Error in generate() method, line 105
f"--with-udev-rules-dir={os.path.join(self.package_folder, 'bin', 'udev', 'rules.d')}",
TypeError: expected str, bytes or os.PathLike object, not NoneType

I verified that self.package_folder is None on install, but not on create.

@memsharded memsharded self-assigned this Mar 9, 2023
@memsharded
Copy link
Member

Hi @jsallay

Thanks for your report.
This is not a bug, but very expected:

  • conan install --requires pulseaudio/14.2 --build=missing is referencing a package pulseaudio in the Conan cache. So it is a full, well defined package, so it will have package_folder
  • conan install all --version 14.2 is not installing pulseaudio, it is just installing the dependencies of pulsaudio, but pulseaudio will be just a consumer project, in the user folder, not in the local cache. Thus, it doesn't define a package_folder because there is no package at all, and certainly there is no package folder when the conanfile is in the user folder.

I hope this clarifies the issue.

@jsallay
Copy link
Contributor Author

jsallay commented Mar 9, 2023

@memsharded

Thanks for clarifying. I had asked on the slack if this was a bug in conan or in the pulseaudio recipe. It looks like pulseaudio needs to be updated. I can try and do a PR for that.

If I'm not mistaken, there are other places where conan enforces that certain values are used in certain places. If it is possible, it would be nice to raise an error if self.package_folder is used in the generate method. At a minimum it should be documented. I know you guys are really busy with the 2.0 release, so I understand that a lot of the documentation is still coming.

I think it is really confusing behavior that it works in some cases but not others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants