"Cannot read property 'icons' of null" With Drupal 8.0.0-rc2, no matter what, I get this error in the JS console:


  Uncaught TypeError: Cannot read property 'icons' of null


I think I have defined everything correctly, so I don't know what causes this error or what I missed.

Plugin definition:

/**


* @file
 * Contains \Drupal\codesnippet\Plugin\CKEditorPlugin\CodeSnippet.
 */

namespace Drupal\codesnippet\Plugin\CKEditorPlugin;

use Drupal\ckeditor\CKEditorPluginBase;
use Drupal\ckeditor\CKEditorPluginConfigurableInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\editor\Entity\Editor;
use Drupal\Core\Url;

/**
 * Defines the "codesnippet" plugin.
 *
 * @CKEditorPlugin(
 *   id = "codesnippet",
 *   label = @Translation("CodeSnippet"),
 * )
 */
class CodeSnippet extends CKEditorPluginBase implements CKEditorPluginConfigurableInterface {
  /**
   * {@inheritdoc}
   */
  public function getFile() {
    return drupal_get_path('module', 'codesnippet') . '/js/plugins/codesnippet/plugin.js';
  }

  /**
   * {@inheritdoc}
   */
  public function getConfig(Editor $editor) {
    return array(
      'codeSnippet_dialogTitleAdd' =&gt; t('Insert Code'),
      'codeSnippet_dialogTitleEdit' =&gt; t('Edit Code'),
    );
  }

  /**
   * {@inheritdoc}
   */
  public function getButtons() {
    return array(
      'CodeSnippet' =&gt; array(
        'label' =&gt; t('CodeSnippet'),
        'image' =&gt; drupal_get_path('module', 'codesnippet') . '/js/plugins/codesnippet/codesnippet.png',
      ),
    );
  }

  /**
   * {@inheritdoc}
   */
  public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
    $form_state-&gt;loadInclude('editor', 'admin.inc');

    $styles = $this-&gt;getStyles();

    $form['highlight_style'] = array(
      '#type' =&gt; 'select',
      '#title' =&gt; 'Highlightjs Style',
      '#description' =&gt; t('Select a style to apply to all highlighted code snippets. You can preview the styles at !link.', array('!link' =&gt; \Drupal::l('https://highlightjs.org/static/demo', Url::fromUri('https://highlightjs.org/static/demo/')))),
      '#options' =&gt; $styles,
      '#default_value' =&gt; !empty($form_state-&gt;storage['editor']-&gt;settings['plugins']['codesnippet']['highlight_style']) ? $form_state-&gt;storage['editor']-&gt;settings['plugins']['codesnippet']['highlight_style'] : 'arta.css',
    );

    return $form;
  }

  /**
   * Returns available stylesheets to use for code syntax highlighting.
   */
  private function getStyles() {
    $styles = preg_grep('/\.css/', scandir(drupal_get_path('module', 'codesnippet') . '/js/plugins/codesnippet/lib/highlight/styles'));
    $style_options = array();

    foreach ($styles as $stylesheet) {
      $style_options[$stylesheet] = $stylesheet;
    }

    return $style_options;
  }
}


The icon on the toolbar when editing the text format appears just fine, I can drag it in and out of the active toolbar, and my settings form shows. But due to the JS error generated, it does not work.

The plugin used is available on ckeditor.com, I dropped it into the plugins/codesnippet/js folder untouched.

I can't find any other examples of custom plugins using anything called 'icons'.
@Kevin are you sure the fix was due to CKEditor being upgraded in that Drupal version? I'm getting the same kind of issue trying to add the Link plugin, on Drupal 8.1.1, which is using CKEditor version 4.5.8.
Trying to find more insight on this issue.
edit: upon manually upgrading CKEditor to version 4.5.9 I'm getting much more illuminating error messages:

Uncaught Error: [CKEDITOR.resourceManager.add] The resource name &quot;link&quot; is
already registered.
Uncaught TypeError: Cannot set property 'getLinkAttributesParser' of undefined
Uncaught TypeError: Cannot read property 'icons' of null

So looks like this is colliding with the Link plugin that comes with Drupal (which is lacking some features). So I'll find a way to sidestep this name space collision and will update here.
edit: renaming the plugin proved unfruitful. Still getting:

Uncaught TypeError: Cannot read property 'icons' of null