electron-userland / electron-installer-snap

Build Snap packages for Electron applications
Apache License 2.0
50 stars 17 forks source link

Snapcraft failed with Hash Sum mismatch on Ubuntu 18.04 #7

Closed MehediH closed 6 years ago

MehediH commented 6 years ago

Hey,

I am trying to build a snap on Ubuntu and am running into a problem. I tried using electron-installer-snap both as the standalone version, as well as part of Electron Forge. I am running into the exact same issue with the module, possibly conflicting with the module cross-spawn-promise.

Here's the console output:


electron-installer-snap --src=build/TestApp-linux-x64

Snapcraft failed (2)
Re-run with the environment variable DEBUG=electron-installer-snap:snapcraft for details.
(node:16964) UnhandledPromiseRejectionWarning: Error: Exited with status 2
    at closeArgsToError (/home/meh/Documents/Projects/TestApp/node_modules/cross-spawn-promise/lib/index.js:20:16)
    at ChildProcess.<anonymous> (/home/meh/Documents/Projects/TestApp/node_modules/cross-spawn-promise/lib/index.js:76:19)
    at Object.onceWrapper (events.js:317:30)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
(node:16964) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:16964) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handledwill terminate the Node.js process with a non-zero exit code.```

I am unaware as to how to address this issue. Please suggest how this problem can be fixed, or if there is a workaround. Thank you!
welcome[bot] commented 6 years ago

👋 Thanks for opening your first issue here! If you have a question about using electron-installer-snap, read the support docs. If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. Development and issue triage is community-driven, so please be patient and we will get back to you as soon as we can.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.

malept commented 6 years ago

Per the error message, try rerunning the command with DEBUG=electron-installer-snap:snapcraft to get the output of the snapcraft command that electron-installer-snap runs:

DEBUG=electron-installer-snap:snapcraft electron-installer-snap --src=build/TestApp-linux-x64
MehediH commented 6 years ago

Thanks! Getting this error now:

Failed to update the package cache: Some files could not be downloaded:

E:Failed to fetch copy:/home/meh/.cache/snapcraft/stage-packages/apt/ebbb4b1389f7016ca9b0be1bf758a6dabc4816304b01c4a504834f8b8be018b1c6748d93faa768ea0be99565dd4b0574/var/lib/apt/lists/partial/security.ubuntu.com_ubuntu_dists_bionic-security_main_dep11_icons-48x48.tar.gz  Hash Sum mismatch
E:Some index files failed to download. They have been ignored
or old ones used instead.

Check that the sources on your host are configured correctly.

Here is the full output:

meh@ubuntu:~/Documents/Projects/TweetenApp$ npm run build:linux

> tweeten@4.5.3 build:linux /home/meh/Documents/Projects/TweetenApp
> DEBUG=electron-installer-snap:snapcraft electron-installer-snap --src=build/Tweeten-linux-x64

  electron-installer-snap:snapcraft Running '/snap/bin/snapcraft snap --target-arch=amd64 --output=/home/meh/Documents/Projects/TweetenApp/tweeten_4.5.3_amd64
.snap' in /tmp/electron-snap-7511Bqw1SlIbpnIc +0ms
Setting target machine to 'amd64'
Preparing to pull desktop-gtk3
Hit http://us.archive.ubuntu.com/ubuntu bionic InRelease
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [83.2 kB]
Hit http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease
Get:2 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [111 kB]
Get:3 http://security.ubuntu.com/ubuntu bionic-security/main i386 Packages [93.7 kB]
Get:4 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [43.7 kB]
Get:5 http://security.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [204 B]
Get:6 http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 48x48 Icons [29 B]
Get:7 http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 64x64 Icons [29 B]
Get:8 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [34.8 kB]
Get:9 http://security.ubuntu.com/ubuntu bionic-security/universe i386 Packages [34.7 kB]
Get:10 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [19.8 kB]
Get:11 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [2452 B]
Get:12 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 48x48 Icons [4031 B]
Get:13 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 64x64 Icons [4058 B]
Get:14 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [1176 B]
Err http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 64x64 Icons
  Hash Sum mismatch
Get:15 http://security.ubuntu.com/ubuntu bionic-security/multiverse i386 Packages [1340 B]
Get:16 http://security.ubuntu.com/ubuntu bionic-security/multiverse Translation-en [632 B]
Fetched 83.2 kB in 0s (0 B/s)
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [83.2 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
Get:3 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [111 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:5 http://security.ubuntu.com/ubuntu bionic-security/main i386 Packages [93.7 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1019 kB]
Get:8 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [43.7 kB]
Get:9 http://security.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [204 B]
Get:10 http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 48x48 Icons [29 B]
Get:11 http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 64x64 Icons [29 B]
Get:12 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [34.8 kB]
Get:13 http://security.ubuntu.com/ubuntu bionic-security/universe i386 Packages [34.7 kB]
Err http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 64x64 Icons
  Hash Sum mismatch
Get:14 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [19.8 kB]
Get:15 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [2452 B]
Get:16 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 48x48 Icons [4031 B]
Get:17 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 64x64 Icons [4058 B]
Get:18 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [1176 B]
Get:19 http://security.ubuntu.com/ubuntu bionic-security/multiverse i386 Packages [1340 B]
Get:20 http://security.ubuntu.com/ubuntu bionic-security/multiverse Translation-en [632 B]
Get:21 http://us.archive.ubuntu.com/ubuntu bionic/main i386 Packages [1007 kB]
Get:22 http://us.archive.ubuntu.com/ubuntu bionic/main Translation-en [516 kB]
Get:23 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 DEP-11 Metadata [477 kB]
Get:24 http://us.archive.ubuntu.com/ubuntu bionic/main DEP-11 48x48 Icons [118 kB]
Get:25 http://us.archive.ubuntu.com/ubuntu bionic/main DEP-11 64x64 Icons [245 kB]
Get:26 http://us.archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [9184 B]
Get:27 http://us.archive.ubuntu.com/ubuntu bionic/restricted i386 Packages [9156 B]
Get:28 http://us.archive.ubuntu.com/ubuntu bionic/restricted Translation-en [3584 B]
Get:29 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [8570 kB]
Get:30 http://us.archive.ubuntu.com/ubuntu bionic/universe i386 Packages [8531 kB]
Get:31 http://us.archive.ubuntu.com/ubuntu bionic/universe Translation-en [4941 kB]
Get:32 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 DEP-11 Metadata [3287 kB]
Get:33 http://us.archive.ubuntu.com/ubuntu bionic/universe DEP-11 48x48 Icons [2151 kB]
Get:34 http://us.archive.ubuntu.com/ubuntu bionic/universe DEP-11 64x64 Icons [8420 kB]
Get:35 http://us.archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [151 kB]
Get:36 http://us.archive.ubuntu.com/ubuntu bionic/multiverse i386 Packages [144 kB]
Get:37 http://us.archive.ubuntu.com/ubuntu bionic/multiverse Translation-en [108 kB]
Get:38 http://us.archive.ubuntu.com/ubuntu bionic/multiverse amd64 DEP-11 Metadata [49.7 kB]
Get:39 http://us.archive.ubuntu.com/ubuntu bionic/multiverse DEP-11 48x48 Icons [8931 B]
Get:40 http://us.archive.ubuntu.com/ubuntu bionic/multiverse DEP-11 64x64 Icons [225 kB]
Get:41 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [175 kB]
Get:42 http://us.archive.ubuntu.com/ubuntu bionic-updates/main i386 Packages [157 kB]
Get:43 http://us.archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [69.7 kB]
Get:44 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [128 kB]
Get:45 http://us.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 48x48 Icons [28.4 kB]
Get:46 http://us.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 64x64 Icons [49.2 kB]
Get:47 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [113 kB]
Get:48 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe i386 Packages [113 kB]
Get:49 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [48.4 kB]
Get:50 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [126 kB]
Get:51 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 48x48 Icons [119 kB]
Get:52 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 64x64 Icons [198 kB]
Get:53 http://us.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [3544 B]
Get:54 http://us.archive.ubuntu.com/ubuntu bionic-updates/multiverse i386 Packages [3700 B]
Get:55 http://us.archive.ubuntu.com/ubuntu bionic-updates/multiverse Translation-en [2060 B]
Get:56 http://us.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2468 B]
Get:57 http://us.archive.ubuntu.com/ubuntu bionic-updates/multiverse DEP-11 48x48 Icons [29 B]
Get:58 http://us.archive.ubuntu.com/ubuntu bionic-updates/multiverse DEP-11 64x64 Icons [2638 B]
Get:59 http://us.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [2704 B]
Get:60 http://us.archive.ubuntu.com/ubuntu bionic-backports/universe i386 Packages [2700 B]
Get:61 http://us.archive.ubuntu.com/ubuntu bionic-backports/universe Translation-en [1136 B]
Get:62 http://us.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [5100 B]
Get:63 http://us.archive.ubuntu.com/ubuntu bionic-backports/universe DEP-11 48x48 Icons [29 B]
Get:64 http://us.archive.ubuntu.com/ubuntu bionic-backports/universe DEP-11 64x64 Icons [1789 B]
Fetched 42.2 MB in 6s (6672 kB/s)
Failed to update the package cache: Some files could not be downloaded:

E:Failed to fetch copy:/home/meh/.cache/snapcraft/stage-packages/apt/ebbb4b1389f7016ca9b0be1bf758a6dabc4816304b01c4a504834f8b8be018b1c6748d93faa768ea0be99565dd4b0574/var/lib/apt/lists/partial/security.ubuntu.com_ubuntu_dists_bionic-security_main_dep11_icons-48x48.tar.gz  Hash Sum mismatch
E:Some index files failed to download. They have been ignored
or old ones used instead.

Check that the sources on your host are configured correctly.
Snapcraft failed (2)
(node:7511) UnhandledPromiseRejectionWarning: Error: Exited with status 2
    at closeArgsToError (/home/meh/Documents/Projects/TweetenApp/node_modules/cross-spawn-promise/lib/index.js:20:16)
    at ChildProcess.<anonymous> (/home/meh/Documents/Projects/TweetenApp/node_modules/cross-spawn-promise/lib/index.js:76:19)
    at Object.onceWrapper (events.js:317:30)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
(node:7511) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7511) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
malept commented 6 years ago

This looks like the error to me:

Err http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 64x64 Icons
  Hash Sum mismatch

I don't know why this is happening, but it's more of an apt/Ubuntu problem, so I can't offer any help here. Try checking in Ubuntu's Stack Overflow or forums.

develar commented 6 years ago

@MehediH You can try electron-builder If you don't have custom stage packages, packaging will be done without apt. And if you have custom stage packages, you can always set set _REMOTE_BUILD=true env to build using free remote service (where all system configuration is done properly and proper Ubuntu version is used).

develar commented 6 years ago

Anyway, electron-installer-snap also can be used — but to avoid errors due to your local system, you can use Docker. Image electronuserland/builder is suitable not only for electron-builder, but of course for electron-installer-snap as well. Please note — implied that you build using electron version 2 (because set of packages different since electron 2 uses gtk3).

malept commented 6 years ago

electron-installer-snap automatically uses the correct packages based on whether the app uses Electron >= 2.0 or not.

MehediH commented 6 years ago

Hi guys, I realize this isn't an issue with the module itself but I am still having the same issue. I tried changing the download server for Ubuntu Software but it didn't help, and tried a bunch of other things that didn't help either. Any idea as to what could be causing this?

Also -- I was wondering, would I be able to create a snap package by using Windows Subsystem for Linux?

develar commented 6 years ago

by using Windows Subsystem for Linux?

Snap store validates your app but do not validate how it work across Linux Distros. If you want to be sure, just use docker (to be clear — official snap docker image is not suitable because electron-installer-snap and electron-builder requires node.js/npm) or electron-builder free build cloud service as mentioned above.

axfelix commented 6 years ago

Is there any chance you just need to run an apt-get update because your sources are out of date?

malept commented 6 years ago

It's possible that wiping out the apt cache might work, but I haven't tried it. When I run tests for electron-installer-snap, I use a Docker image of Ubuntu 16.04.

MehediH commented 6 years ago

Cleaning the apt cache doesn't work, neither does changing the sources.

malept commented 6 years ago

Yeah, I would just use a Docker container, such as the one that's used for tests in both electron-installer-snap and Electron Forge. It's Ubuntu 16.04, but that shouldn't matter unless you have some hard dependency that requires a newer Ubuntu version.

MehediH commented 6 years ago

I don't really want to get in the trouble of using Docker. Do you have any Ubuntu env where you can try and repro the problem?

malept commented 6 years ago

The only Ubuntu environments I have are in Docker environments.

That being said, it doesn't seem to be a problem isolated to building Electron apps: https://forum.snapcraft.io/t/ubuntu-18-04-dont-create-a-snap-package-failed-to-update-the-package-cache/5313

Their proposed solution is basically "build the app in a container" (although they use lxc instead of Docker).

malept commented 6 years ago

Evidently it is not currently recommended to build snaps on Ubuntu 18.04 without a container. I tried to run the electron-installer-snap tests with Ubuntu 18.04 and got some interesting errors:

https://travis-ci.org/electron-userland/electron-installer-snap/jobs/405055315#L706-L712

Looking for similar errors led me to https://forum.snapcraft.io/t/python-plugin-glibc-error-in-ubuntu-18-04/5233 which explains why.

axfelix commented 6 years ago

Probably easier to just build on 16.04 then for now?

malept commented 6 years ago

Probably easier to just build on 16.04 then for now?

Either 16.04 or a container running 16.04.

develar commented 6 years ago

That’s why electron-builder uses templates (produced in cooperation with Ubuntu, so, you can be sure that it works and passed Ubuntu Store requirements) instead of snapcraft, otherwise users have a lot of issues, since developer environment is different (each time). It also affects delta updates. That’s why electron-builder offers free public cloud service to build snap even on Linux/MacOS if need (e.g. if you have custom packages).

MehediH commented 6 years ago

I ended up moving to electron-builder and solved this problem with lots of help from @develar. Thanks everyone.