Cannot build my Snap anymore: Unexpected end of JSON input

Hi all.

My build process started failing some time ago and I cannot pin point where the error is originating. Somehow Electron Builder tries to parse some JSON and fails doing so. On other platforms (local environment, Flathub) the build runs through smoothly.

Is there anyone around who could take a quick look at the report and maybe point me towards a solution?

https://launchpadlibrarian.net/817748326/buildlog_snap_ubuntu_noble_arm64_0bd466522b32144f4aca7878faa1937b_BUILDING.txt.gz

Best ransome1

Hello @ransome1 ! Is that zsh your command interpreter :face_with_monocle: ?

I’m not sure if I understand the question. What you see is the output of the Snapcraft build pipeline.

Hi @ransome1 - are you able to share the project file for this snap?

Hi @bepri . Of course, here is the manifest: sleek/snap/snapcraft.yaml at main · ransome1/sleek · GitHub

It looks like this problem comes from npm or peggy (I can’t tell which right now) dropping Launchpad’s proxy settings. Launchpad sets the http_proxy, https_proxy, HTTP_PROXY, and HTTPS_PROXY environment variables when performing a remote build, and build tools are expected to respect them. An upstream feature request or bug report would have to be opened with the responsible tool.

(my two cents makes me guess it’s probably peggy’s fault, since npm was able to successfully download peggy)

1 Like

But as far as I read the log, Peggy runs through successfully and then the process continues with vite building the app. I don’t really spot any indication, that Peggy cases this tbh.

@ogra Hey Oliver, you’ve been helping out with sleek quite a bit in the past and I was wondering if you could take a look at the launchpad log. Unfortunately sleek’s build is now 2 releases behind in Snapcraft store, since I am unable to build it any longer :frowning:

The relevant bit is this:

Build log
:: > npx peggy --format es --dts --output ./src/main/Filters/FilterLang.ts ./src/main/Filters/FilterLang.pegjs
::
:: vite v7.1.4 building SSR bundle for production...
:: transforming...
:: ✓ 1248 modules transformed.
:: rendering chunks...
:: out/main/index.js  1,509.98 kB
:: ✓ built in 6.55s
:: vite v7.1.4 building SSR bundle for production...
:: transforming...
:: ✓ 1 modules transformed.
:: rendering chunks...
:: out/preload/index.mjs  1.11 kB
:: ✓ built in 25ms
:: vite v7.1.4 building for production...
:: transforming...
:: ✓ 1382 modules transformed.
:: rendering chunks...
:: ../../out/renderer/index.html                     0.44 kB
:: ../../out/renderer/assets/index-ha3tsHeN.css     27.51 kB
:: ../../out/renderer/assets/index--q8HEarD.js   2,569.15 kB
:: ✓ built in 7.99s
::   • electron-builder  version=26.0.12 os=6.8.0-71-generic
::   • loaded configuration  file=/build/sleek/parts/sleek/build/electron-builder.yml
::   • executing @electron/rebuild  electronVersion=38.0.0 arch=arm64 buildFromSource=false appDir=./
::   • installing native dependencies  arch=arm64
::   • completed installing native dependencies
::   • packaging       platform=linux arch=arm64 electron=38.0.0 appOutDir=dist/linux-arm64-unpacked
::   • downloading     url=https://github.com/electron/electron/releases/download/v38.0.0/electron-v38.0.0-linux-arm64.zip size=115 MB parts=8
::   • downloaded      url=https://github.com/electron/electron/releases/download/v38.0.0/electron-v38.0.0-linux-arm64.zip duration=15.074s
[14/Sep/2025:09:11:23 +0000] "CONNECT release-assets.githubusercontent.com:443 HTTP/1.1" 200 14385517 "-" "Go-http-client/1.1"
[14/Sep/2025:09:11:23 +0000] "CONNECT release-assets.githubusercontent.com:443 HTTP/1.1" 200 14386406 "-" "Go-http-client/1.1"
[14/Sep/2025:09:11:23 +0000] "CONNECT release-assets.githubusercontent.com:443 HTTP/1.1" 200 14386234 "-" "Go-http-client/1.1"
[14/Sep/2025:09:11:23 +0000] "CONNECT release-assets.githubusercontent.com:443 HTTP/1.1" 200 14386206 "-" "Go-http-client/1.1"
[14/Sep/2025:09:11:23 +0000] "CONNECT release-assets.githubusercontent.com:443 HTTP/1.1" 200 14386601 "-" "Go-http-client/1.1"
[14/Sep/2025:09:11:23 +0000] "CONNECT release-assets.githubusercontent.com:443 HTTP/1.1" 200 14385963 "-" "Go-http-client/1.1"
[14/Sep/2025:09:11:23 +0000] "CONNECT release-assets.githubusercontent.com:443 HTTP/1.1" 200 14386163 "-" "Go-http-client/1.1"
[14/Sep/2025:09:11:23 +0000] "CONNECT release-assets.githubusercontent.com:443 HTTP/1.1" 200 14386157 "-" "Go-http-client/1.1"
[14/Sep/2025:09:11:23 +0000] "CONNECT github.com:443 HTTP/1.1" 200 8703 "-" "Go-http-client/1.1"
::   ⨯ Unexpected end of JSON input  failedTask=build stackTrace=SyntaxError: Unexpected end of JSON input
::     at JSON.parse (<anonymous>)
::     at NpmNodeModulesCollector.parseDependenciesTree (/build/sleek/parts/sleek/build/node_modules/app-builder-lib/src/node-module-collector/npmNodeModulesCollector.ts:68:17)
::     at NpmNodeModulesCollector.getDependenciesTree (/build/sleek/parts/sleek/build/node_modules/app-builder-lib/src/node-module-collector/nodeModulesCollector.ts:48:17)
::     at processTicksAndRejections (node:internal/process/task_queues:105:5)
::     at NpmNodeModulesCollector.getNodeModules (/build/sleek/parts/sleek/build/node_modules/app-builder-lib/src/node-module-collector/nodeModulesCollector.ts:16:21)
::     at computeNodeModuleFileSets (/build/sleek/parts/sleek/build/node_modules/app-builder-lib/src/util/appFileCopier.ts:181:16)
::     at /build/sleek/parts/sleek/build/node_modules/app-builder-lib/src/platformPackager.ts:500:34
::     at async Promise.all (index 0)
::     at AsyncTaskManager.awaitTasks (/build/sleek/parts/sleek/build/node_modules/builder-util/src/asyncTaskManager.ts:65:25)
::     at LinuxPackager.doPack (/build/sleek/parts/sleek/build/node_modules/app-builder-lib/src/platformPackager.ts:317:5)
'override-build' in part 'sleek' failed with code 1.

