-
Notifications
You must be signed in to change notification settings - Fork 14
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
Wrong ODOO_VERSION in bootstrap #51
Comments
@ddejong-therp I don't see a bug in this part of the code https://github.com/sunflowerit/waftlib/blob/master/bootstrap#L41C66-L41C78 , if Additionally, if you follow a method like the one https://github.com/sunflowerit/waftlib/blob/master/bin/addons#L24-L28 , you will import the variables from @thomaspaulb what do you think? |
The way I've known waft thus far is that upon initial clone for a new project, you can't go wrong because it will warn you to choose an ODOO_VERSION in
Another usecase is the cloning of an existing project's waft. But, in that case a symlink to the correct Where it goes wrong is when a certain Odoo version has been set up already, and then I suddenly want a different version, and some old files are still left. In such a case, I have to clean everything up first:
Because this is most of the time still faster than to re-clone the Odoo and OCA repositories from scratch, I still jump through the above hoops instead of removing everything and cloning a fresh As for your migration case, there is probably a way in which it can go wrong, but can't you solve that in the migration script itself? If the ODOO_VERSION variable of the main project is loaded beforehand, that's wrong anyway, so maybe:
As to your suggested solution to load all the env variables at the beginning of the waft, I think that does already happen, rather the problem is that it also takes any pre-set variables along for the ride, which could be wrong. So maybe in that case a reset function should be called at the beginning: https://stackoverflow.com/questions/9671027/sanitize-environment-with-command-or-bash-script |
Finally, a solution could maybe be that we always unset ODOO_VERSION at the beginning of bootstrap and build, and we then load the env variables, and then we check if it's now defined, and if not, we exit. That way, at least it always fails when it's not defined. And it can't secretly inherit ODOO_VERSION from the caller script. |
@Hussam-Suleiman @ddejong-therp Which do you like best |
In my opinion, we need to improve the script so that it only modifies the variables we expect to be changed during execution. |
@thomaspaulb Yeah ok, I think my problems with the migration builds were not really caused by what I thought it was initially. I now understand how to prevent this. But I still believe it is a (small) bug, that after you've bootstrapped with a different version, and are trying to do it again with another version, it will copy the wrong .env-default template, if you didn't edit .env-shared as well. The templates of .env-shared & .env-default have a line which set ODOO_VERSION, while .env-secret does not. It probably won't do much harm to be honest, it's just a small nuisance that's all. I kind of like the solution of unsetting it, and then loading the .env files, like you suggested Tom. |
@ddejong-therp Maybe using |
Well for the context of the migration script, ODOO_VERSION is already correctly in .env-secret @Hussam-Suleiman . But for the migration script I'm thinking of copying .env-secret .env-shared & .env-default myself, instead of relying on bootstrap to do it for me, and I think it will work fine then as well. |
@ddejong-therp I think, copying .env-secret will be enough, because the variables in .env-secret will override all variables in .env-default and .env-shared |
@ddejong-therp I saw you're now not running bootstrap but copying the files yourself instead. I'm not sure if you're now still running bootstrap somewhere, if yes, then great, if not, then that's risky I guess because then someone needs to run it manually? I think the correct solution is to copy |
@thomaspaulb Yes I'm still running bootstrap somewhere. It was just a simple workaround around the bug, that I can do to at least continue using the rebuild switch on the migration script. The correct solution you proposed is essentially what the migration script already does at the moment. The only difference is that instead of |
I've noticed that when I use the migration script to set up build directories for a migration, it may go wrong because the build has been set up to use a wrong python version.
After investigating this issue, I've noticed that it would set up certain files (like .env-default, .python-version) from the wrong template file.
See these logs for example:
It links .env-default from the 16.0 instead of 12.0
It could link the .python-version from 16.0 instead 12.0 too, which will break a lot more.
See this line: https://github.com/sunflowerit/waftlib/blob/master/bootstrap#L41C66-L41C78
At this point,
$ODOO_VERSION
is still not necessarily set by anything in waft.The .env-default file may have been edited to not define the variable, so then it would use the value for
$ODOO_VERSION
, which could have been previously defined.In the migration script,
$ODOO_VERSION
is already defined becausewaftlib/bin/migrate.py
loads them from the.env-*
files in the top build directory. Then that script invokes the bootstrap script of another waft build while$ODOO_VERSION
is already defined.I think what needs to happen, is that somewhere at the top of the script the
.env-*
files need to be called if they exist, so that all the variables (including$ODOO_VERSION
) of the waft sub-build are available.Even if the migration script is not involved, someone could edit and remove the
$ODOO_VERSION
variable from .env-default, then use./bootstrap
, and then things would break, because$ODOO_VERSION
would not be set yet.The text was updated successfully, but these errors were encountered: