flet icon indicating copy to clipboard operation
flet copied to clipboard

Old flet client app versions do not launch on Mac

Open mikaelho opened this issue 2 years ago • 15 comments

Have repeatedly seen the following behavior on Mac:

  • I get this error when trying to launch a flet app in "local app mode":

    The application cannot be opened for an unexpected reason, error=Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x60000374d650 {Error Domain=NSPOSIXErrorDomain Code=111 "Unknown error: 111" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}

  • Web mode works normally.

  • When I check flet version, I see that there is a new version available.

  • After upgrading to latest version, app launches normally.

While this is in a way great, as it keeps me motivated to quickly upgrade to the latest version, it is not good for stable application use.

Speculation: Mac only considers the latest flet Flutter client app valid.

Would be great if anyone else using a Mac could verify this behavior.

mikaelho avatar Aug 07 '22 13:08 mikaelho

just reinstall flet)

mrkito avatar Aug 08 '22 18:08 mrkito

just reinstall flet)

Sorry, I do not understand what you mean. flet apps cannot stop working just because a new version of flet is released.

mikaelho avatar Aug 09 '22 13:08 mikaelho

I'm testing in a virtual environment. Apple M1. Just did pip install flet --upgrade to 0.1.48, had 0.1.46 before.

Was able to run sample app without any issues and with Flet and fletd in correct locations:

[Screenshot]

image

In the same time there is still Flet 0.1.46 in the temp folder:

(venv1) feodor@Feodors-Mac-mini 4 % ls /private/var/folders/66/jrqkzks15q76d85xhkqlwm680000gn/T/flet-*
/private/var/folders/66/jrqkzks15q76d85xhkqlwm680000gn/T/flet-0.1.46:
Flet.app

/private/var/folders/66/jrqkzks15q76d85xhkqlwm680000gn/T/flet-0.1.48:
Flet.app

FeodorFitsner avatar Aug 09 '22 17:08 FeodorFitsner

Thanks for the effort!

The issue I was describing is that when you next release 0.1.49, the app that now runs fine on 0.1.48, stops working (without any changes or updates).

Virtual machine might not give an accurate result if you restart it between now and then.

Next time when this happens for me, I will try restarting the machine instead of installing the latest version.

mikaelho avatar Aug 09 '22 18:08 mikaelho

I meant it was Python's virtual environment, in a separate folder. I'm testing on a physical machine.

OK, let me check an a different Mac with Intel CPU.

FeodorFitsner avatar Aug 09 '22 18:08 FeodorFitsner

Tested on another Mac - it still works with an old 0.1.39 installation:

image

FeodorFitsner avatar Aug 09 '22 18:08 FeodorFitsner

Would be great if anyone else using a Mac could verify this behavior.

Same happened to me on Mac today. Upgrading also fixed the issue for me.

dsgibbons avatar Aug 11 '22 11:08 dsgibbons

Thanks @dsgibbons, this helps. In order to help pinpoint the cause, could you share which editor and package manager are you using?

PyCharm and poetry for me.

mikaelho avatar Aug 12 '22 11:08 mikaelho

Could be related: https://github.com/flet-dev/flet/issues/181#issuecomment-1213325055

FeodorFitsner avatar Aug 12 '22 17:08 FeodorFitsner

Thanks @dsgibbons, this helps. In order to help pinpoint the cause, could you share which editor and package manager are you using?

PyCharm and poetry for me.

@mikaelho pip/venv, editing on VSCode, and running on bash terminal

dsgibbons avatar Aug 12 '22 22:08 dsgibbons

And one more thing, I am using M1, wonder if that has something to with this? Is the app compiled for M1 or are we emulating Intel?

mikaelho avatar Aug 13 '22 12:08 mikaelho

@mikaelho I'm using a 2015 MacBook Pro so no M1 here.

dsgibbons avatar Aug 13 '22 12:08 dsgibbons

@mikaelho It's build for Intel, so it uses Rosetta on M1.

FeodorFitsner avatar Aug 13 '22 15:08 FeodorFitsner

New flet 0.1.50 version.

Same error.

Without installing the new version, I tried manually launching the latest version I had installed:

% open /var/folders/qn/01t1th0j6s79l1bjbqjlrvbw0000gn/T//flet-0.1.49/Flet.app

