Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed errors when running on macOS 10.13.3 #5

Closed
wants to merge 2 commits into from

Conversation

sedalu
Copy link

@sedalu sedalu commented Mar 5, 2018

I ran into several errors when running on macOS 10.13.3 with Apple's command line development tools installed. Most of the errors were due to non-available parameters for date. Also getopt and the while loop. With these changes I have been able to backup without error on a daily basis. I've also successfully tested "command unlock" and "expire".

@alphapapa
Copy link
Owner

Hi,

Thanks for sending this PR; I don't use Mac OS or have a machine to test it on.

I'm happy to support a wider Unix audience, but I'm not sure about some of these changes. The changes to the human_duration function, and using date +%s instead of date to get a timestamp, are probably fine, especially since that's the only place the function is called. But I don't want to replace getopt with the more primitive argument parsing; getopt normalizes arguments and ensures that options which require arguments do so. Are you sure there's not a way to use getopt on Mac OS? I imagine it can probably be installed in a package from Homebrew or something like that. In that case, I'd rather mention that in the documentation for Mac users.

Thanks.

@sedalu
Copy link
Author

sedalu commented Mar 6, 2018

Fair enough; Homebrew does provide package gnu-getopt. After running brew install gnu-getopt and setting the PATH (Homebrew doesn't symlink getopt), I reverted the getopt section and ran the below tests.

Using system getopt:

[sethdlumnah:~] $ which getopt
/usr/bin/getopt
[sethdlumnah:~] $ Documents/code/src/github.com/sedalu/restic-runner/restic-runner --debug --repo b2 command version
LOG (2018-03-05 22:49:07): REPO: SET:
LOG (2018-03-05 22:49:07): REPO: SET:
LOG (2018-03-05 22:49:07): REPO: SET:
...
LOG (2018-03-05 22:49:10): REPO: SET:
LOG (2018-03-05 22:49:10): REPO: SET:
LOG (2018-03-05 22:49:10): REPO: SET:
^C
[sethdlumnah:~] 130 $ 

Using gnu-getopt:

[sethdlumnah:~] $ PATH="/usr/local/opt/gnu-getopt/bin:$PATH"
[sethdlumnah:~] $ which getopt
/usr/local/opt/gnu-getopt/bin/getopt
[sethdlumnah:~] $ Documents/code/src/github.com/sedalu/restic-runner/restic-runner --debug --repo b2 command version
DEBUG: ARGS:  --debug --repo 'b2' -- 'command' 'version'
DEBUG: Command: command
DEBUG: Rest: version
LOG (2018-03-05 22:48:31): REPO:b2 SET:
DEBUG: Running: restic version
restic 0.8.3
compiled with go1.10 on darwin/amd64
LOG (2018-03-05 22:48:31): passthrough finished.  Duration: 0s  
[sethdlumnah:~] $

I also ran a backup without error using gnu-getopt.

@alphapapa
Copy link
Owner

Ok, so I think what needs to be done next is:

  1. Mention the need for GNU getopt on non-GNU/Linux systems in the readme.
  2. Check for the presence of getopt early in the script, and give a useful error if it's not found.
  3. Probably go ahead and make the timestamp-related changes you made. I'd like to think about this a bit more though.

Thanks for your help with this.

@alphapapa alphapapa self-assigned this Mar 6, 2018
@askielboe
Copy link

I see you merged the date stuff which is nice. I just want to comment that in order to make is work on macos I had to use gnu date instead of the macos bundled date. I installed gnu date using homebrew and added it to my PATH:

brew install coreutils
ln -s /usr/local/bin/gdate $HOME/.bin/date

alphapapa added a commit that referenced this pull request Mar 16, 2019
alphapapa added a commit that referenced this pull request Mar 16, 2019
@alphapapa
Copy link
Owner

Since the need for GNU date and getopt are mentioned in the readme now, I'm going to close this PR. If you think any other changes still need to be made, please let me know. Thanks.

@alphapapa alphapapa closed this Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants