nate-parrott / Flashlight

The missing Spotlight plugin system
http://flashlight.nateparrott.com
Other
5.39k stars 411 forks source link

Flashlight not injecting plugins when user ScriptingAdditions directory is not writable #246

Closed kopischke closed 3 years ago

kopischke commented 9 years ago

Breaking this out of #38, which seems to have been lost in translation: Flashlight up to and including release 0.95.4 will not inject its plugins into Spotlight if ~/Library/ScriptingAdditions is not writable. Console log shows the following relevant terror messages:

01.12.14 12:26:33,872 com.nateparrott.Flashlight.FlashlightSIMBLAgent[82703]: Cannot make directory /Users/martin/Library/ScriptingAdditions/Flashlight.osax: Permission denied
01.12.14 12:26:33,885 com.nateparrott.Flashlight.FlashlightSIMBLAgent[82703]: #Flashlight SIMBLlinkItemAtPath error:Error Domain=NSCocoaErrorDomain Code=513 "“Flashlight.osax” couldn’t be linked because you don’t have permission to access “ScriptingAdditions”." UserInfo=0x7f9eabd582d0 {NSSourceFilePathErrorKey=/Applications/Flashlight.app/Contents/Library/LoginItems/FlashlightSIMBLAgent.app/Contents/PlugIns/Flashlight.osax, NSUserStringVariant=(
    Link
), NSDestinationFilePath=/Users/martin/Library/ScriptingAdditions/Flashlight.osax, NSFilePath=/Applications/Flashlight.app/Contents/Library/LoginItems/FlashlightSIMBLAgent.app/Contents/PlugIns/Flashlight.osax, NSUnderlyingError=0x7f9eabd57b90 "The operation couldn’t be completed. Permission denied"}

Permissions for ~/Library/ScriptingAdditions are as follows (set by OS X, no user intervention):

drwx------   2 root    staff

OS X 10.10.1 German locale, iMac 21.5″ end 2012 model

nate-parrott commented 9 years ago

Thanks for the report!

Do you have any idea why your ~/Library/ScriptingAdditions directory isn't writeable? It doesn't seem likely that it's protected by default. It's writeable on my machine, I never remember changing it explicitly, and I've installed Flashlight on some fairly clean installs of Yosemite. None of them have this problem.

It should be possible to change the directory in which the Flashlight.osax code injection bundle is saved to, but I'm not sure it make sense if this isn't a common issue. You may also want to bring this question up with the EasySIMBL team, since the code that touches ScriptingAdditions is forked from theirs, and they understand it better than I do.

kopischke commented 9 years ago

You are right: the folder is not protected by default. That is because since at least OS X 10.8 the ~/Library/ScriptingAdditions folder does not exist by default (I did a bit of sleuthing by sampling a few machines of coworkers and family members less prone to fiddling than I am; none of them has that folder in ~/Library; most of them updated to 10.10 from 10.8 or 10.9), meaning it has to created by the first software that wants to install there. If that software runs in the user’s context, all is fine; if, however, that first installer runs in another context, or choose to elevate privileges when creating the folder, other software that relies on scripting additions in the user folder and expects that folder to be writable without privilege elevation will silently (and to most users: inexplicably) fail to work.

I cannot judge how common this kind of scenario is, as it is rather hard to diagnose: even to savvy users, this kind of failure looks somewhat inscrutable. A solution would be checking the writability of the folder and elevating privileges if needed before linking the osax; as to deciding if that has to happen in your fork or upstream first, or that it is a corner case not worth your time, that is your call to make :).

Personally, I’ll go with

sudo chown -R martin:staff ~/Library/ScriptingAdditions
nate-parrott commented 9 years ago

Interesting. Just got an email from another person with the issue. If the case of other apps creating ~/Library/ScriptingAdditions is at all common, we should do something about it.

Do you think it makes sense to use a directory other than ScriptingAdditions? ("FlashlightSupport?"). I'd rather not ask the user to grant root, as it might scare people. Would this work? I'll probably experiment with find+replacing ScriptingAdditions with something else in the source and seeing if everything still works...

kopischke commented 9 years ago

I think that is what ~/Library/Application Support/Flashlight is for :). The ScriptingAdditions folder is meant for general purpose extensions anyway, so a single application extension like Flashlight’s doesn’t necessarily need to go there.