Search code examples
yoctobitbakerecipe

yocto: REQUIRED_VERSION not working, if recipe does not exist


I am using yocto with the current kirkstone LTS release(for a long time). I tried to use the version information for recipes.

See: https://docs.yoctoproject.org/4.0.6/ref-manual/variables.html?highlight=preferred_version#term-PV

So I have a recipe like this: 'my-recipe_1.0.0.bb'

Now I want to install that recipe in this version in my image. So I have another recipe like 'image.bb' that installs the recipe with something like: 'IMAGE_INSTALL += "my-recipe".

Now I want the build to fail, if that recipe version does not exist. I use REQUIRED_VERSION for this, see: https://docs.yoctoproject.org/4.0.6/ref-manual/variables.html?highlight=preferred_version#term-REQUIRED_VERSION

So I added in my image.bb a line like this: 'REQUIRED_VERSION_my-recipe="1.0.0"'

This works perfectly fine and I can switch this way between different versions of my recipe.

Now comes the question: If I require a version of my recipe that does not exist, the documentation says I will get an error and an immediate build error. But instead, my build takes an existing recipe but not the one I required.

This leads to an unacceptable situation where my build build something I do not expect. Now I wonder, if somebody has an idea what is going wrong.

I tried to use the REQUIRED_VERSION for different existing recipes. -> That worked as expected.

I tried to use the REQUIRED_VERSION for a not existing recipe. -> That did not work as expected. I got no build error.


Solution

  • Since the manual states that REQUIRED_VERSION "works in exactly the same manner as PREFERRED_VERSION" (except that it throws an error), maybe try using the forcevariable override:

    REQUIRED_VERSION_my-recipe:forcevariable = "1.0.0"
    

    Edit: Include this line in local.conf instead of the image.bb file for the expected behavior to take effect.