By ulandreman on
I'm running composer 2.7.2 on a Linux Virtual Private Server hosted by GoDaddy.com.
When I do a composer diagnose, I get the message:
"Composer could not detect the root package (drupal/recommended-project) version, defaulting to '1.0.0'. See https://getcomposer.org/root-version"
I'm inferring that this is a problem and it would be good to fix it.
The message directs me to the composer troubleshooting guide and I read it, but I'm still unclear what my best course of action is.
Was the COMPOSER_ROOT_VERSION variable supposed to be set at some point, but it wasn't?
How do I find out what the right value is to set that environmental variable?
Thanks in advance.
Comments
COMPOSER_ROOT_VERSION
Setting it to the next logical version based on your project's history or starting with
1.0.0if you're just beginning can work. Use the commandexport COMPOSER_ROOT_VERSION=x.y.zin your terminal, replacingx.y.zwith your version.Is it a problem to not have a
Is it a problem to not have a version set?
I did not change my project.
I did not change my project. Suddenly composer 2.7.2 complains.
Where does it come from?
What needs to be set in composer.json?
Is the version referring to Drupal version?
Could you please give an example line what would be expected in the json file?
Thank you.
the warning is Composer's way
the warning is Composer's way of indicating that it's assuming your project's version in the absence of explicit information. For Drupal site development and management, this typically doesn't pose an issue for day-to-day operations, unless your project is distributed as a Composer package.
For a distributed package, a version line in
composer.jsonmight look like this (though, again, it's often unnecessary for site projects and can even be discouraged because it can conflict with VCS tagging):To silence the warning, you could define the
COMPOSER_ROOT_VERSIONenvironment variable as a workaround, especially if you're encountering this in automated environments like CI/CD pipelines. Setting this variable to a version that reflects your project's current state.To set this variable, you would typically use:
starting with a version that represents the state of your project (like
1.0.0for an initial state) and incrementing it as you make significant updates is logical.Please backup everything before making any changes.
Thank you!
Thank you!
It is explicitly refering to the Drupal site project?
Or could it be caused by a module that does not specify a version?
now you must deactivate each
now you must deactivate each module one by one as you clear the cache and see if the error is, you will know what module is causing all the havoc and make the necessary changes to it
There is no verbose output?
There is no verbose output?
composer update -vvv
composer update -vvv
made it clear for sure.
Much appreciated
Thanks for all your suggestions and assistance.
No effect
I'm experiencing the same issues on different hosts.
had no effect. :(
it only gives you more
it only gives you more information...
Then you can see if it is the ignoreble situation described above.
I made a fresh install today
I made a fresh install today "composer create-project drupal/recommended-project my_site_name" in a test directory. Directly afterwards a "composer diagnose" returned this message. So obviously it is not an additional module that causes it.
Fred
Hi,
Hi katorymnd
could you explain where do I have to use this code?
In $HOME/.profile or $HOME/
In $HOME/.profile or $HOME/.bash_profile works. Check which you have.
I don't understand
I'm sorry, I don't understand what I have to do.
Is it a path I can manage by SSH, SFTP...?
Where is inside a debian config?
I have put the code in /home
I have put the code in /home/user_me/.profile. Log in via SSH and type ls -al and you see either .profile or .bash_profile.
I don't know if my solution is proper but the message is gone.
Fred
All my sites started doing
All my sites started doing the same thing as well. I got rid of it by adding
to all the sites .bashrc file.
It will be fixed in next the release of Composer
It turns out that Add a warning message when Composer is not able to guess the root package version #11858 was too broad, causing many false positives as we have seen. It will be fixed when Only show warning about default version when not "project" type #11885 in the next release of Composer.