The invocation of npx peggy --format es --dts --output ./src/main/Filters/FilterLang.ts ./src/main/Filters/FilterLang.pegjs is still running when the process fails.

1 Like

Honestly I have no idea what’s up here. All other platforms build the app, locally everzthing is peachy and I really cannot spot the issue. It’s also quite frustrating, because sleek is desperately outdated on Snap because of this.

The only thing I can do is to push this :frowning:

This is the latest failed run, based on the most recent code base: https://launchpadlibrarian.net/846313167/buildlog_snap_ubuntu_noble_amd64_0bd466522b32144f4aca7878faa1937b_BUILDING.txt.gz

Have you filed an upstream issue with peggy to see if they see any problems on their side? I can try to weigh in on the issue if one exists but isn’t getting traction. It’s been a while since I looked at this, but the logs still strongly suggest to me that peggy isn’t respecting proxy settings.

I did: Snapcraft: Cannot build app, supposedly because Peggy might not be respecting proxy settings · Issue #658 · peggyjs/peggy · GitHub

@bepri As recommended I will add the verbose parameter, but as you can read from the reply, he doesn’t expect this to be a peggy issue.

Interesting. I asked some colleagues of mine, and comparing the different logs (which all seem to fail in slightly different ways) points to electron-builder instead.

We skimmed a bit through the code and as far as we can tell, electron-builder is calling bash -c "npm list --long ..." which would cause this, but it absolutely looks like that should preserve the environment.

Once I saw this, I turned to looking more critically at the project file for sleek and I spotted something interesting: sleek/snap/snapcraft.yaml at 2238c8226052b11c9f30f70d3b066d2c882daebc · ransome1/sleek · GitHub

What are these lines accomplishing? I don’t know with confidence that they’re causing the issue, but at least line 52 is wrong – it should use https_proxy since the environment variable being assigned is for HTTPS, not HTTP. Regardless, I wouldn’t expect you to have to set any special environment variables for the proxy setup to work.

Another concern is that this is using plugin: nil instead of plugin: npm. It may be worth a try to rewrite this to use that new plugin (here’s the docs, and here’s a usage tutorial), and maybe the fix will come for free from that.

Hey you so much for digging into this. With this information and then some more help by AI, I was able to get the building process running through and now sleek is available in its latest version on Snapcraft :smiling_face_with_three_hearts: Many thanks!