magento2: Magento version UNKNOWN
Preconditions
- Starting with Magento 2.2.5 installed via composer on CentOS7 (centos-release-7-6.1810.2.el7.centos.x86_64) on CentOS 7 & nginx version: nginx/1.12.2, php 7.0. My original Magento 2.2.5 composer.json is here. Config and data were migrated from a pre-existing Magento 1.9 store.
- Upgraded php to 7.1.28 and Magento 2.3.1. My final composer.json is here.
Steps to reproduce
- I (believe I have) upgraded to 2.3.1 using the script method. I hit issues along the way (documented here) but eventually I have managed to run the pre_composer_update_2.3.php script. To do this I had to amend the composer.json with
"name": "magento/product-community-edition", "version": "2.3.1",
Then I had to repeatedly run composer update
and progressively run remove all the pre-existing dependancies from composer.json that conflicted with those for the new upgrade.
- Probably not related, but, I had not installed mcrypt at this stage since it was not mentioned here, however after enabling compilation I got exception
main.CRITICAL: Notice: Use of undefined constant MCRYPT_BLOWFISH - assumed 'MCRYPT_BLOWFISH'
So, I installed it and after flushing caches and recompiling, both front and backends are working.
Expected result
- Expect to be able to retrieve a Magento version by any of these methods: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/versioning/check-version.html
Actual result
- I log into the admin area however at the bottom of the page I see “Magento ver. UNKNOWN”.
- Running:
bin/magento --version
gives: “Magento CLI”
- I see nothing in the headers when requesting http://<magento2-store>/magento_version
- There is no “magento/product-community-edition” mentioned in my composer.lock
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (3 by maintainers)
So I dug in a bit more, since I was curious 😃
It looks like when you install Magento2 using composer, it searches the version in a package what Magento calls a “system package”, that is determined if the name of that package matches the regex
magento/product-*
and then that version is used. (this regex is wrong in my opinion, it should probably be:magento/product-.+
, but that’s beside the question here). If it can’t find such a package, it assumes Magento is installed by cloning the git repo, and it will search for the version in the rootcomposer.json
file. But it looks like theversion
is no longer provided in thecomposer.json
file in the git repo, this got removed in: https://github.com/magento/magento2/commit/95bfd2c790f9f84c81f0f25807623d136555f7ea#diff-b5d0ee8c97c7abd7e3fa29b9a27d1780R4 (it is still there in tagged versions however, then it gets put back in place luckily). So how does composer then figure out a version if it isn’t specified in thecomposer.json
file? It looks like it takes the current branch in git which is checked out, this happens in Composer’s VersionGuesser class.So summary @benhtn:
composer.json
file which name starts with:magento/product
. If that’s the case, the version of that one should be used.composer.json
file (see below for an example file).composer/composer
being installed in your Magento shop (runcomposer show | grep composer/composer
to see which one is installed, latest available at the time of writing is 1.8.5 for Magento 2.3.1), or even an outdatedgit
version (I’m using 2.21.0).Hope this helps somehow 😃
As a reference, here is the root
composer.json
when setting up a new Magento 2.3.1 installation:Hi @benhtn Thank you for your report. problems with data migration from 1.x must be reported in https://github.com/magento/data-migration-tool repository.