Closed pratikindia143 closed 8 years ago
@pratikindia143
Please use the following commands:
1) bin/magento sampledata:deploy => throws error 2) composer update 3) bin/magento setup:upgrade 4) sudo chown -R :www-data . 5) sudo find . -type d -exec chmod 770 {} \; && sudo find . -type f -exec chmod 660 {} \; && sudo chmod u+x bin/magento
Thanks
@karthickannan
Thanks, it worked, but still not clear even with the error bin/magento sampledata:deploy => throws error
it worked fine?
@pratikindia143
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 auth.json
is wrong: maybe it contains a syntax error or maybe is placed in a wrong location.
See the documentation: http://devdocs.magento.com/guides/v2.0/install-gde/prereq/dev_install.html#create-authjson
Here is my working example for a custom private composer repository with the http-basic
authentication: https://mage2.pro/t/256
@dfediuk
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 auth.json
file?
@dfediuk
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
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.
ln -s ~/.composer/auth.json var/composer_home/
@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.
~/Sites/magento-sandbox => magento sampledata:deploy ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) ✘ => ~/Sites/magento-sandbox`
Anyone else with this problem?
As @moleman has outlined (and I can confirm his findings) (findings are: https://github.com/magento/magento2/issues/2523#issuecomment-162534708) 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 COMPOSER_HOME
is changed albeit it's a user setting.
Can someone please escalate this?
COMPOSER_HOME
environment variable?var/composer_home
(relative to the Magento project) as composer home?magento/*sample-data*
packages?COMPOSER_CACHE
if not yet explicitly set- for this side-effect I've created a little PR to preserve the original cache location at least: https://github.com/magento/composer/pull/1)The error message for reference:
[Composer\Downloader\TransportException]
The 'https://repo.magento.com/packages.json' URL required authentication.
You must be using the interactive console to authenticate
Despite authentication configured in composer global config.
Edit: Ref: 4a9581ec1b9ca488b7e24f5444274885733cfb7e db7912cf6f1de4b235db4a2164f0fd5f4ba38cc7
+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 auth.json
next to composer.json
(in the same directory that is where the Magento 2 project resides). This makes it immune to the new COMPOSER_HOME.
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: 1c086f3868b248affb1aef9181eb8bf3e0875b60
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.
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.