magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.45k stars 9.29k forks source link

Sample Data Installation issue #2523

Closed pratikindia143 closed 8 years ago

pratikindia143 commented 8 years ago

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.

nkarthickannan commented 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

pratikindia143 commented 8 years ago

@karthickannan Thanks, it worked, but still not clear even with the error bin/magento sampledata:deploy => throws error it worked fine?

nkarthickannan commented 8 years ago

@pratikindia143

I'm also not clear why that error is being thrown. If anybody knows the reason, please do let us know.

Thanks

ghost commented 8 years ago

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.

nkarthickannan commented 8 years ago

@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?

dmitrii-fediuk commented 8 years ago

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

nkarthickannan commented 8 years ago

@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

dmitrii-fediuk commented 8 years ago

Maybe the Composer does not see your auth.json file?

nkarthickannan commented 8 years ago

@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

moleman commented 8 years ago

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.

Vinai commented 8 years ago

Great debugging @moleman

FossPrime commented 8 years ago

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/

nkarthickannan commented 8 years ago

@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

TommyKolkman commented 8 years ago

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?

ktomk commented 8 years ago

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?


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

peterjaap commented 8 years ago

+1 Just ran into this as well. The installer for sample data should just read out ~/.composer/auth.json. That's what its for.

ktomk commented 8 years ago

@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.

ktomk commented 8 years ago

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.

mazhalai commented 8 years ago

Linking to MAGETWO-48580 for internal tracking.

vancoz commented 8 years ago

Hi @ktomk, thank you for your attention to this issue, let me explain why Magento has var/composer_home directory, there is few reasons:

  1. Magento actually has more than 1 user, it has at least 2 users: web server and CLI user, and we would like to use the same credentials for both of them. And this is a reason why we would like to have dedicated composer home directory and sharing composer authentication and cache between users.
  2. Your current CLI user probably has different authentication setting even for the same domain (repo.magento.com) or maybe you just logged in as different user who is not authenticated yet.

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.

FossPrime commented 8 years ago

Commit that addressed the issue: 1c086f3868b248affb1aef9181eb8bf3e0875b60

markshust commented 7 years ago

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.

airtonix commented 6 years ago

Still a blocker for automation.

markshust commented 6 years ago

this ticket was fixed some time ago, works just fine with docker

ktomk commented 6 years ago

@markoshust: Any reference to the commit(s) you can attribute that fix to?

ktomk commented 5 years ago

Okay, looks like there was no fix -or- there is a regression to it in 2.3.0.

georgeirimiciuc commented 1 year ago

8 years later and still ran into this with Docker in WSL. The cp or ln of auth.json inside composer_home worked.