Quantcast

El Capitan: App is terminated on double-click, but runs from terminal (open -a app)

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

El Capitan: App is terminated on double-click, but runs from terminal (open -a app)

bostjan
Hi,

We have a legacy Mono Windows Forms app that was running without problems on Yosemite but does not run on El Capitan.
- I have downloaded the new Mono MDK-4.0.4.4. and re-package the app using the macpack.
- Now the app runs/is opened normally when executing command in terminal: open -a
(app) or when calling mono --debug (app)
- But does not run when double clicking on app inside Finder or LounchPad. The app icon shows just briefly then is immediately terminated.

Any idea?

BR,
Bostjan

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: El Capitan: App is terminated on double-click, but runs from terminal (open -a app)

creatorul
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Hey,

I got the same problem and even opened a thread here with the description:
http://stackoverflow.com/questions/33183502/mono-on-mac-os-x-el-capitan-lsopenurlswithrole

I've narrowed it down to the launch script generated by macpack in Contents/MacOS folder:

ln -s `which mono` ".bin/$APP_NAME"

This line is close to the end of the file and creates a symlink in /Applications/YourApp.app/Contents/Resources/bin folder. The symlink points to mono location which is: /usr/local/bin/mono on El Capitan as opposed to /usr/bin/mono on earlier versions.
From the small debug I did using Console it seems `which mono` works correctly when doing "open -a" from terminal but on double-click it doesn't return anything causing launchd to crash:

com.apple.xpc.launchd[1] (MyApp.111072[1451]): Service exited with abnormal code: 127

Perhaps someone can check if  "which" command has been restricted on OSX El capitan.
For a temporary workaround you can replace remove everything from the last else except the last line which has to be modified as so:
/usr/local/bin/mono "$ASSEMBLY"

This will work only on EL Capitan since on the others mono is located in /usr/bin/mono
Thanks
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: El Capitan: App is terminated on double-click, but runs from terminal (open -a app)

Dave Burnard
In reply to this post by bostjan
Looks like I might be wrong about the version number for the fix. We build our own 64bit binaries and the guy who did our build
went looking for the 4.0.4.4 sources and saw this change in the git repo:

mono/mono/mini/mini-amd64.c:  https://github.com/mono/mono/commit/061f993b6878585a75fbb4de39b89bf3b4aca348

"Add support for version of pthread_getspecific when launching from Xcode with LLDB attached."

That seems to be the key change, but I'm not sure whether what we built corresponds to 4.0.4.4, or if we just grafted that change into our older 4.0.2.X sources.
In our local repository it looks like the latter...

Sorry for the confusion,
DaveB




> On Nov 6, 2015, at 2:17 AM, bostjan <[hidden email]> wrote:
>
> Hi,
>
> We have a legacy Mono Windows Forms app that was running without problems on
> Yosemite but does not run on El Capitan.
> - I have downloaded the new Mono MDK-4.0.4.4. and re-package the app using
> the macpack.
> - Now the app runs/is opened normally when executing command in terminal:
> open -a
> (app) or when calling mono --debug (app)
> - But does not run when double clicking on app inside Finder or LounchPad.
> The app icon shows just briefly then is immediately terminated.
>
> Any idea?
>
> BR,
> Bostjan
>
>
>
>
>
> --
> View this message in context: http://mono.1490590.n4.nabble.com/El-Capitan-App-is-terminated-on-double-click-but-runs-from-terminal-open-a-app-tp4666888.html
> Sent from the Mono - OSX mailing list archive at Nabble.com.
> _______________________________________________
> Mono-osx mailing list
> [hidden email]
> http://lists.ximian.com/mailman/listinfo/mono-osx

_______________________________________________
Mono-osx mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/mono-osx
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: El Capitan: App is terminated on double-click, but runs from terminal (open -a app)

creatorul
Any news on this particular macpack error ?
Seems it takes ages until someone gets approved on the mailing lists here not to mention ages until some fix appears. I understand that this is a free service but I would be happy to pay something for something that gets fixed in a reasonable time.
What about using a normal forum and not a mailing list ?
Thx
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: El Capitan: App is terminated on double-click, but runs from terminal (open -a app)

creatorul
Since there is no fix yet you can use this temporary fix. After packing with Macpack open the app folder and go to /Contents/MacOS and edit the last if else from your launch script:
MONO_PATH="/usr/bin/mono"

cd "$APP_PATH/Contents/Resources"

if [ "$X11_MODE" -eq "1" ]; then
        open-x11 "$APP_NAME"
