rconradharris / reddit-background

Set your Linux and Mac OS X desktop background to images pulled from Reddit
101 stars 17 forks source link

Permission issue when using launchctl on macOS #24

Closed NickGaens closed 7 years ago

NickGaens commented 7 years ago

I've created a property list (.plist) which embodies reddit-background as such:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Disabled</key>
    <false/>
    <key>Label</key>
    <string>local.reddit-background</string>
    <key>Program</key>
    <string>/usr/local/bin/reddit-background/reddit-background</string>
    <key>RunAtLoad</key>
    <true/>
    <key>StandardErrorPath</key>
    <string>/tmp/local.reddit-background.err</string>
    <key>StandardOutPath</key>
    <string>/tmp/local.reddit-background.out</string>
</dict>
</plist>

But when trying to launch this using launchctl, it says:

Traceback (most recent call last):
  File "/usr/local/bin/reddit-background/reddit-background", line 791, in <module>
    main()
  File "/usr/local/bin/reddit-background/reddit-background", line 773, in main
    _clear_download_directory()
  File "/usr/local/bin/reddit-background/reddit-background", line 514, in _clear_download_directory
    shutil.rmtree(dirname)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 247, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 252, in rmtree
    onerror(os.remove, fullname, sys.exc_info())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 250, in rmtree
    os.remove(fullname)
OSError: [Errno 13] Permission denied: '/Users/nickgaens/Reddit Backgrounds/Desktop 1/A blooming California purplehead field in Ventura County [200.png'

I'm assuming there's a missing sudo on my part somewhere; any clue?

rconradharris commented 7 years ago

@NickGaens Seems like the permissions/ownership on the Reddit Backgrounds directory are messed up. Perhaps it was run as sudo the first time, so the directory is really owned by root(?)

Probably easiest to just delete the directory and recreate it making sure to not use sudo here. Altneratively you, can use chown -R and chmod -R to fix the permissions manually.

NickGaens commented 7 years ago

You were correct: the Reddit Backgrounds directory had root as its owner, which caused the permission problem I experienced. Using chown -R nickgaens /usr/local/bin/reddit-background indeed solved it.

Thanks!