fxpio / composer-asset-plugin

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

'Undefined index: name' on v1.2.0 #238

Closed AstRonin closed 8 years ago

AstRonin commented 8 years ago

After update plugin to version v1.2.0 I got error:

$ php composer.phar

  [ErrorException]
  Undefined index: name

Version 1.1.4 works fine.

francoispluchino commented 8 years ago

Do you use the last stable version of Composer (1.1.3)?

AstRonin commented 8 years ago

Yes,

$ php composer.phar -V
Composer version 1.1.3 2016-06-26 15:42:08

sorry, forgot to tell

francoispluchino commented 8 years ago

Can you copy your composer.json file? Or stack trace.

AstRonin commented 8 years ago

I can, but not all.

{
  "name": "yiisoft/yii2-app-advanced",
  "description": "Yii 2 Advanced Application Template",
  "keywords": ["yii2", "framework", "advanced", "application template"],
  "homepage": "http://www.yiiframework.com/",
  "type": "project",
  "license": "BSD-3-Clause",
  "support": {
    "issues": "https://github.com/yiisoft/yii2/issues?state=open",
    "forum": "http://www.yiiframework.com/forum/",
    "wiki": "http://www.yiiframework.com/wiki/",
    "irc": "irc://irc.freenode.net/yii",
    "source": "https://github.com/yiisoft/yii2"
  },
  "minimum-stability": "stable",
  "require": {
    "php": ">=5.4.0",
    "yiisoft/yii2": ">=2.0.7",
    ..............
    "bower-asset/jquery-migrate": ">=1.4.0"
 },
  "require-dev": {
    "yiisoft/yii2-codeception": ">=2.0.5",
    "yiisoft/yii2-debug": ">=2.0.6",
    "yiisoft/yii2-gii": ">=2.0.5"
  },
  "suggest": {
    "codeception/codeception": "Codeception, 1.8.*@dev is currently works well with Yii.",
    "codeception/specify": "BDD style code blocks for PHPUnit and Codeception",
    "codeception/verify": "BDD Assertions for PHPUnit and Codeception",
    "yiisoft/yii2-faker": "Fixtures generator for Yii2 based on Faker lib"
  },
  "scripts": {
    "post-create-project-cmd": [
      "yii\\composer\\Installer::setPermission"
    ]
  },
  "config": {
    "secure-http": false,
    "process-timeout": 1800
  },
  "extra": {
    "writable": [
      "backend/runtime",
      "backend/web/assets",

      "console/runtime",
      "console/migrations",

      "frontend/runtime",
      "frontend/web/assets"
    ],

    "asset-installer-paths": {
      "npm-asset-library": "vendor/npm",
      "bower-asset-library": "vendor/bower"
    },
    "asset-repositories": {
      "bower-asset/paper-dialog": {
        "type": "bower-git",
        "url": "https://github.com/PolymerElements/paper-dialog.git"
      }
    }
  }
}

How I can to do call composer with support showing stack trace? Because now I'm not see it...

holtkamp commented 8 years ago

See https://github.com/fxpio/composer-asset-plugin/blob/master/Resources/doc/index.md#overriding-the-config-of-a-vcs-repository

This section misses a name entry:

"asset-repositories": {
      "bower-asset/paper-dialog": {
        "type": "bower-git",
        "url": "https://github.com/PolymerElements/paper-dialog.git"
      }
    }
francoispluchino commented 8 years ago

Strange, normally the name is copied by the array key.

holtkamp commented 8 years ago

@francoispluchino aah, indeed, sorry, might have been to "quick" with a solution. Might be good to ignore my answer 馃槃

AstRonin commented 8 years ago

Yes, suggestion of @holtkamp helped, but in documentation the field name is not necessarily...

joshrickert commented 8 years ago

Using the array syntax with an explicit "name" property fixed this for me, in case anyone else is looking for a suitable workaround.

francoispluchino commented 8 years ago

Normally, it's fixed in v1.2.1.

joshrickert commented 8 years ago

I was also experiencing this issue on 1.2.1.

francoispluchino commented 8 years ago

Seriously? Give me your composer.json file because I have no problem with the latest stable version.

