LSOpenURLsWithRole() failed with error -10810 for the file ...
can be caused by trying to open a script
that itself calls /usr/bin/open
I.e. MacOS /use/bin/open is not trivially reentrant.
DETAIL
Alvin Alexander provided some clues to this MacOS error:
Mac OS X 'LSOpenURLsWithRole() failed with error' | alvinalexander.com
I had a slightly different cause of
LSOpenURLsWithRole() failed with error -10810 for the file ...
I have some shell scripts that call "open SOME-MAC-APP",
where open = /usr/bin/open
$ bash 1349 $> open -h
Usage: open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-b <bundle identifier>] [-a <application>] [filenames] [--args arguments]
Help: Open opens files from a shell.
By default, opens each file using the default application for that file.
If the file is in the form of a URL, the file will be opened as a URL.
Options:
-a Opens with the specified application.
-b Opens with the specified application bundle identifier.
-e Opens with TextEdit.
-t Opens with default text editor.
-f Reads input from standard input and opens with TextEdit.
-F --fresh Launches the app fresh, that is, without restoring windows. Saved persistent state is lost, excluding Untitled documents.
-R, --reveal Selects in the Finder instead of opening.
-W, --wait-apps Blocks until the used applications are closed (even if they were already running).
--args All remaining arguments are passed in argv to the application's main() function instead of opened.
-n, --new Open a new instance of the application even if one is already running.
-j, --hide Launches the app hidden.
-g, --background Does not bring the application to the foreground.
-h, --header Searches header file locations for headers matching the given filenames, and opens them.
such as "open /Applications/p4v.app".
Trying to make a shell script that calls open
into an app that can itself be called via open seems to be not supported
- i.e. open is not reentrant, and least not trivially.
It is this "open within an open" that was causing
LSOpenURLsWithRole() failed with error -10810 for the file ...
$ bash 1258 $> diff p4v p4v-ag
16c16
< P4_EXECUTABLE=/Applications/p4v.app
---
> P4_EXECUTABLE=/Applications/p4v.app/Contents/MacOS/p4v
18c18
< open "$P4_EXECUTABLE" $@
---
> "$P4_EXECUTABLE" $@
The p4v-ag script (the other can be inferred)
$ bash 1259 $> cat p4v-agI make both of these shell scripts into MacOS apps
#!/bin/sh
# Simple script to run Perforce (P4) commands on macos
export P4CONFIG=.p4config
P4_EXECUTABLE=/Applications/p4v.app/Contents/MacOS/p4v
"$P4_EXECUTABLE" $@
$ bash 1261 $> macos-appify p4vRunning the open with open gives the error:
/Users/glew/bin/p4v.app
$ bash 1262 $> macos-appify p4v-ag
/Users/glew/bin/p4v-ag.app
$ bash 1263 $> open ./p4v.appRunning the other does not.
LSOpenURLsWithRole() failed with error -10810 for the file /Users/glew/bin/p4v.app.
✗
$ bash 1264 $> open ./p4v-ag.app
✓
No comments:
Post a Comment