How to access `whoami`

A user of our snap says one of our software’s dependencies needs to access the whoami command.

How do I allow this? I couldn’t find any mention of whoami in the interfaces/builtin directory of the snapd repo.

When I run snappy-debug, I’m told that I need to ship it with my snap. However, putting it in the stage-packages section of my snap doesn’t work:

Failed to fetch stage packages: Error downloading packages for part 'my-part': The package 'whoami' was not found..

I can’t use layouts. The source path needs to be in $SNAP but whoami is in /usr/bin or /bin.

The whoami command is part of the coreutils package. You could try doing something like this to pick the one command from that package:

parts:
  ...
  whoami:
    plugin: nil
    stage-packages:
      - coreutils
    stage:
     - usr/bin/whoami
2 Likes