restic-browser icon indicating copy to clipboard operation
restic-browser copied to clipboard

Issue with $PATH on OSX

Open darthlite opened this issue 2 years ago • 15 comments

Thanks for this tool. I'm having an issue that I don't know how to solve (sorry if this is a basic question).

I have both restic and rclone (for the repository) in my $PATH, but when I run restic-browser it does not detect restic and asks me to manually set the path to the executable. Then, when I do that, and try to browse my rclone repository, I get an error saying rclone is not in the $PATH.

How do I fix this? I'm running MacOS Ventura btw and using zsh ($PATH is defined in the ~/.zshrc file).

darthlite avatar Oct 30 '22 15:10 darthlite

Same here with the same config. Paths to restic and rclone are in the .zshrc file as

export PATH="$PATH:/usr/local/bin"
export PATH="$PATH:/opt/homebrew/bin"
export PATH="$PATH:/opt/homebrew/sbin"

but they are not detected, even after source .zshrc or a reboot (zsh is now the standard shell in macOS; rclone got installed via homebrew)

necrevistonnezr avatar Nov 01 '22 09:11 necrevistonnezr

I had the same issue, and I found a workaround which suits my needs.

Opening Restic-Browser.app from CLI it works perfectly and uses RESTIC_REPOSITORY and RESTIC_PASSWORD from env.

Simply use the good old open command:

e.g.

open /PATH/TO/Restic-Browser.app

There was also a PR: which was not merged due This has some side-effects. Closed until resolved.

https://github.com/emuell/restic-browser/pull/27

osiktech avatar Nov 04 '22 09:11 osiktech

I had the same issue, and I found a workaround which suits my needs.

Opening Restic-Browser.app from CLI it works perfectly and uses RESTIC_REPOSITORY and RESTIC_PASSWORD from env.

Simply use the good old open command:

e.g.

open /PATH/TO/Restic-Browser.app

Can confirm that this works for me. Thanks!

darthlite avatar Nov 06 '22 16:11 darthlite

How do I fix this? I'm running MacOS Ventura btw and using zsh ($PATH is defined in the ~/.zshrc file).

It's unfortunately quite a pain to configure PATH for apps started with Finder on OSX.
See e.g. https://serverfault.com/questions/16355/how-do-i-set-the-global-path-environment-variable-on-os-x#146142 All those workarounds seem to no longer work in newer versions of OSX.

The easiest way around this may be installing the restic binary to some path which already is in PATH by default, in you don't want to start in from the terminal app.

emuell avatar Nov 06 '22 17:11 emuell

Thanks for the clarification. Would a solution in which users specify the path to restic and/or rclone once and have it saved in Restic Browser's config work (and hopefully be easy to implement)?

darthlite avatar Nov 06 '22 19:11 darthlite

I agree, this could be a solution. Something like

  • Check $PATH for restic binary and use it if found
  • If not found in $PATH open a dialog and let user set location
    • this is partly already implemented. just safe the value somewhere suitable
  • Throw an error when no binary is given or not working

Another solution could be, to bundle restic together with Restic-Browser. Although this would be probably a completely different approach.

osiktech avatar Nov 06 '22 21:11 osiktech

Thought about bundling restic too, but this and saving the path to the located restic binary also doesn't fix darthlite's second problem: that rclone could also not be found.

emuell avatar Nov 06 '22 21:11 emuell

Why not just save both the path to restic and rclone (if used)?

darthlite avatar Nov 07 '22 03:11 darthlite

@emuell I checked your stackoverflow link. The solution which points to, put a file in /etc/paths.d/ actually looks like a viable solution.

My suggestion, leave this part to the user: simply check with Restic-Browser if it can locate third party dependencies like restic and clone and whatnot. If Restic-Browser is not able to detect those, give the user a link to the README.md with an installation howto. I would be willing in extending the README.md in that direction.

This way, the code changes on your end are minimal and you provide the user with the necessary information.

@darthlite: depending on your setup, I guess you are using homebrew to install restic and rclone, simple put a textfile in /etc/paths.d/ called homebrew and put in the homebrew bin-path. On newer Macs it is usually something like /opt/homebrew/bin/ in the past it was usually /usr/local/bin if I remember correctly. Best to check this with which restic and/or which rclone

Restart your Mac since the files in this directory are as it seems only read at system start and you should be good to go.

osiktech avatar Nov 07 '22 07:11 osiktech

