Community Packages

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#77220 - [electron] Bug in electron-launcher.sh, empty lines in flags-electron.conf cause app launch to fail

Attached to Project: Community Packages
Opened by Urban Suhadolnik (lightning5) - Saturday, 21 January 2023, 22:17 GMT
Last edited by Caleb Maclennan (alerque) - Thursday, 15 June 2023, 06:53 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Caleb Maclennan (alerque)
Bruno Pagani (ArchangeGabriel)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Hi,

Recently, I was playing Electron flags in electron-flags.conf file and encountered a bug in electron-launcher.sh (a.k.a. /usr/bin/elecron) script. In case there is multiple empty lines at the end of electron-flags.conf file, startup fails.
Running with bash -x shows that empty lines were converted into empty strings as arguments:
+ exec /usr/lib/electron/electron --enable-features=WaylandWindowDecorations --ozone-platform-hint=auto '' '' '' '' '' '' /usr/lib/discord/app.asar

Complete output of bash -x:
[strela@stardust bin]$ bash -x ./electron /usr/lib/discord/app.asar
+ set -euo pipefail
+ name=electron
+ flags_file=/home/strela/.config/electron-flags.conf
+ declare -a flags
+ [[ -f /home/strela/.config/electron-flags.conf ]]
+ mapfile -t
+ for line in "${MAPFILE[@]}"
+ [[ ! --enable-features=WaylandWindowDecorations =~ ^[[:space:]]*#.* ]]
+ flags+=("${line}")
+ for line in "${MAPFILE[@]}"
+ [[ ! --ozone-platform-hint=auto =~ ^[[:space:]]*#.* ]]
+ flags+=("${line}")
+ for line in "${MAPFILE[@]}"
+ [[ ! '' =~ ^[[:space:]]*#.* ]]
...snip...
+ flags+=("${line}")
+ for line in "${MAPFILE[@]}"
+ [[ ! '' =~ ^[[:space:]]*#.* ]]
+ flags+=("${line}")
+ exec /usr/lib/electron/electron --enable-features=WaylandWindowDecorations --ozone-platform-hint=auto '' '' '' '' '' '' /usr/lib/discord/app.asar

Electron apps that don't use the default script, like VScode, don't suffer from this problem. VSvode launcher "sed" instead of a bash array to print the flags.
Sed command in VScode launching script:
"$(sed 's/#.*//' $XDG_CONFIG_HOME/code-flags.conf | tr '\n' ' ')"

Solution is to use VScode launching script or to modify the current electron-laucher.sh to use "sed".

Modified VScode sript for electron is available in attachments under: "VScode-modified-electron-launcher.sh"
Modified electron-laucher.sh to use sed is available in attachments under: "modified electron-launcher.sh"


Additional info:
* package version(s): all of them

Affected apps:
* All apps that use /usr/bin/electron to startup
* And all apps that copied electron launcher for their own flags (e.g. Discord)

Not affected:
* Apps with custom starting/flag reading scripts (VScode) and run /usr/lib/electron/electron directly

Steps to reproduce:
1. Create electron-flags.conf file with multiple empty lines after the last line
2. Run app with /usr/bin/electron /usr/lib/discord/app.asar (or any app that calls /usr/bin/electron or copies electron-launcher.sh script (e.g. discord))

Workaround:
- Remove empty lines in electron-config

Regards,
Lightning5
This task depends upon

Closed by  Caleb Maclennan (alerque)
Thursday, 15 June 2023, 06:53 GMT
Reason for closing:  Fixed
Comment by Toolybird (Toolybird) - Monday, 23 January 2023, 07:14 GMT
Some might argue that broken conf files are not supported.

Related:  FS#75667 
Comment by Urban Suhadolnik (lightning5) - Tuesday, 07 February 2023, 17:03 GMT
That's true. But I don't think that extra empty lines should not make a difference, since it is really easy to add them accidentally (or even added by text editor when closing).
Higher robustness of launcher script would be the right thing to do.
Comment by DrasLorus (DrasLorus) - Thursday, 23 March 2023, 16:08 GMT
Just ran into this problem. An easy fix is to add ``&& [[ -n "${line}" ]]'' in the condition, line 15 of the script. It checks for empty lines to ignore them.
Comment by Caleb Maclennan (alerque) - Wednesday, 14 June 2023, 15:29 GMT
The latter change suggested by DrasLorus is comments has been applied to all the Electron versions currently in [extra-testing] (22, 23, 24, and 25). Everything older than that is soon to be dropped anyway and I'm not messing with them.

It would be helpful if somebody who actually *had* this problem and uses flag files like this could test at least one of those packages and make sure the change works as expected and doesn't break the usual usage.
Comment by Caleb Maclennan (alerque) - Thursday, 15 June 2023, 06:52 GMT
This is holding up new Electron builds now and doesn't seem to have broken usage for *without* flag files. I'm going to go ahead and move it out of testing and close this, but if there are ongoing issues with flag file handling please feel free to open a new issue.

Loading...