lumeland / lume

🔥 Static site generator for Deno 🦕
https://lume.land
MIT License
1.83k stars 83 forks source link

Pagefind plugin exited with error code 127 #362

Closed shishkin closed 1 year ago

shishkin commented 1 year ago

Version

1.15.1

Platform

MacOS on M1/ARM

What steps will reproduce the bug?

  1. Init new Lume project with pagefind plugin
  2. Run deno task lume

How often does it reproduce? Is there a required condition?

Every time

What is the expected behavior?

Build works

What do you see instead?

I see an error:

❯ deno task lume
Task lume echo "import 'lume/cli.ts'" | deno run --unstable -A -
Loading config file file:///Users/serega/code/dojo/deno/lume-init-test/_config.ts

Downloading https://github.com/CloudCannon/pagefind/releases/download/v0.10.6/pagefind-v0.10.6-aarch64-apple-darwin.tar.gz...

Error: Pagefind exited with code 127

47,85,115,101,114,115,47,115,101,114,101,103,97,47,99,111,100,101,47,100,111,106,111,47,100,101,110,111,47,108,117,109,101,45,105,110,105,116,45,116,101,115,116,47,95,98,105,110,47,112,97,103,101,102,105,110,100,58,32,108,105,110,101,32,49,58,32,51,48,58,32,99,111,109,109,97,110,100,32,110,111,116,32,102,111,117,110,100,10,47,85,115,101,114,115,47,115,101,114,101,103,97,47,99,111,100,101,47,100,111,106,111,47,100,101,110,111,47,108,117,109,101,45,105,110,105,116,45,116,101,115,116,47,95,98,105,110,47,112,97,103,101,102,105,110,100,58,32,108,105,110,101,32,50,58,32,50,50,58,32,99,111,109,109,97,110,100,32,110,111,116,32,102,111,117,110,100,10,47,85,115,101,114,115,47,115,101,114,101,103,97,47,99,111,100,101,47,100,111,106,111,47,100,101,110,111,47,108,117,109,101,45,105,110,105,116,45,116,101,115,116,47,95,98,105,110,47,112,97,103,101,102,105,110,100,58,32,108,105,110,101,32,51,58,32,50,50,58,32,99,111,109,109,97,110,100,32,110,111,116,32,102,111,117,110,100,10,47,85,115,101,114,115,47,115,101,114,101,103,97,47,99,111,100,101,47,100,111,106,111,47,100,101,110,111,47,108,117,109,101,45,105,110,105,116,45,116,101,115,116,47,95,98,105,110,47,112,97,103,101,102,105,110,100,58,32,108,105,110,101,32,52,58,32,50,56,58,32,99,111,109,109,97,110,100,32,110,111,116,32,102,111,117,110,100,10,47,85,115,101,114,115,47,115,101,114,101,103,97,47,99,111,100,101,47,100,111,106,111,47,100,101,110,111,47,108,117,109,101,45,105,110,105,116,45,116,101,115,116,47,95,98,105,110,47,112,97,103,101,102,105,110,100,58,32,108,105,110,101,32,53,58,32,51,50,58,32,99,111,109,109,97,110,100,32,110,111,116,32,102,111,117,110,100,10
    at (https://deno.land/x/lume@v1.15.1/plugins/pagefind.ts:185:15)
    at async Events.dispatchEvent (https://deno.land/x/lume@v1.15.1/core/events.ts:49:11)
    at async Site.build (https://deno.land/x/lume@v1.15.1/core/site.ts:527:5)
    at async build (https://deno.land/x/lume@v1.15.1/cli/build.ts:36:3)
    at async Command.execute (https://deno.land/x/cliffy@v0.25.7/command/command.ts:1794:7)
    at async Command.parseCommand (https://deno.land/x/cliffy@v0.25.7/command/command.ts:1639:14)
    at async (https://deno.land/x/lume@v1.15.1/cli.ts:158:3)

The byte array content above is:

/Users/serega/code/dojo/deno/lume-init-test/_bin/pagefind: line 1: 30: command not found
  '/Users/serega/code/dojo/deno/lume-init-test/_bin/pagefind: line 2: 22: command not found
  '/Users/serega/code/dojo/deno/lume-init-test/_bin/pagefind: line 3: 22: command not found
  '/Users/serega/code/dojo/deno/lume-init-test/_bin/pagefind: line 4: 28: command not found
  '/Users/serega/code/dojo/deno/lume-init-test/_bin/pagefind: line 5: 32: command not found

Additional information

Contents of the _bin/pagefind file:

30 mtime=1671398107.623792028
22 GNU.sparse.major=1
22 GNU.sparse.minor=0
28 GNU.sparse.name=pagefind
32 GNU.sparse.realsize=10945478
oscarotero commented 1 year ago

Someone reported the same issue some days ago. We think it's a bug of the last version of pagefind in the Apple M1 processors. Try again configuring the pagefind version to the previous version: v0.10.5.

shishkin commented 1 year ago

Try again configuring the pagefind version to the previous version: v0.10.5.

Thanks @oscarotero. Setting the version to v0.10.5 worked indeed.

bglw commented 1 year ago

@oscarotero I think this is an issue on the Lume side — either in dbin and untar, from a skim? Though I'm not quite sure how it would be happening.

I'm seeing the same error as reported in this issue on my M1 machine. Running Pagefind through its npx wrapper is working fine for me, and downloading the release url specified in the Lume log (https://github.com/CloudCannon/pagefind/releases/download/v0.10.6/pagefind-v0.10.6-aarch64-apple-darwin.tar.gz) extracts fine, and the binary runs correctly.

My _bin/pagefind file created by Lume looks identical to the one referenced above:

30 mtime=1671398107.623792028
22 GNU.sparse.major=1
22 GNU.sparse.minor=0
28 GNU.sparse.name=pagefind
32 GNU.sparse.realsize=10945478

This looks like the tar headers of the file, in some way? I'm not super familiar with tar headers, but the mtime lines up with when that archive was created in the GitHub Action, and the realsize works out to the correct size of the decompressed Pagefind binary. So it looks like everything is downloading correctly, but the tar headers are being copied over instead of the tar contents.

I have no explanation for why a previous version of Pagefind is working, however. Nothing in the release flow changed between those two versions, and looking at the logs they both ran on the same OS version/build image, so they should have been archived the same.

Let me know if there's anything I can help debug using my machine

bglw commented 1 year ago

Okay, what I think is the case is that the Deno standard library archive functions don't support sparse tar files — and v0.10.6 happened to archive as sparse, as that can happen by default on the system tar used in macOS.

I don't know how common it is for tar libraries to handle sparse tars, so I don't know if it's worth opening any issue against Deno for this. It might be one to look further into, though, as any GitHub action building for macOS that uses the system tar may, at any point, create a sparse archive that fails in Deno/Lume. Whether it does so seems to depend on the underlying blocks of the filesystem, so it's a tossup whether or not it will happen.

In any case, I've updated Pagefind's release flow to force GNU tar instead of bsdtar on macOS, which defaults the other way on sparse files, so they will no longer be created. That means version v0.10.7 and onwards of Pagefind will be working again in Lume.

oscarotero commented 1 year ago

Many many thanks @bglw for your time digging into this issue and releasing a new patch for Deno/Lume. I'm not familiarized with how tar files work, but I guess Deno standard library should be able to handle sparse files. I'll post an issue to Deno.

Thanks again!

shishkin commented 1 year ago

Thanks @bglw. I can confirm that 0.10.7 works .