Same error.

Noticed that I only had 0.1.48 and 0.1.49 in the temp dir, so tried if removing the 0.1.48 directory changed anything.

Same error.

Then tried the launch services registering thing, and tried running again:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f /var/folders/qn/01t1th0j6s79l1bjbqjlrvbw0000gn/T/flet-0.1.49/Flet.app

No errors from registering call.

Still the same error.

Updated flet. My test app launched normally, after which flet-0.1.50 directory was created, and also open from the command line worked, opening the empty app.

mikaelho avatar Aug 14 '22 04:08 mikaelho

As it somehow "knows" there is a new version available? :-/

FeodorFitsner avatar Aug 14 '22 18:08 FeodorFitsner

it happens to me from time to time, reloading VScode doesn't fix the issue, restarting MAC completely does.

Even if I am running over version 0.1.60

(flet-test) ➜  flet git:(main) pip show flet 
Name: flet
Version: 0.1.60
Summary: Flet for Python - easily build interactive multi-platform apps in Python
Home-page: 
Author: 
Author-email: Appveyor Systems Inc. <[email protected]>
License: MIT
Requires: beartype, cryptography, oauthlib, repath, requests, watchdog, websocket-client
Required-by: 

Running the app:

ERROR:websocket:[Errno 61] Connection refused - goodbye
WARNING:websocket:websocket connected
App URL: http://127.0.0.1:52937
Connected to Flet app and handling user sessions...
The application cannot be opened for an unexpected reason, error=Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x7fdd72f17a40 {Error Domain=NSPOSIXErrorDomain Code=111 "Unknown error: 111" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}
(flet-test) ➜  flet git:(main) 

So the conclusion is:

  • Works fine over web mode
  • Was working before via MAC app mode
  • After rebooting the MAC it works (MacOS Monterey - Intel cpu)
  • Relaunching VScode doesn't help

mkhachfeh avatar Oct 04 '22 13:10 mkhachfeh

That error is coming from macOS. Nothing in Flet is trying to contact GitHub and lookup for the latest version. Once Python Flet package is installed it contains everything it needs, including Flet macOS client and Fletd server. My guess it's related to some remote macOS executables checking service (kind of this https://eclecticlight.co/2020/11/16/checks-on-executable-code-in-catalina-and-big-sur-a-first-draft/). For example, when someone somewhere has already tried a newer macOS client version it starts failing checks for the previous one.

You can see the error while trying to run a previous Flet client from a command line:

open $TMPDIR/flet-0.1.59/Flet.app

It's uncharted territory for me as well. Need to google, need to find what exactly that error means. Signing could be an answer.

FeodorFitsner avatar Oct 04 '22 14:10 FeodorFitsner

can you try the following command on your mac:

ls $TMPDIR/flet-0.1.60/Flet.app/Contents/MacOS

FeodorFitsner avatar Oct 04 '22 14:10 FeodorFitsner

Another thing to try when it happens: in Finder go to $TMPDIR/flet-0.1.60, right-click Flet.app and select "Open".

FeodorFitsner avatar Oct 04 '22 15:10 FeodorFitsner

  1. For the first suggestion: (ls $TMPDIR/flet-0.1.60/Flet.app/Contents/MacOS)
  • within $TMPDIR, I see only flet-0.1.52 folder, and going to the requested dir:
➜  MacOS ls $TMPDIR/flet-0.1.52/Flet.app/Contents/MacOS
Flet
  • So only Flet file, tailing it shows nothing while running Flet app.
  1. For the second suggestion ($TMPDIR/flet-0.1.60, right-click Flet.app and select "Open"):
  • At the end for me this is a folder, so click "open" on it will take me to the content data, which is only Contents/
  • Or am I missing something?

mkhachfeh avatar Oct 05 '22 15:10 mkhachfeh

I've implemented, hopefully, a solution to this issue - let see if it's going to work in the next update scheduled later this week.

FeodorFitsner avatar Oct 05 '22 16:10 FeodorFitsner

@FeodorFitsner sadly. I still see the same error on the new version:

