'Where to put a binary when root/sudo is not an option?

I am currently working on an installer, written in Go. The main part is to automatically put the binary in the right place. This is not a problem with root/sudo permissions, but users don't want to use sudo, because a part of the script is web-loaded, and I totally understand that.

My issue is, that many systems don't have a single path in $PATH where non-admin users can write to. Here is the output of a fresh Debian installation:

# Permissions

[INFO] Has administrative rights: false

Can write to /usr/local/go/bin: false
Can write to /usr/local/sbin: false
Can write to /usr/local/bin: false
Can write to /usr/sbin: false
Can write to /usr/bin: false
Can write to /sbin: false
Can write to /bin: false
Can write to /usr/games: false
Can write to /usr/local/games: false

A fresh Debian installation does not have ~/bin / ~/.local/bin, etc.

Those are my options, as far as I am aware of:

  • Put the binary in a path and tell the user to add it to the env (not possible, the installer has to be fully automatic)
  • Require root/sudo (security concerns => not possible)
  • Create a new dir like ~/bin, put the binary there and add the path to the shell profile automatically (is this a good practise? )
    • If this is acceptable, what path would fit most (~/bin / ~/.local/bin, etc.)?

Please let me know if there is a better option! Currently, only the last one seems to work for me, but I really don't like modifying users shell profiles.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source