joshrickert commented 8 years ago
{
  "name": "joshrickert/wp-project",
  "type": "project",
  "license": "proprietary",
  "description": "A modern WordPress stack",
  "homepage": "https://roots.io/bedrock/",
  "keywords": [
    "bedrock", "roots", "wordpress", "stack", "composer", "vagrant", "wp"
  ],
  "support": {
    "issues": "https://github.com/roots/bedrock/issues",
    "forum": "https://discourse.roots.io/category/bedrock"
  },
  "config": {
    "preferred-install": "dist"
  },
  "repositories": [
    {
      "type": "composer",
      "url": "https://wpackagist.org"
    }
  ],
  "require": {
    "php": ">=5.5",
    "composer/installers": "~1.0.12",
    "vlucas/phpdotenv": "^2.0.1",
    "johnpbloch/wordpress": "^4.5",
    "wpackagist-plugin/advanced-custom-fields": "~4.4",
    "wpackagist-plugin/are-you-robot-recaptcha": "~2.2",
    "wpackagist-plugin/backwpup": "~3.3",
    "wpackagist-plugin/better-font-awesome": "~1.4",
    "wpackagist-plugin/bootstrap-for-contact-form-7": "~1.3",
    "wpackagist-plugin/contact-form-7": "~4.4",
    "wpackagist-plugin/disqus-comment-system": "~2.84",
    "wpackagist-plugin/eps-301-redirects": "~2.3",
    "wpackagist-plugin/enable-media-replace": "~3.0",
    "wpackagist-plugin/ewww-image-optimizer": "~2.5",
    "wpackagist-plugin/google-analytics-for-wordpress": "~5.4",
    "wpackagist-plugin/jonradio-current-year-and-copyright-shortcodes": "~1.0",
    "wpackagist-plugin/nginx-helper": "~1.9",
    "wpackagist-plugin/portfolio-post-type": "0.9.*",
    "wpackagist-plugin/recent-tweets-widget": "~1.6",
    "wpackagist-plugin/redis-cache": "~1.2",
    "wpackagist-plugin/regenerate-thumbnails": "~2.2",
    "wpackagist-plugin/tinymce-advanced": "~4.2",
    "wpackagist-plugin/wordfence": "~6.0",
    "wpackagist-plugin/wordpress-seo": "~3.0",
    "wpackagist-plugin/use-google-libraries": "~1.6.2",
    "wpackagist-plugin/add-headers": "~2.0",
    "fxp/composer-asset-plugin": "~1.1",
    "wpackagist-plugin/jetpack": "^4.0",
    "wpackagist-plugin/table-of-contents-plus": "^1601.0"
  },
  "extra": {
    "installer-paths": {
      "web/content/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
      "web/content/plugins/{$name}/": ["type:wordpress-plugin"],
      "web/content/themes/{$name}/": ["type:wordpress-theme"]
    },
    "asset-installer-paths": {
      "bower-asset-library": "web/content/assets"
    },
    "wordpress-install-dir": "web/wp",
    "asset-repositories": {
      "bower-asset/jr-paperjs-pluck-string": {
        "type": "bower-vcs",
        "url": "https://github.com/joshrickert/jr-paperjs-pluck-string.git"
      }
    }
  }
}

Output from composer install

Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing composer/installers (v1.0.25)
    Loading from cache

  - Installing johnpbloch/wordpress-core-installer (0.2.1)
    Loading from cache

  - Installing fxp/composer-asset-plugin (v1.2.1)
    Loading from cache

Plugin installation failed, rolling back
  - Removing fxp/composer-asset-plugin (v1.2.1)

  [ErrorException]
  Undefined index: name

Also, I've been running the plugin without issues as a project-level dependency, but if I install it globally I get the same exception. It also appears when I run composer validate.

francoispluchino commented 8 years ago

The plugin must be installed in global mode, not in project mode. Your global plugin version probably should not be the last stable release.

joshrickert commented 8 years ago

I thought that might be the case. See my edit to the comment above. Got the same error when I installed 1.2.1 globally.

francoispluchino commented 8 years ago

I have not my computer with me because I'm on vacation this week, but I would look your problem this Monday, but for me, you should remove the plugin in your project and reinstal/check the plugin in global mode.

joshrickert commented 8 years ago

No rush. Will do if I encounter further issues. For now, switching to the array syntax with an explicit "name" property got everything working again. Enjoy your vacation. 馃槃

ocramleznem commented 8 years ago

The same here. Hopefully my test will help. composer.json:

{
    "extra": {
        "asset-repositories": {
            "bower-asset/jquery": {
                "type": "bower-vcs",
                "url": "https://github.com/components/jquery.git"
            }
        }
    }
}

Tinkering with PHP 5.6.24, Composer 1.2.0, composer-asset-plugin 1.1.4, 1.2.0, 1.2.1

C:\Users\mmenzel\projects\asset-test
位 php composer.phar --version
Composer version 1.2.0 2016-07-19 01:28:52

C:\Users\mmenzel\projects\asset-test
位 php composer.phar global show
Changed current directory to C:/Users/mmenzel/AppData/Roaming/Composer
fxp/composer-asset-plugin v1.1.4 NPM/Bower Dependency Manager for Composer

C:\Users\mmenzel\projects\asset-test
位 php composer.phar global require fxp/composer-asset-plugin 1.2.0
Changed current directory to C:/Users/mmenzel/AppData/Roaming/Composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing fxp/composer-asset-plugin (v1.1.4)
  - Installing fxp/composer-asset-plugin (v1.2.0)
    Loading from cache

