fxpio / composer-asset-plugin

NPM/Bower Dependency Manager for Composer
MIT License
892 stars 156 forks source link

composer force to use https protocol for github not working #212

Closed hemc4 closed 7 years ago

hemc4 commented 8 years ago
 Installing dependencies (including require-dev)
  Failed to clone the git@github.com:jquery/jquery-dist.git repository, try running in interactive mode so that you can enter your GitHub credentials

  [RuntimeException]
  Failed to execute git clone --mirror 'git@github.com:jquery/jquery-dist.git' '/root/cache/vcs/git-github.com-jquery-jquery-dist.git/'

  install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...

I using

/usr/bin/composer.phar global require fxp/composer-asset-plugin:~1.0.3 and setting the config as /usr/bin/composer.phar config --global github-protocols https and still install is calling the url's with git protocol.

francoispluchino commented 8 years ago

Try with the last stable version of Composer (1.0.2) and this plugin (1.1.4).

francoispluchino commented 8 years ago

Is it always the case with the 1.2.x-dev version of this plugin?

hemc4 commented 8 years ago

This was the case with the combination of some composer version. I had gotten plugin 1.1.3 working with composer 1.0.0-alpha11

francoispluchino commented 8 years ago

Try with the last stable version of Composer (1.1.3) and this plugin (1.2.0).

cebe commented 7 years ago

composer config --global github-protocols https has no effect for me on the following versions:

$ composer global show 
Changed current directory to /home/cebe/.composer
fxp/composer-asset-plugin v1.2.2 NPM/Bower Dependency Manager for Composer
$ composer --version
Composer version 1.3.2 2017-01-27 18:23:41

see yiisoft/yii2-app-basic#102 for more details.

AAlvz commented 7 years ago

same issue here. see yiisoft/yii2-app-basic#102 for more details.

AAlvz commented 7 years ago

Any sign of solving this? Does anyone care? haha.. if someone could guide me I could fix this..

cebe commented 7 years ago

@francoispluchino do you have an idea what may be causing this and which code is responsible for this?

francoispluchino commented 7 years ago

With Composer v1.3.2 and composer-asset-plugin v1.3.0@dev and composer config --global github-protocols https:

{
    "require": {
        "bower-asset/jquery": "^2.2.4"
    }
}
$ root@HG-D01:/mnt/d/Tests/test82# composer install -vvv
Reading ./composer.json
Loading config file /root/.composer/config.json
Loading config file /root/.composer/auth.json
Loading config file ./composer.json
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/mnt/d/Tests/test82): git branch --no-color --no-abbrev -v
Executing command (/mnt/d/Tests/test82): git describe --exact-match --tags
Executing command (/mnt/d/Tests/test82): git log --pretty="%H" -n1 HEAD
Reading /root/.composer/composer.json
Loading config file /root/.composer/config.json
Loading config file /root/.composer/auth.json
Loading config file /root/.composer/composer.json
Loading config file /root/.composer/auth.json
Reading /root/.composer/auth.json
Reading /root/.composer/vendor/composer/installed.json
Loading plugin Fxp\Composer\AssetPlugin\FxpAssetPlugin
Running 1.3.2 (2017-01-27 18:23:41) with PHP 7.0.14-2+deb.sury.org~trusty+1 on Linux / 3.4.0+
Loading composer repositories with package information
Downloading https://packagist.org/packages.json
Writing /root/.composer/cache/repo/https---packagist.org/packages.json into cache
Updating dependencies (including require-dev)
Downloading http://packagist.org/p/provider-2013%24d7a13db83335964f68cececa1966742f314ee51f1a95e9d64c09326df76c4e78.json
Writing /root/.composer/cache/repo/https---packagist.org/p-provider-2013.json into cache
Downloading http://packagist.org/p/provider-2014%24122bb470d79e5c94e7b5019041da6e4ebb3362cfeeaa15cc5c8f82fe58092344.json
Writing /root/.composer/cache/repo/https---packagist.org/p-provider-2014.json into cache
Downloading http://packagist.org/p/provider-2015%24ec62df0994a602f8beb41c5c745c6acff17bf18be3a0df94c3a1e311d4ae2414.json
Writing /root/.composer/cache/repo/https---packagist.org/p-provider-2015.json into cache
Downloading http://packagist.org/p/provider-2016%24d9d8a9e6adf41d9222eab0190def6acc24a3963b11f4197535f069a493b401fe.json
Writing /root/.composer/cache/repo/https---packagist.org/p-provider-2016.json into cache
Downloading http://packagist.org/p/provider-2016-04%240c726efb0e3057004b8f81c330801375051e88fb621c3e9e54166def04c21654.json
Writing /root/.composer/cache/repo/https---packagist.org/p-provider-2016-04.json into cache
Downloading http://packagist.org/p/provider-2016-07%244eaa93cdd9087225169e3338c6da64611333eb4e4db819f215b54e286c96250b.json
Writing /root/.composer/cache/repo/https---packagist.org/p-provider-2016-07.json into cache
Downloading http://packagist.org/p/provider-2016-10%2416dc97d25d667727caea03ecace4d9a3d7b6df86d19202fda9d4e94bd4bc33d1.json
Writing /root/.composer/cache/repo/https---packagist.org/p-provider-2016-10.json into cache
Downloading http://packagist.org/p/provider-2017-01%246efcc7f97d0c9195b9e511ab380e6d7e1829d4f6378dec6aa44b5247aeb9b767.json
Writing /root/.composer/cache/repo/https---packagist.org/p-provider-2017-01.json into cache
Downloading http://packagist.org/p/provider-archived%248e498ea0cf861a3288705a27863706764ee18a17cca4b75296cd2ad6c697393a.json
Writing /root/.composer/cache/repo/https---packagist.org/p-provider-archived.json into cache
Downloading http://packagist.org/p/provider-latest%2426ddb337d5022a8a78b536b112dbe12e749d14be9a7163dd43b0fefc402a7871.json
Writing /root/.composer/cache/repo/https---packagist.org/p-provider-latest.json into cache
Downloading http://packagist.org/p/bower-asset/jquery%244cf05e4448f7974a447a2dbb07403c4db0c495d2564f6b53fed97e761f2689d2.json
Writing /root/.composer/cache/repo/https---packagist.org/provider-bower-asset$jquery.json into cache
Downloading https://bower.herokuapp.com/packages/jquery
Writing /root/.composer/cache/repo/https---bower.herokuapp.com-packages/jquery-6f2ab963b5a51d155d69ac091e52e506d1055057-package.json into cache
Adding VCS repository bower-asset/jquery
Downloading https://api.github.com/repos/jquery/jquery-dist
Downloading https://api.github.com/repos/jquery/jquery-dist/contents/bower.json?ref=master
Downloading https://api.github.com/repos/jquery/jquery-dist/commits/master
Downloading https://api.github.com/repos/jquery/jquery-dist/tags?per_page=100
Downloading https://api.github.com/repositories/28825109/tags?per_page=100&page=2
Downloading https://api.github.com/repos/jquery/jquery-dist/git/refs/heads?per_page=100
Reading bower.json of bower-asset/jquery (2.2.4)
Downloading https://api.github.com/repos/jquery/jquery-dist/contents/bower.json?ref=c0185ab7c75aab88762c5aae780b9d83b80eda72
Downloading https://api.github.com/repos/jquery/jquery-dist/commits/c0185ab7c75aab88762c5aae780b9d83b80eda72
Writing /root/.composer/cache/repo/github.com/jquery/jquery-dist/bower-c0185ab7c75aab88762c5aae780b9d83b80eda72 into cache
Importing tag 2.2.4 (2.2.4.0)
Resolving dependencies through SAT
Dependency resolution completed in 0.000 seconds
Analyzed 73 packages to resolve dependencies
Analyzed 56 rules to resolve dependencies
Package operations: 1 install, 0 updates, 0 removals
Installs: bower-asset/jquery:2.2.4
  - Installing bower-asset/jquery (2.2.4)Downloading https://api.github.com/repos/jquery/jquery-dist/zipball/c0185ab7c75aab88762c5aae780b9d83b80eda72
 Downloading: 100%Writing /root/.composer/cache/files/bower-asset/jquery/7e88380dd6ec5a5623acd19d8923f1dc7598e073.zip into cache from /mnt/d/Tests/test82/vendor/bower-asset/jquery/bcbbb6114cde052635ec77ed2459acdd
 Extracting archive
    REASON: Required by the root package: Install command rule (install bower-asset/jquery 2.2.4)

Reading /mnt/d/Tests/test82/vendor/composer/installed.json
Writing lock file
Generating autoload files

The HTTPS protocol is used, not the GIT protocol. Now if you force the use of the HTTPS protocol with Github, it's the Github API that called, and so, you will probably reach the anonymous rate limit if you don't use the Github Token.

On the other hand, and it is a native behavior of Composer, If you installed a dependency using GIT, but you want to use the HTTPS protocol later, The HTTPS protocol will be used for new installed dependencies, but Composer will continue to use the GIT protocol for dependencies already installed with this protocol.

Solution: remove your vendor directory.

AAlvz commented 7 years ago

@francoispluchino

Solution: remove your vendor directory.

  1. What if I don't have a vendor directory yet? :confused:
  2. Do you mean that if I clone my repository using ssh, the dependencies will try to use ssh as well?? Can I clone using ssh, and get dependencies using http? ... Anyway, the --prefer-dist flag should do this, shouldn't it? I'd like to avoid the token.

More info and full example in yiisoft/yii2-app-basic#102 :)

francoispluchino commented 7 years ago

Can I clone using ssh, and get dependencies using http?

Clone repositories with GIT protocol to solve the dependencies and download archives using HTTP, yes, It's possible.

If you don't want to use a API token for Github, don't use APIs but GIT protocol, for this, see the doc Use no-api option of VCS Githhub driver for the v1.3.0 and this doc for the v1.2.2.

I tested your command (with Composer v1.3.2 and composer-asset-plugin v1.3.0@dev):

$ php composer.phar create-project --prefer-dist --no-interaction --stability=dev yiisoft/yii2-app-basic basic

And the installation download the archives with HTTP, but the resolution of dependencies use the Github APIs, and my Token API is require, because the number of API calls exceeds the authorized limit (see this post).

If I add the github-no-api option in my composer.json file, Composer clones all repositories for the resolution of dependencies and download the archives using HTTP in the project as explained above (and uses the cached file if it exists).

Normally, your SSH key is not required. And I don't understand the error in your example. Maybe a git config insteadOf somewhere?