(flet-test) ➜  flet git:(main) ✗ pip show flet
Name: flet
Version: 0.1.62
Summary: Flet for Python - easily build interactive multi-platform apps in Python
Home-page: 
Author: 
Author-email: Appveyor Systems Inc. <[email protected]>
License: MIT
Location: /flet/.venv/lib/python3.9/site-packages
Requires: beartype, oauthlib, repath, requests, watchdog, websocket-client
Required-by: 

Running the app:

The application cannot be opened for an unexpected reason, error=Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x7fab7ff28090 {Error Domain=NSPOSIXErrorDomain Code=111 "Unknown error: 111" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}

mkhachfeh avatar Oct 17 '22 12:10 mkhachfeh

What do you have in $TMPDIR/flet-0.1.62 folder?

FeodorFitsner avatar Oct 17 '22 19:10 FeodorFitsner

Here is the tree:

(flet-test) ➜  flet-0.1.62 pwd
$TMPDIR/flet-0.1.62
(flet-test) ➜  flet-0.1.62 tree
.
└── Flet.app
    └── Contents
        ├── Frameworks
        │   ├── App.framework
        │   │   ├── App -> Versions/Current/App
        │   │   ├── Resources -> Versions/Current/Resources
        │   │   └── Versions
        │   │       ├── A
        │   │       │   ├── Resources
        │   │       │   │   └── flutter_assets
        │   │       │   │       ├── fonts
        │   │       │   │       ├── packages
        │   │       │   │       │   └── window_manager
        │   │       │   │       │       └── images
        │   │       │   │       └── shaders
        │   │       │   └── _CodeSignature
        │   │       └── Current -> A
        │   ├── FlutterMacOS.framework
        │   │   ├── FlutterMacOS -> Versions/Current/FlutterMacOS
        │   │   ├── Resources -> Versions/Current/Resources
        │   │   └── Versions
        │   │       ├── A
        │   │       │   ├── Resources
        │   │       │   └── _CodeSignature
        │   │       └── Current -> A
        │   ├── audioplayers_darwin.framework
        │   │   ├── Resources -> Versions/Current/Resources
        │   │   ├── Versions
        │   │   │   ├── A
        │   │   │   │   ├── Resources
        │   │   │   │   └── _CodeSignature
        │   │   │   └── Current -> A
        │   │   └── audioplayers_darwin -> Versions/Current/audioplayers_darwin
        │   ├── path_provider_macos.framework
        │   │   ├── Resources -> Versions/Current/Resources
        │   │   ├── Versions
        │   │   │   ├── A
        │   │   │   │   ├── Resources
        │   │   │   │   └── _CodeSignature
        │   │   │   └── Current -> A
        │   │   └── path_provider_macos -> Versions/Current/path_provider_macos
        │   ├── screen_retriever.framework
        │   │   ├── Resources -> Versions/Current/Resources
        │   │   ├── Versions
        │   │   │   ├── A
        │   │   │   │   ├── Resources
        │   │   │   │   └── _CodeSignature
        │   │   │   └── Current -> A
        │   │   └── screen_retriever -> Versions/Current/screen_retriever
        │   ├── shared_preferences_macos.framework
        │   │   ├── Resources -> Versions/Current/Resources
        │   │   ├── Versions
        │   │   │   ├── A
        │   │   │   │   ├── Resources
        │   │   │   │   └── _CodeSignature
        │   │   │   └── Current -> A
        │   │   └── shared_preferences_macos -> Versions/Current/shared_preferences_macos
        │   ├── url_launcher_macos.framework
        │   │   ├── Resources -> Versions/Current/Resources
        │   │   ├── Versions
        │   │   │   ├── A
        │   │   │   │   ├── Resources
        │   │   │   │   └── _CodeSignature
        │   │   │   └── Current -> A
        │   │   └── url_launcher_macos -> Versions/Current/url_launcher_macos
        │   ├── window_manager.framework
        │   │   ├── Resources -> Versions/Current/Resources
        │   │   ├── Versions
        │   │   │   ├── A
        │   │   │   │   ├── Resources
        │   │   │   │   └── _CodeSignature
        │   │   │   └── Current -> A
        │   │   └── window_manager -> Versions/Current/window_manager
        │   └── window_to_front.framework
        │       ├── Resources -> Versions/Current/Resources
        │       ├── Versions
        │       │   ├── A
        │       │   │   ├── Resources
        │       │   │   └── _CodeSignature
        │       │   └── Current -> A
        │       └── window_to_front -> Versions/Current/window_to_front
        ├── MacOS
        ├── Resources
        │   └── Base.lproj
        │       └── MainMenu.nib
        └── _CodeSignature