Writing lock file
Generating autoload files

C:\Users\mmenzel\projects\asset-test
位 php composer.phar global show
Changed current directory to C:/Users/mmenzel/AppData/Roaming/Composer
fxp/composer-asset-plugin v1.2.0 NPM/Bower Dependency Manager for Composer

C:\Users\mmenzel\projects\asset-test
位 php composer.phar --version

  [ErrorException]
  Undefined index: name

C:\Users\mmenzel\projects\asset-test
位 php composer.phar global require fxp/composer-asset-plugin 1.2.1
Changed current directory to C:/Users/mmenzel/AppData/Roaming/Composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing fxp/composer-asset-plugin (v1.2.0)
  - Installing fxp/composer-asset-plugin (v1.2.1)
    Loading from cache

Writing lock file
Generating autoload files

C:\Users\mmenzel\projects\asset-test
位 php composer.phar global show
Changed current directory to C:/Users/mmenzel/AppData/Roaming/Composer
fxp/composer-asset-plugin v1.2.1 NPM/Bower Dependency Manager for Composer

C:\Users\mmenzel\projects\asset-test
位 php composer.phar --version

  [ErrorException]
  Undefined index: name

//EDIT: Same ouput wirh Composer version 1.1.3 2016-06-26 15:42:08

//EDIT2:

Exception trace:
 () at C:\Users\mmenzel\AppData\Roaming\Composer\vendor\fxp\composer-asset-plugin\Repository\AbstractAssetVcsRepository.php:87
 Composer\Util\ErrorHandler::handle() at C:\Users\mmenzel\AppData\Roaming\Composer\vendor\fxp\composer-asset-plugin\Repository\AbstractAssetVcsRepository.php:87
 Fxp\Composer\AssetPlugin\Repository\AbstractAssetVcsRepository->__construct() at phar://C:/Users/mmenzel/projects/composer.phar/src/Composer/Repository/RepositoryManager.php:133
 Composer\Repository\RepositoryManager->createRepository() at C:\Users\mmenzel\AppData\Roaming\Composer\vendor\fxp\composer-asset-plugin\Repository\Util.php:38
 Fxp\Composer\AssetPlugin\Repository\Util::addRepository() at C:\Users\mmenzel\AppData\Roaming\Composer\vendor\fxp\composer-asset-plugin\FxpAssetPlugin.php:163
 Fxp\Composer\AssetPlugin\FxpAssetPlugin->addRepositories() at C:\Users\mmenzel\AppData\Roaming\Composer\vendor\fxp\composer-asset-plugin\FxpAssetPlugin.php:98
 Fxp\Composer\AssetPlugin\FxpAssetPlugin->activate() at phar://C:/Users/mmenzel/projects/composer.phar/src/Composer/Plugin/PluginManager.php:231
 Composer\Plugin\PluginManager->addPlugin() at phar://C:/Users/mmenzel/projects/composer.phar/src/Composer/Plugin/PluginManager.php:204
 Composer\Plugin\PluginManager->registerPackage() at phar://C:/Users/mmenzel/projects/composer.phar/src/Composer/Plugin/PluginManager.php:256
 Composer\Plugin\PluginManager->loadRepository() at phar://C:/Users/mmenzel/projects/composer.phar/src/Composer/Plugin/PluginManager.php:79
 Composer\Plugin\PluginManager->loadInstalledPlugins() at phar://C:/Users/mmenzel/projects/composer.phar/src/Composer/Factory.php:362
 Composer\Factory->createComposer() at phar://C:/Users/mmenzel/projects/composer.phar/src/Composer/Factory.php:554
 Composer\Factory::create() at phar://C:/Users/mmenzel/projects/composer.phar/src/Composer/Console/Application.php:318
 Composer\Console\Application->getComposer() at phar://C:/Users/mmenzel/projects/composer.phar/src/Composer/Console/Application.php:430
 Composer\Console\Application->getPluginCommands() at phar://C:/Users/mmenzel/projects/composer.phar/src/Composer/Console/Application.php:135
 Composer\Console\Application->doRun() at phar://C:/Users/mmenzel/projects/composer.phar/vendor/symfony/console/Application.php:123
 Symfony\Component\Console\Application->run() at phar://C:/Users/mmenzel/projects/composer.phar/src/Composer/Console/Application.php:104
 Composer\Console\Application->run() at phar://C:/Users/mmenzel/projects/composer.phar/bin/composer:43
 require() at C:\Users\mmenzel\projects\composer.phar:24
jk commented 7 years ago

@francoispluchino Any news on this issue?

ocramleznem commented 7 years ago

I'm still having this issue but I'm getting around with setting a name to the given repositories.

francoispluchino commented 7 years ago

Fixed by fb19e04bab8f6cbca46e9f12b00ce9fa5054b4f5.