Skip to content
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

Closed
pratikindia143 opened this issue Nov 25, 2015 · 27 comments
Closed

Sample Data Installation issue #2523

pratikindia143 opened this issue Nov 25, 2015 · 27 comments
Labels
Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@pratikindia143
Copy link

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
Copy link

@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
Copy link
Author

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

@nkarthickannan
Copy link

@pratikindia143

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

Thanks

@ghost
Copy link

ghost commented Nov 25, 2015

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
Copy link

@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
Copy link

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
Copy link

@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
Copy link

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

@nkarthickannan
Copy link

@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
Copy link

moleman commented Dec 7, 2015

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
Copy link
Contributor

Vinai commented Dec 7, 2015

Great debugging @moleman

@Vinai Vinai added the PS label Dec 7, 2015
@FossPrime
Copy link

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
Copy link

@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
Copy link

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
Copy link
Contributor

ktomk commented Jan 19, 2016

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 COMPOSER_HOME is changed albeit it's a user setting.

Can someone please escalate this?

  • What is the rationale to change the COMPOSER_HOME environment variable?
  • What is the rationale to use the directory var/composer_home (relative to the Magento project) as composer home?
  • What is the rationale to not cache the diverse magento/*sample-data* packages? (because COMPOSER_HOME is changed, there is no cache folder, Composer probably initializes it later. This should be easy to circumvent by retaining the origin 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: Preserve Composer cache directory in MagentoComposerApplication composer#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: 4a9581e db7912c

@peterjaap
Copy link
Contributor

+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
Copy link
Contributor

ktomk commented Jan 23, 2016

@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 referenced this issue in tkn98/magento2 Jan 23, 2016
@ktomk
Copy link
Contributor

ktomk commented Jan 24, 2016

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
Copy link
Contributor

Linking to MAGETWO-48580 for internal tracking.

@mazhalai mazhalai added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Jan 29, 2016
@vancoz
Copy link

vancoz commented Feb 3, 2016

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.

@vancoz vancoz closed this as completed Feb 3, 2016
@FossPrime
Copy link

Commit that addressed the issue:
1c086f3

@markshust
Copy link
Contributor

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.

magento-engcom-team pushed a commit that referenced this issue May 11, 2018
Fixed issues:
- MAGETWO-89540: Static CompilerTest doesn't understand nullable type hint
@airtonix
Copy link

Still a blocker for automation.

@markshust
Copy link
Contributor

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

@ktomk
Copy link
Contributor

ktomk commented Jul 28, 2018

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

@ktomk
Copy link
Contributor

ktomk commented Mar 5, 2019

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

@georgeirimiciuc
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests