Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old flet client app versions do not launch on Mac #161

Closed
mikaelho opened this issue Aug 7, 2022 · 31 comments
Closed

Old flet client app versions do not launch on Mac #161

mikaelho opened this issue Aug 7, 2022 · 31 comments
Milestone

Comments

@mikaelho
Copy link
Contributor

mikaelho commented Aug 7, 2022

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.

@mrkito
Copy link

mrkito commented Aug 8, 2022

just reinstall flet)

@mikaelho
Copy link
Contributor Author

mikaelho commented Aug 9, 2022

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.

@FeodorFitsner
Copy link
Contributor

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

@mikaelho
Copy link
Contributor Author

mikaelho commented Aug 9, 2022

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.

@FeodorFitsner
Copy link
Contributor

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
Copy link
Contributor

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

image

@dsgibbons
Copy link

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.

@mikaelho
Copy link
Contributor Author

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.

@FeodorFitsner
Copy link
Contributor

Could be related: #181 (comment)

@dsgibbons
Copy link

dsgibbons commented Aug 12, 2022

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

@mikaelho
Copy link
Contributor Author

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?

@dsgibbons
Copy link

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

@FeodorFitsner
Copy link
Contributor

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

@mikaelho
Copy link
Contributor Author

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.

@FeodorFitsner
Copy link
Contributor

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

@mkhachfeh
Copy link

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. <hello@flet.dev>
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

@FeodorFitsner
Copy link
Contributor

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
Copy link
Contributor

can you try the following command on your mac:

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

@FeodorFitsner
Copy link
Contributor

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

@mkhachfeh
Copy link

  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?

@FeodorFitsner FeodorFitsner added this to the Controls-S2 milestone Oct 5, 2022
@FeodorFitsner
Copy link
Contributor

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 FeodorFitsner added status: working on it Working on a fix for the issue and removed status: working on it Working on a fix for the issue labels Oct 5, 2022
@mkhachfeh
Copy link

@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. <hello@flet.dev>
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}}}

@FeodorFitsner
Copy link
Contributor

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

@mkhachfeh
Copy link

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

@FeodorFitsner
Copy link
Contributor

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

@mkhachfeh
Copy link

Nothing, it is empty:

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

@FeodorFitsner
Copy link
Contributor

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

@FeodorFitsner FeodorFitsner reopened this Oct 19, 2022
@mkhachfeh
Copy link

@FeodorFitsner That works, thanks.

What do you suggest as a permanent solution?

@FeodorFitsner
Copy link
Contributor

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 FeodorFitsner added the status: working on it Working on a fix for the issue label Oct 29, 2022
@FeodorFitsner FeodorFitsner removed the status: working on it Working on a fix for the issue label Nov 10, 2022
@xylix
Copy link

xylix commented Nov 16, 2022

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?

@FeodorFitsner
Copy link
Contributor

It's related problem I guess though errors are always different and cryptic in all cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants