Open radonish opened 4 years ago
Hi @radonish
yes, that is true. The self.user
and self.channel
fields cannot be used in that way if there is no user and channel defined. It is likely that such exception will be removed in 2.0.
In the meantime, you can capture the exception:
def requirements(self):
try:
user = self.user
channel = self.channel
except ConanException:
self.requires("Say/0.1")
else:
self.requires("Say/0.1@%s/%s" % (user, channel))
@memsharded, that's what I had been doing in the past but came across the documentation example and wondered if I was missing something silly.
Thanks!
Not really, those docs were before the possibility of removing the user/channel. So not a bug, but I think it deserves being updated in the docs. Lets move it there.
Looking at the example here where the requirements() method checks if the user and channel are set: https://docs.conan.io/en/latest/reference/conanfile/attributes.html#user-channel
For the scenario where the user/channel are not provided in the
conan create
command I get: conans.errors.ConanException: user not defined, but self.user is used in conanfileIs the documentation dated or is the behavior python version-related perhaps?
Python 3.7.1 Conan 1.21.1
Thanks