Custom theme: variable not made available in menu template
I think that it might work if you do like this,

function mytheme_preprocess_menu(&amp;$variables) {
  $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()-&gt;id());
  $variables['current_user_name'] = $user-&gt;getUsername();
}


Remember to clear the cache.

After debugging, we found out this this code worked, in the case somebody runs into the same issue.

function themename_preprocess_menu(&amp;$variables) {
  $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()-&gt;id());
  $variables['attributes']['uname'] = $user-&gt;getUsername();
}