Drupal 8, override template menu in custom module doesn't work, theme template is called instead
Your module function custommodule_menu_theme() is incorrectly named so hook_theme() isn't evoked and returning incomplete output; it needs, at least, the base hook &amp; render element elements entered so that it knows what hook to target and the render array to supply to the template.

/**
 * Implements hook_theme().
 */
function custommodule_theme($existing, $type, $theme, $path) {
  $theme = array();
  $theme['menu__main'] = array(
    'base hook' =&gt; 'menu',
    'render element' =&gt; 'menu',
  );
  return $theme;
}