Unable to execute Borgmatic when using pipx installation method #757
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'm trying to do and why
Issue
When installing using pipx, I'm unable to execute Borgmatic unless providing the full directory path
I'm following the instructions on this page.
Ubuntu 22.04LTS
Steps to reproduce
Troubleshooting/Repro
Prior to installing, I update my path with
sudo pipx ensurepath
:/root/.local/bin has been been added to PATH, but you need to open a new terminal or re-login for this PATH change to take effect.
I have verified that my PATH does contain
/root/.local/bin
:tyler@tl-pub-media:~$ echo $PATH /home/tyler/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/root/.local/bin
While installing, I receive this output:
I can execute when providing the full path:
I cannot execute when calling 'borgmatic':
Unable to execute Borgmatic when using pipx installation methodto Unable to execute Borgmatic when using pipx installation methodThanks for filing this! I think you're running into this problem because
pipx ensurepath
only applies to the shell for the Unix user account in which that command is run. In other words, when you runsudo pipx ensurepath
, that modifies thePATH
environment variable for the root user—but not for your non-root user. So I see a couple of options here:su
orsudo
to a root shell before running borgmatic as the root user. That should work because it'll use root'sPATH
./root/.local/bin
to your non-root user's PATH (in~/.bashrc
or similar) sosudo borgmatic
works as expected.pipx ensurepath
) as a non-root user instead of (or in addition to) a root user. This would only work though if you want to run borgmatic as a non-root user and therefore only have access to that user's files.I'll try to cover this use case a little better in the documentation.
Okay, I implemented some documentation updates that should hopefully clarify this situation. Please check it out and let me know what you think and whether this solves your issue at all: https://torsion.org/borgmatic/docs/how-to/set-up-backups/#installation
If not, I'd be happy to reopen this ticket and try something else. ("Happy" in that I'd be cursing the Python packaging ecosystem all the while.)
Thanks! Is there any risk if installing both root and non-root?
The only risk I can think of is that you might upgrade one and forget to upgrade the other—and end up with different versions installed!
After upgrading to bookworm and all my backups failing, I was getting the "module not found" error with borgmatic so I came to reinstall and see it's now via
pipx
instead ofpip
.I tried the root install and the user install and adding the path to
.bashrc
, but neither option makessudo borgmatic --version
work.I can do it with my user or as root but not with sudo:
halp?
Hmm.. Some thoughts:
.bashrc
? Did you usepipx ensurepath
to do it? You might give that a shot rather than manual path modifications.sudo
command work if you specifysudo -E
? That would indicate there's an environment variable (e.g.PATH
) not getting set properly uponsudo
.I used
pipx ensurepath
and it putexport PATH="$PATH:/root/.local/bin"
in my.bashrc
echo $PATH
shows/root/.local/bin
sudo -E
does not work.upon googling, it looks like there's a
secure_path
that's managed with visudo. I added/root/.local/bin
to the end of that list and nowsudo borgmatic --version
works.Nice detective work! I'm glad to hear that worked. I'll make a note in the docs about this solution. Thanks!