else
        if [ -f "/usr/local/bin/mono" ]; then MONO_PATH="/usr/local/bin/mono" ; fi
        "$MONO_PATH" "$ASSEMBLY"
fi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: El Capitan: App is terminated on double-click, but runs from terminal (open -a app)

bostjan
Thanks for temporary fix.
In the mean time I have for El Capitan hardcoded the mono path instead "which" command.
And thanks for suggestion where the errors is in first place.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of creatorul
Sent: Samstag, 14. November 2015 11:46
To: [hidden email]
Subject: Re: [Mono-osx] El Capitan: App is terminated on double-click, but runs from terminal (open -a app)

Since there is no fix yet you can use this temporary fix. After packing with Macpack open the app folder and go to /Contents/MacOS and edit the last *if else *from your launch script:

> MONO_PATH="/usr/bin/mono"
>
> cd "$APP_PATH/Contents/Resources"
>
> if [ "$X11_MODE" -eq "1" ]; then
> open-x11 "$APP_NAME"
> else
> if [ -f "/usr/local/bin/mono" ]; then MONO_PATH="/usr/local/bin/mono"
> ; fi
> "$MONO_PATH" "$ASSEMBLY"
> fi





--
View this message in context: http://mono.1490590.n4.nabble.com/El-Capitan-App-is-terminated-on-double-click-but-runs-from-terminal-open-a-app-tp4666888p4666972.html
Sent from the Mono - OSX mailing list archive at Nabble.com.
_______________________________________________
Mono-osx mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/mono-osx
_______________________________________________
Mono-osx mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/mono-osx
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: El Capitan: App is terminated on double-click, but runs from terminal (open -a app)

alfonso
This post has NOT been accepted by the mailing list yet.
Hi,

I have the same issue as op on Sierra.

I'm trying to create a launcher for KeePass but same as op, it launches if I try "open -a (app)" from Terminal but does not run from Finder.

The content of KeePass.app/Contents/MacOS/KeePass is below but I don't know how to edit it to fix it.

Any help is appreciated, thank you!

(please note: which mono
/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono)

#!/bin/sh
#
# This is a stub script that allows .apps to be relocatable on OSX but still
# find the managed assembly.
#
# You should never have to edit this file directly as its generated by the 
# bundle maker.
#

X11_MODE=0
MWF_MODE=1
COCOASHARP_MODE=0

PWD=`pwd`
# Fetch the path relative to the launch point where this shell script exists.
APP_PATH=`echo $0 | awk '{split($0,patharr,"/"); idx=1; while(patharr[idx+3] != "") { if (patharr[idx] != "/") {printf("%s/", patharr[idx]); idx++ }} }'`

# Fetch the app name (its our own name)
APP_NAME=`echo $0 | awk '{split($0,patharr,"/"); idx=1; while(patharr[idx+1] != "") {idx++} printf("%s", patharr[idx]); }'`
ASSEMBLY=`echo $0 | awk '{split($0,patharr,"/"); idx=1; while(patharr[idx+1] != "") {idx++} printf("%s.exe", patharr[idx]); }'`

# Setup the environment for MWF if needed
if [ "$MWF_MODE" -eq "1" ]; then
	export MONO_MWF_USE_CARBON_BACKEND=1
	export GDIPLUS_NOX=1
fi

# Setup the environment for Cocoa# if needed
if [ "$COCOASHARP_MODE" -eq "1" ]; then
	export MONO_GDIP_USE_COCOA_BACKEND=1
	export DYLD_LIBRARY_PATH=$PWD/$APP_PATH/Contents/Resources:$DYLD_LIBRARY_PATH
fi

cd "$APP_PATH/Contents/Resources"

if [ "$X11_MODE" -eq "1" ]; then
	open-x11 "$APP_NAME"

# rcruzs00
# El Capitan FIX: `which` wont work (system-integrity-protection)
# elif: Keep compatibility with previous code
elif [ -f /usr/local/bin/mono ]; then
        DIR=$(cd "$(dirname "$0")"; pwd)
        /usr/local/bin/mono $DIR/../Resources/"$ASSEMBLY"

else
	if [ ! -d "./bin" ]; then mkdir bin ; fi
	if [ -f "./bin/$APP_NAME" ]; then rm -f "./bin/$APP_NAME" ; fi
	ln -s `which mono` "./bin/$APP_NAME" 
	"./bin/$APP_NAME" "$ASSEMBLY"
fi
Loading...