@emuell I checked your stackoverflow link. The solution which points to, put a file in /etc/paths.d/ actually looks like a viable solution.

My suggestion, leave this part to the user: simply check with Restic-Browser if it can locate third party dependencies like restic and clone and whatnot. If Restic-Browser is not able to detect those, give the user a link to the README.md with an installation howto. I would be willing in extending the README.md in that direction.

This way, the code changes on your end are minimal and you provide the user with the necessary information.

@darthlite: depending on your setup, I guess you are using homebrew to install restic and rclone, simple put a textfile in /etc/paths.d/ called homebrew and put in the homebrew bin-path. On newer Macs it is usually something like /opt/homebrew/bin/ in the past it was usually /usr/local/bin if I remember correctly. Best to check this with which restic and/or which rclone

Restart your Mac since the files in this directory are as it seems only read at system start and you should be good to go.

This method does not work. It adds new path to user PATH but does not make difference for restic-browser ability to find needed binaries.

kapitainsky avatar Nov 24 '22 08:11 kapitainsky

what works for me is to make sure that required path is in my shell PATH and then instead of starting restic-browser from Finder start it from Terminal:

/Applications/Restic-Browser.app/Contents/MacOS/restic-browser

both restic and rclone path should be configurable and remembered by rclone-browser. This would be ideal solution.

kapitainsky avatar Nov 24 '22 08:11 kapitainsky

both restic and rclone path should be configurable and remembered by rclone-browser.

Unfortunately, as mentioned above, this would only work for the restic binary. There's no way to pass a PATH to the restic binary so that it can find rclone.

emuell avatar Nov 24 '22 12:11 emuell

Depending on which version of OSX you can also try following solution from Homebrew's FAQ:

https://docs.brew.sh/FAQ#my-mac-apps-dont-find-homebrew-utilities

And here's a more detailed explanation on how to change the PATH with launchctl: https://sparanoid.blog/749646

emuell avatar Nov 24 '22 12:11 emuell

both restic and rclone path should be configurable and remembered by rclone-browser.

Unfortunately, as mentioned above, this would only work for the restic binary. There's no way to pass a PATH to the restic binary so that it can find rclone.

are you sure?

I think restic allows to specify explicitly rclone binary location

-o rclone.program=/path/rclone

kapitainsky avatar Nov 24 '22 14:11 kapitainsky

-o rclone.program=/path/rclone

Thanks. Wasn't aware of this option.

Then this indeed would work, but will require a new "preferences" dialog in Restic Browser to set up those paths.

emuell avatar Nov 27 '22 12:11 emuell

Another workaround: you can use this tool https://github.com/sveinbjornt/Platypus to create an app that runs this script

Create a restic-with-path.sh or whatever and change path to where your restic is

#!/usr/bin/env sh

export PATH="$PATH:/opt/local/bin:/usr/local/bin"
open -a 'Restic-Browser.app'

and launch this app instead of the original

eugenesvk avatar Aug 15 '23 15:08 eugenesvk

The next version of Restic Browser will look for for restic in the following paths on MacOS, if it cannot be found in PATH: /usr/local/bin:/opt/local/bin:/opt/homebrew/bin:~/bin.

This should cover most of the default locations where restic is installed, so hopefully all those PATH hacks won't be necessary on OSX anymore.

This feature hasn't been released yet, but most recent builds that include it can be downloaded here: https://github.com/emuell/restic-browser/actions

emuell avatar Oct 28 '23 15:10 emuell

The next version of Restic Browser will look for for restic in the following paths on MacOS, if it cannot be found in PATH: /usr/local/bin:/opt/local/bin:/opt/homebrew/bin:~/bin.

This should cover most of the default locations where restic is installed, so hopefully all those PATH hacks won't be necessary on OSX anymore.

This feature hasn't been released yet, but most recent builds that include it can be downloaded here: https://github.com/emuell/restic-browser/actions

My copy of Rclone is at /usr/local/bin but it's still not finding it. I'm assuming since this issue is closed, that's been fixed? How can you set the path so that Restic-Browser sees it? I'm running v0.3.0.

akrabu avatar Dec 06 '23 19:12 akrabu

Yes, it should have been found automatically, when it's located at this path. Which filename does the restic binary have? It must be just "restic", not "restic-vsomething". Also does location the binary manually work?

emuell avatar Dec 07 '23 16:12 emuell