-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Sample Data Installation issue #2523
Comments
Please use the following commands:
Thanks |
@karthickannan |
I'm also not clear why that error is being thrown. If anybody knows the reason, please do let us know. Thanks |
The authentication error is caused by the fact that repo.magento.com requires authentication and the sample data modules (incorrectly) suppress the error from Composer. Your remediation steps are correct. |
@xcomSteveJohnson Thank you Steve. But I have the public and private keys added in my auth.json file. Then why the error is still popping up? |
Maybe your |
Here is my auth.json file content: {
"github-oauth": {
"github.com": "<snip>"
},
"http-basic": {
"repo.magento.com": {
"username": "<snip>",
"password": "<snip>"
}
}
} I am able to get the Magento 2 code base using composer. So, we can conclude that both the username & password are valid and the auth.json is also valid. Thanks |
Maybe the Composer does not see your |
As I told earlier, I'm able to get the Magento 2 project using this command composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition mage2 Also the auth.json file is in ~/.composer directory which is the composer home. Thanks |
I have the same problem and I have found the reason and a workaround. The reason why sampledata:deploy will not read auth from your ~/.composer folder is because the COMPOSER_HOME environment variable is set by the MagentoComposerApplication class in the magento/composer package (source code / repo for this package doesn't seem to be publicly available?) and this class is constructed when running the sampledata:deploy command, even though it is not really used by the command from what I can see because the command itself will create a clean Composer\Console\Application object. The class will set the COMPOSER_HOME environment variable to /var/composer_home so when sampledata:deploy is calling composer require, with the use of Composer\Console\Application, it will look for the auth.json in that folder. A workaround for this is to copy your ~/.composer/auth.json (if it contains the correct authentication credentials) to var/composer_home before running sampledata:deploy but I would rather prefer sampledata:deploy to use the global Composer directory. |
Great debugging @moleman |
I can Confirm @moleman 's solution works perfectly. Also, you don't need to copy it, a symbolic link will do the job just as well if not better. |
@moleman Great discovery!! @Vinai As per @moleman comment, the un-used MagentoComposerApplication class is setting the COMPOSER_HOME variable. If the class is not at all useful then why should Magento use this class to create a new problem? If there is any reason for using this class please let us know. Otherwise usage of this class should be avoided to prevent this issue from popping-out. Thanks |
I applied @moleman's solution and ran magento sampledata:deploy. It now just silently fails.
Anyone else with this problem? |
As @moleman has outlined (and I can confirm his findings) (findings are: #2523 (comment)) he is effectively reporting a flaw. The flaw is that magento does not work with the composer configuration, in specific, it does not work with the composer configuration of the user using composer. The flaw is that the environment variable Can someone please escalate this?
The error message for reference:
Despite authentication configured in composer global config. |
+1 Just ran into this as well. The installer for sample data should just read out ~/.composer/auth.json. That's what its for. |
@peterjaap: I also checked composer sources this morning because of the topic complex, there is the other option you can place It would be good to learn why the change of the composer home directory was introduced in the first place. |
The more I think about the var/composer_home dir, the less it makes any sense. For example, the deploy command to add the sample data is actually changing the composer.json file. So there can't be a reason to not create the auth.json file right next to it, too. And that's the file that I have identified as the only reason why the comoser home directory is changed. Looks more and more like the decision to create that composer_home folder was done in error not knowing about the more fitting location to add own credentials. |
Linking to MAGETWO-48580 for internal tracking. |
Hi @ktomk, thank you for your attention to this issue, let me explain why Magento has var/composer_home directory, there is few reasons:
Also we are not rewriting COMPOSER_HOME variable for your user, we just point it to var/composer_home only in case if you use Magento Web or CLI. About originally reported issue: we had this issue in sampledata:deploy command, it was preventing user interaction, but now this issue is fixed, and users can respond to CLI prompt and authenticate. If you have more question or proposals how to improve this behavior we are open for discussion. |
Commit that addressed the issue: |
I think this ticket should be re-opened, as with the current setup it's not possible to create an automated M2 build with composer + sample data. |
Fixed issues: - MAGETWO-89540: Static CompilerTest doesn't understand nullable type hint
Still a blocker for automation. |
this ticket was fixed some time ago, works just fine with docker |
@markoshust: Any reference to the commit(s) you can attribute that fix to? |
Okay, looks like there was no fix -or- there is a regression to it in 2.3.0. |
8 years later and still ran into this with Docker in WSL. The cp or ln of auth.json inside composer_home worked. |
I am trying to install sample data, but unable to install i tried following command
bin/magento sampledata:deploy
I am getting error as
[Composer\Downloader\TransportException] The 'https://repo.magento.com/packages.json' URL required authentication. You must be using the interactive console to authenticate
Even i am not getting prompt to enter username and password i.e public key and private key.
Is there any way i can include auth.json if yes please provide us sample auth and path. i have already added auth.json under /home/{user}/.composer/ folder or any other way to force the prompt for username and password.
I already tried composer update but no luck.
Please let me know is there anything else i have to do.
The text was updated successfully, but these errors were encountered: