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

briefcase run fails after briefcase create when using stub app templates #1729

Closed
zhenzi0322 opened this issue Apr 12, 2024 · 3 comments · Fixed by #1781
Closed

briefcase run fails after briefcase create when using stub app templates #1729

zhenzi0322 opened this issue Apr 12, 2024 · 3 comments · Fixed by #1781
Labels
bug A crash or error in behavior. good first issue Is this your first time contributing? This could be a good place to start! macOS The issue relates to Apple macOS support. windows The issue relates to Microsoft Windows support.

Comments

@zhenzi0322
Copy link

zhenzi0322 commented Apr 12, 2024

Describe the bug

When running an app on macOS or Windows, briefcase run will fail if a build step hasn't been executed.

On Windows, the error manifests as:

SystemExit: stub: No module named stub

On macOS, it is

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

Steps to reproduce

$ briefcase new -Q app_name=foobar
$ cd foobar
$ briefcase create
$ briefcase run

Expected behavior

App should start without error. The run should imply the need for a build on the macOS/Windows app templates, but because the template and binary both exist, the need for a build isn't detected.

Screenshots

No response

Environment

  • Operating System: macOS, Windows
  • Python version: All
  • Software versions:
    • Briefcase: 0.3.17+

Logs

Traceback (most recent call last):
  File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\runpy.py", line 183, in _run_module_as_main
  File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\runpy.py", line 136, in _get_module_details
runpy._Error: No module named stub

During handling of the above exception, another exception occurred:

SystemExit: stub: No module named stub

---------------------------------------------------------------------------
Application quit abnormally (Exit code -1)!
stub: No module named stub

Unable to start app helloworld.

Additional context

The briefcase dev is normal, but the briefcase run is abnormal.

If you invoke briefcase run on a clean project, the app works.

If you invoke briefcase build before invoking briefcase run, the app works.

This only affects the app targets; the Xcode/VisualStudio templates do the right thing, because they require an explicit compilation step to create the binary.

@zhenzi0322 zhenzi0322 added the bug A crash or error in behavior. label Apr 12, 2024
@freakboy3742
Copy link
Member

freakboy3742 commented Apr 12, 2024

When reporting a bug, it's really important that you provide full reproduction instructions. You've given 3 commands - but haven't provided any details about the other inputs you've used (such as the name of your app), or the system where you're running (including operating system versions, briefcase versions, etc). The bug template asks for these details for reason - if you don't provide these details, it can be very difficult for us to diagnose the problem. I've updated your report to include some of the details you've omitted.


In this case, the problem is that the build step has been missed. A Windows app needs a build step to set some metadata on the binary. This should be picked up automatically, but it appears it isn't.

As a workaround, you can manually run:

briefcase build

This will only be needed on the initial build. Once the metadata has been set once, no additional builds will be required.

I believe the specific issue is caused because you did run briefcase create. If you invoke briefcase run without invoking briefcase create first, this triggers the create, which then causes a build to occur. However, if you invoke create, the template and the binary both exist, so Run assumes no build is required.

The same problem exists for both the macOS app and Windows app template, for the same reason - they're both stub apps that require additional modifications after the template is rolled out.

One fix would be to modify the app template so that the stub binary generated by the template is literally stub.exe; then the "build" step would be "rename stub.exe to .exe", which would be detected by a create/run sequence as an update that will be required on the first run, but not subsequent runs.

@freakboy3742 freakboy3742 changed the title SystemExit: stub: No module named stub briefcase run fails after briefcase create when using stub app templates Apr 12, 2024
@freakboy3742 freakboy3742 added good first issue Is this your first time contributing? This could be a good place to start! windows The issue relates to Microsoft Windows support. macOS The issue relates to Apple macOS support. labels Apr 12, 2024
@zhenzi0322
Copy link
Author

Thank you

@rmartin16
Copy link
Member

I believe this is the same issue as #807. Nonetheless, this should be resolved by #1714 since running the build step would no longer be dependent on the presence of the app binary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior. good first issue Is this your first time contributing? This could be a good place to start! macOS The issue relates to Apple macOS support. windows The issue relates to Microsoft Windows support.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants