borgbase / vorta

Desktop Backup Client for Borg Backup
https://vorta.borgbase.com
GNU General Public License v3.0
2k stars 132 forks source link

bundled borg is preferred over system borg (macOS) #2100

Open ThomasWaldmann opened 1 week ago

ThomasWaldmann commented 1 week ago

Description

After stumbling over #2099 I also noticed that vorta seems to prefer the borg that comes bundled with it, even if the user has installed another borg on their system.

In my case, I have:

tw@MacBook-Pro ~ % which borg       
/opt/homebrew/bin/borg
tw@MacBook-Pro ~ % borg -V
borg 1.4.0

And that borg is the Apple Silicon binary, which would be better than the currently bundled Intel binary inside vorta.

Reproduction

OS

macOS 15

Version of Vorta

0.10.0 beta1

What did you install Vorta with?

Binary

Version of Borg

1.4.0

Logs

No response

m3nu commented 1 week ago

Not seeing that. It's using the Homebrew version for me.

Screenshot 2024-10-18 at 19 18 47
ThomasWaldmann commented 1 week ago

I just restarted vorta, still the same: it wants to use the bundled borg.

2024-10-18 21:05:20,068 - vorta.i18n - DEBUG - Loading translation succeeded for ['en-DE', 'en-Latn-DE', 'de-DE', 'de-Latn-DE', 'de'].
2024-10-18 21:05:20,072 - vorta.scheduler - WARNING - Failed to connect to DBUS interface to detect sleep/resume events
2024-10-18 21:05:20,228 - root - DEBUG - Not a private SSH key file: authorized_keys
2024-10-18 21:05:20,229 - root - DEBUG - Not a private SSH key file: ykpub
2024-10-18 21:05:20,243 - vorta.views.source_tab - DEBUG - Added item number 0 from 1
2024-10-18 21:05:20,612 - root - INFO - Using DarwinNetworkStatus NetworkStatusMonitor implementation.
2024-10-18 21:05:20,688 - vorta.borg.jobs_manager - DEBUG - Add job for site default
2024-10-18 21:05:20,688 - vorta.borg.jobs_manager - DEBUG - Start job on site: default
2024-10-18 21:05:20,689 - vorta.borg.borg_job - INFO - Running command /Applications/Vorta.app/Contents/Resources/borg-dir/borg.exe --version
2024-10-18 21:05:21,204 - vorta.borg.jobs_manager - DEBUG - Finish job for site: default
2024-10-18 21:05:21,204 - vorta.borg.jobs_manager - DEBUG - No more jobs for site: default
2024-10-18 21:05:25,290 - vorta.scheduler - DEBUG - Refreshing all scheduler timers
2024-10-18 21:05:25,291 - vorta.scheduler - INFO - Setting timer for profile 1
2024-10-18 21:05:25,291 - vorta.scheduler - DEBUG - Scheduling next run for 2024-10-19 00:03:32.628913
ThomasWaldmann commented 1 week ago

Just checked out vorta master branch and installed it to a venv:

That one finds the homebrew borg:

2024-10-18 21:48:17,192 - vorta.borg.borg_job - INFO - Running command /opt/homebrew/bin/borg --version
ThomasWaldmann commented 1 week ago
    @classmethod
    def prepare_bin(cls):
        """Find packaged borg binary. Prefer globally installed."""

        borg_in_path = shutil.which('borg')

        if borg_in_path:
            return borg_in_path
        elif sys.platform == 'darwin':
            # macOS: Look in pyinstaller bundle
            from Foundation import NSBundle

            mainBundle = NSBundle.mainBundle()

            bundled_borg = os.path.join(mainBundle.bundlePath(), 'Contents', 'Resources', 'borg-dir', 'borg.exe')
            if os.path.isfile(bundled_borg):
                return bundled_borg
        return None

Guess we need some additional logging in the else-branch for os.environ["PATH"] because the shutil.which obviously could not find my homebrew borg (and it is found if I use which in a terminal).

m3nu commented 1 week ago

vorta.spec has the path that's being searched. This is an Apple app setting. Currently it's

/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin

ThomasWaldmann commented 1 week ago

That might be, but something is broken there.

My borg is in /opt/homebrew/bin and does not get found by shutil.which.

maximede commented 5 days ago

Same issue on my side. If that helps, vorta was installed with brew too

m3nu commented 5 days ago

I think in the case of Thomas, it was Borg that was installed from homebrew.

Is there a difference when using Vorta downloaded from Github? (Homebrew also downloads from there, so it should be the same file). In which path is your Borg binary? Also in /opt/homebrew/bin?

maximede commented 5 days ago

Same for me, both borg and vorta are installed from homebrew

# which borg
/opt/homebrew/bin/borg
m3nu commented 5 days ago

Still can't reproduce this with fresh settings.

Screenshot 2024-10-22 at 13 47 33
ThomasWaldmann commented 5 days ago

BTW, IIRC finding the homebrew borg from vorta has worked for me at some time in the past. I remember installing the Apple Silicon version of borg from homebrew, so that Vorta does not use the bundled Intel version of borg. At that time, I verified that the Apple Silicon version gets invoked by vorta. But that was quite a while ago.

Recently, upgraded macOS and also vorta (see top post).

ThomasWaldmann commented 5 days ago

BTW, I reproduced the issue (see top post) with vorta 0.9.1 installed via brew.

It also wants to use the bundled borg and not the one from homebrew.