-
Notifications
You must be signed in to change notification settings - Fork 370
Fix SITL binary path resolution for dev and packaged modes #2496
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
Merged
sensei-hacker
merged 1 commit into
iNavFlight:maintenance-9.x
from
sensei-hacker:fix-sitl-path-resolution
Dec 24, 2025
Merged
Fix SITL binary path resolution for dev and packaged modes #2496
sensei-hacker
merged 1 commit into
iNavFlight:maintenance-9.x
from
sensei-hacker:fix-sitl-path-resolution
Dec 24, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The SITL feature was broken because the code looked for binaries in the wrong location. The path used __dirname which points to the Vite build output (.vite/build/), but SITL binaries are in resources/public/sitl/. Changes: - Add getSitlBasePath() function that returns correct path based on whether app is packaged (process.resourcesPath) or in dev mode (app.getAppPath()/resources/public/sitl) - Add extraResource in forge.config.js to include SITL in packages - Add afterCopy hook to remove binaries for other platforms/architectures, reducing package size
Contributor
ⓘ Your approaching your monthly quota for Qodo. Upgrade your plan PR Compliance Guide 🔍All compliance sections have been disabled in the configurations. |
Comment on lines
364
to
369
| ipcMain.handle('chmod', (_event, pathName, mode) => { | ||
| return new Promise(resolve => { | ||
| chmod(path.join(__dirname, 'sitl', pathName), mode, error => { | ||
| chmod(path.join(getSitlBasePath(), pathName), mode, error => { | ||
| if (error) { | ||
| resolve(error.message) | ||
| } else { |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Refactor the chmod IPC handler to use the promise-based fs.promises.chmod instead of wrapping the callback version in a new Promise. [general, importance: 6]
New proposed code:
-ipcMain.handle('chmod', (_event, pathName, mode) => {
- return new Promise(resolve => {
- chmod(path.join(getSitlBasePath(), pathName), mode, error => {
- if (error) {
- resolve(error.message)
- } else {
- resolve(false)
- }
- });
- });
+ipcMain.handle('chmod', async (_event, pathName, mode) => {
+ try {
+ await chmod(path.join(getSitlBasePath(), pathName), mode);
+ return false; // Indicates success
+ } catch (error) {
+ return error.message;
+ }
});
Contributor
ⓘ Your monthly quota for Qodo has expired. Upgrade your plan ⓘ Paying users. Check that your Qodo account is linked with this Git user account |
ac5180b
into
iNavFlight:maintenance-9.x
5 of 6 checks passed
This was referenced Dec 24, 2025
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
User description
Summary
Fixes SITL feature which was broken because the code looked for binaries in the wrong location.
Problem
The SITL path used
__dirnamewhich points to the Vite build output (.vite/build/), but SITL binaries are located inresources/public/sitl/. This meant SITL couldn't find its executables in either dev mode or packaged builds.Changes
getSitlBasePath()function that returns the correct path based on whether the app is packaged (process.resourcesPath) or in dev mode (app.getAppPath()/resources/public/sitl)extraResourcein forge.config.js to include SITL binaries in packaged buildsafterCopyhook to remove binaries for other platforms/architectures, reducing package sizeTesting
afterCopyhook correctly handles all platform/arch combinations including Linux arm64Related
Alternative implementation to #2492
PR Type
Bug fix
Description
Fix SITL binary path resolution for dev and packaged modes
Add getSitlBasePath() function for correct path detection
Include SITL binaries in packaged builds via extraResource
Remove platform-specific binaries in afterCopy hook to reduce package size
Diagram Walkthrough
flowchart LR A["SITL Binary Location"] --> B{"App Packaged?"} B -->|Yes| C["process.resourcesPath/sitl"] B -->|No| D["app.getAppPath/resources/public/sitl"] C --> E["getSitlBasePath Function"] D --> E E --> F["chmod & startChildProcess"] G["forge.config.js"] --> H["extraResource adds SITL to package"] H --> I["afterCopy removes unused platform binaries"]File Walkthrough
forge.config.js
Configure SITL binary inclusion and platform filteringforge.config.js
extraResourceconfiguration to includeresources/public/sitlinpackaged builds
afterCopyhook that removes SITL binaries for non-target platformsand architectures
and removing x64 variant
main.js
Implement dynamic SITL path resolution logicjs/main/main.js
getSitlBasePath()function that returns correct path based onpackaged vs dev mode
__dirname/sitlpaths withgetSitlBasePath()calls inchmod and startChildProcess handlers
process.resourcesPathfor packaged builds andapp.getAppPath()/resources/public/sitlfor dev mode