Skip to content

Commit

Permalink
fix(snap): Snap does not launch when Ubuntu uses Wayland
Browse files Browse the repository at this point in the history
Close #4007
  • Loading branch information
develar committed Jul 4, 2019
1 parent 30c3904 commit 2278c2a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export class Packager {
const platformToTarget = new Map<Platform, Map<string, Target>>()
const createdOutDirs = new Set<string>()

for (const [platform, archToType] of this.options.targets!) {
for (const [platform, archToType] of this.options.targets!!) {
if (this.cancellationToken.cancelled) {
break
}
Expand Down
5 changes: 4 additions & 1 deletion packages/app-builder-lib/src/targets/snap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getTemplatePath } from "../util/pathManager"
import { LinuxTargetHelper } from "./LinuxTargetHelper"
import { createStageDirPath } from "./targetUtil"

const defaultPlugs = ["desktop", "desktop-legacy", "home", "x11", "unity7", "browser-support", "network", "gsettings", "pulseaudio", "opengl"]
const defaultPlugs = ["desktop", "desktop-legacy", "home", "x11", "wayland", "unity7", "browser-support", "network", "gsettings", "pulseaudio", "opengl"]

export default class SnapTarget extends Target {
readonly options: SnapOptions = {...this.packager.platformSpecificBuildOptions, ...(this.packager.config as any)[this.name]}
Expand Down Expand Up @@ -95,6 +95,9 @@ export default class SnapTarget extends Target {
else {
const archTriplet = archNameToTriplet(arch)
appDescriptor.environment = {
// https://github.com/electron-userland/electron-builder/issues/4007
// https://github.com/electron/electron/issues/9056
DISABLE_WAYLAND: "1",
TMPDIR: "$XDG_RUNTIME_DIR",
PATH: "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
SNAP_DESKTOP_RUNTIME: "$SNAP/gnome-platform",
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/targets/targetFactory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addValue, Arch, archFromString, ArchType, asArray } from "builder-util"
import { PlatformSpecificBuildOptions, DEFAULT_TARGET, DIR_TARGET, Platform, Target, TargetConfiguration } from "../index"
import { PlatformSpecificBuildOptions, DEFAULT_TARGET, DIR_TARGET, Platform, Target, TargetConfiguration } from ".."
import { PlatformPackager } from "../platformPackager"
import { ArchiveTarget } from "./ArchiveTarget"

Expand Down
2 changes: 1 addition & 1 deletion test/out/__snapshots__/BuildTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ Object {
"size": 765,
},
"chownr.js": Object {
"size": 2488,
"size": 3512,
},
"package.json": Object {
"size": 402,
Expand Down
9 changes: 9 additions & 0 deletions test/out/linux/__snapshots__/snapTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Object {
"adapter": "none",
"command": "command.sh",
"environment": Object {
"DISABLE_WAYLAND": "1",
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
Expand All @@ -28,6 +29,7 @@ Object {
"desktop-legacy",
"home",
"x11",
"wayland",
"unity7",
"browser-support",
"network",
Expand Down Expand Up @@ -229,6 +231,7 @@ Object {
"sep": Object {
"command": "command.sh",
"environment": Object {
"DISABLE_WAYLAND": "1",
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
Expand All @@ -239,6 +242,7 @@ Object {
"desktop-legacy",
"home",
"x11",
"wayland",
"unity7",
"browser-support",
"network",
Expand Down Expand Up @@ -295,6 +299,7 @@ Object {
"sep": Object {
"command": "command.sh",
"environment": Object {
"DISABLE_WAYLAND": "1",
"FOO": "bar",
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
Expand All @@ -306,6 +311,7 @@ Object {
"desktop-legacy",
"home",
"x11",
"wayland",
"unity7",
"browser-support",
"network",
Expand Down Expand Up @@ -990,6 +996,7 @@ Object {
"sep": Object {
"command": "command.sh",
"environment": Object {
"DISABLE_WAYLAND": "1",
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
Expand Down Expand Up @@ -1049,6 +1056,7 @@ Object {
"adapter": "none",
"command": "command.sh",
"environment": Object {
"DISABLE_WAYLAND": "1",
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
Expand Down Expand Up @@ -1241,6 +1249,7 @@ Object {
"adapter": "none",
"command": "command.sh",
"environment": Object {
"DISABLE_WAYLAND": "1",
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
Expand Down

0 comments on commit 2278c2a

Please sign in to comment.