1

Conan version: 2.0.13

I have a conan recipe where I define the set_version() method to set my package version based on an external script.

When I try to generate the package by doing

conan create .

I get the next error:

ERROR: conanfile didn't specify version

It seems that I must use --version flag for it to work and that set_version() is not called.

  1. --version is an optional parameter of conan
  2. set_version() method is defined in conanfile
  3. For what I know, set_version() will be automatically called when doing conan create or conan export

What am I missing?

(EDIT)

    def set_version(self):
        if self.version:
            return
        version_script = self.recipe_folder / "scripts" / "version"
        self.version = check_output([version_script], text=True).strip()
3
  • Please, show your recipe that you are using. The set_version works even when there is no self.version defined in the recipe, it's a tested case. Probably you are having an issue to get the version from your script. Plus, you should set self.version in set_version Commented Nov 3, 2023 at 18:51
  • self.version property is not manually set in the recipe; only in set_version() Commented Nov 3, 2023 at 18:58
  • It is possible that the result of check_output is empty? please print the value and execute, to double check it is getting a value. If it is getting a value and still complaining, I'd file a ticket in github.com/conan-io/conan/issues Commented Nov 3, 2023 at 23:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.