77 directories, 9 files

mkhachfeh avatar Oct 18 '22 10:10 mkhachfeh

What files do you have in $TMPDIR/flet-0.1.62/Flet.app/Contents/MacOS?

FeodorFitsner avatar Oct 18 '22 18:10 FeodorFitsner

Nothing, it is empty:

(flet-test) ➜  flet git:(main) ✗ ls -ltr $TMPDIR/flet-0.1.62/Flet.app/Contents/MacOS
total 0

mkhachfeh avatar Oct 19 '22 10:10 mkhachfeh

OK, great. Now, could you please delete the entire $TMPDIR/flet-0.1.62 directory and run Flet program again?

FeodorFitsner avatar Oct 19 '22 15:10 FeodorFitsner

@FeodorFitsner That works, thanks.

What do you suggest as a permanent solution?

mkhachfeh avatar Oct 19 '22 17:10 mkhachfeh

Thanks for the update!

I don't know if it's going to be permanent, but the solution would be moving Flet executables out of $TMPDIR, say to $HOME and see how it goes. I feel like it should fix the issue.

FeodorFitsner avatar Oct 19 '22 17:10 FeodorFitsner

I'm getting the error

The application cannot be opened for an unexpected reason, error=Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x600002658f00 {Error Domain=NSPOSIXErrorDomain Code=111 "Unknown error: 111" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}

and these errors in my system console when it happens

error	14:05:55.725521+0200	runningboardd	Launchd didn't have information for pid 55429, reason: Error Domain=NSPOSIXErrorDomain Code=113 "Unknown error: 113"
error	14:05:55.737042+0200	runningboardd	Process start failed with Error Domain=NSPOSIXErrorDomain Code=111 "Unknown error: 111" UserInfo={NSLocalizedDescription=Launchd job spawn failed}
error	14:05:55.737338+0200	runningboardd	Job remove after failed start failed with Error Domain=OSLaunchdErrorDomain Code=36 "Operation now in progress" UserInfo={NSLocalizedFailureReason=Operation now in progress}
error	14:05:55.737356+0200	runningboardd	Launch failed with Error Domain=NSPOSIXErrorDomain Code=111 "Unknown error: 111" UserInfo={NSLocalizedDescription=Launchd job spawn failed}
error	14:05:55.738195+0200	open	LAUNCH: RBSLaunchRequest FAILURE <private> com.appveyor.flet <private> 0x0-0x312312 failed with error Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x600002b48d20 {Error Domain=NSPOSIXErrorDomain Code=111 "Unknown error: 111" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}
error	14:05:55.738240+0200	open	LAUNCH: Runningboard launch of com.appveyor.flet <private> returned RBSRequestErrorFailed, error Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x600002b48d20 {Error Domain=NSPOSIXErrorDomain Code=111 "Unknown error: 111" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}, so returning -10810
error	14:05:55.738317+0200	open	LAUNCH: request execute thru runningboard of 0x0-0x312312 com.appveyor.flet/<private> failed with error=Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x600002b48d20 {Error Domain=NSPOSIXErrorDomain Code=111 "Unknown error: 111" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}
error	14:05:55.759259+0200	analyticsd	[XPC Server] managed connection recieved connection invalidated: Connection invalid
error	14:05:55.753134+0200	open	LAUNCH: Launch failure with -10810/kLSUnknownErr <private>
error	14:05:55.764661+0200	runningboardd	RBSStateCapture remove item called for untracked item <RBProcessMonitorObserver| qos:0 qos:(null) configs:{
	}>
error	14:05:55.768282+0200	taskgated	cannot open file at line 45530 of [9ff244ce07]
error	14:05:55.768311+0200	taskgated	os_unix.c:45530: (2) open(/var/db/DetachedSignatures) - No such file or directory

System restart seems to fix the problem.

Is this related, should I file a separate issue, or did the PR that closed this issue also fix the issue I am having?

xylix avatar Nov 16 '22 12:11 xylix