hugo-bin icon indicating copy to clipboard operation
hugo-bin copied to clipboard

Hugo bin is not working with Docker on Mac M1 Pro

Open joaolrpaulo opened this issue 3 years ago • 19 comments

Currently is not possible to use this lib on the new M1 Pro processor using Docker, I suspect it is because of the arch that docker is reporting, but cannot confirm.

The error I get executing this lib is:

#56 0.433
#56 0.433 > [email protected] generate-hugo-files
#56 0.433 > cd app && npm run generate
#56 0.433
#56 0.606
#56 0.606 > [email protected] generate
#56 0.606 > hugo --gc --minify --ignoreCache
#56 0.606
#56 0.679 qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory

Lib Version: 0.82.2 Docker reported Architecture: aarch64 Linux

joaolrpaulo avatar Mar 14 '22 11:03 joaolrpaulo

Does Hugo provide a binary that works on your system? If so, which one exactly?

I don't use Docker not do I have such a system to test, so if the above applies, I might need you to test some things for me.

XhmikosR avatar Mar 16 '22 19:03 XhmikosR

Similar issue as above for me, but my local install works.

I installed on my m1 via homebrew

hugo: stable 0.94.2

sakes avatar Mar 16 '22 22:03 sakes

Well, this is where the platform choice happens https://github.com/fenneclab/hugo-bin/blob/c809456a0c769f7d669a79327c3ec1829fa97288/lib/index.js#L14-L47

Since I don't have such a system, you will need to figure this out and submit a PR :)

Don't forge t to CC me if you make a PR.

XhmikosR avatar Mar 17 '22 06:03 XhmikosR

I'll see if can get to it this weekend. In the meantime here are some references.

homebrew hugo formula: https://formulae.brew.sh/formula/hugo


{
  "urls": {
        "stable": {
            "url": "https://github.com/gohugoio/hugo/archive/v0.94.2.tar.gz",
            "tag": null,
            "revision": null
        }
    }
}

---

{
    "bottle": {
        "stable": {
            "rebuild": 0,
            "root_url": "https://ghcr.io/v2/homebrew/core",
            "files": {
                "arm64_monterey": {
                    "cellar": ":any_skip_relocation",
                    "url": "https://ghcr.io/v2/homebrew/core/hugo/blobs/sha256:650985eb8967555b5d65164d0e7457c29bc4b795af7ba7bebe1d8bf8d85dda7a",
                    "sha256": "650985eb8967555b5d65164d0e7457c29bc4b795af7ba7bebe1d8bf8d85dda7a"
                },
                "arm64_big_sur": {
                    "cellar": ":any_skip_relocation",
                    "url": "https://ghcr.io/v2/homebrew/core/hugo/blobs/sha256:f9edc07415ab2e7e8f375a145ca8cdff45b722de699efed5fe16f7db92be6331",
                    "sha256": "f9edc07415ab2e7e8f375a145ca8cdff45b722de699efed5fe16f7db92be6331"
                },
                "monterey": {
                    "cellar": ":any_skip_relocation",
                    "url": "https://ghcr.io/v2/homebrew/core/hugo/blobs/sha256:f650560dc0aef2615b14f56d27c3e660f7b754da6fabc69e130d0e826ee554af",
                    "sha256": "f650560dc0aef2615b14f56d27c3e660f7b754da6fabc69e130d0e826ee554af"
                },
                "big_sur": {
                    "cellar": ":any_skip_relocation",
                    "url": "https://ghcr.io/v2/homebrew/core/hugo/blobs/sha256:92eb80c53f1569882188feb7cb50b4db979d5ecea341a53d9d71a7fdd1c9bac8",
                    "sha256": "92eb80c53f1569882188feb7cb50b4db979d5ecea341a53d9d71a7fdd1c9bac8"
                },
                "catalina": {
                    "cellar": ":any_skip_relocation",
                    "url": "https://ghcr.io/v2/homebrew/core/hugo/blobs/sha256:fe7dd3ac6d785b3b1723da85b22d7e6edd922441e6019c44ea54e46f97a2e2a6",
                    "sha256": "fe7dd3ac6d785b3b1723da85b22d7e6edd922441e6019c44ea54e46f97a2e2a6"
                },
                "x86_64_linux": {
                    "cellar": ":any_skip_relocation",
                    "url": "https://ghcr.io/v2/homebrew/core/hugo/blobs/sha256:7779f0c2b12ae81c1990cd03910faebf0afe4992f833fe38e6c454c27fbcbbe1",
                    "sha256": "7779f0c2b12ae81c1990cd03910faebf0afe4992f833fe38e6c454c27fbcbbe1"
                }
            }
        }
    }
}

sakes avatar Mar 17 '22 11:03 sakes

Hey @XhmikosR,

I believe that this might suffice (for both extended and no extended versions).

.src(`${baseUrl}hugo_${hugoVersion}_Linux-ARM64.tar.gz`, 'linux', 'aarch64')

If you create a branch with this (or publish a test release), I believe I might be able to test this in the next days.

joaolrpaulo avatar Mar 18 '22 18:03 joaolrpaulo

The thing is that there's no such binary upstream: https://github.com/gohugoio/hugo/releases

XhmikosR avatar Mar 19 '22 07:03 XhmikosR

@XhmikosR pr created - https://github.com/fenneclab/hugo-bin/pull/119

sakes avatar Mar 19 '22 13:03 sakes

@XhmikosR Please note that the binary is Linux-ARM64.

From what I understand, aarch64 & arm64 are the same arch.

joaolrpaulo avatar Mar 19 '22 14:03 joaolrpaulo

Looking deeply into the code I see that bottomline the dependency to detect OS Arch does not properly work in this scenarios https://github.com/feross/arch/issues/19

joaolrpaulo avatar Mar 19 '22 14:03 joaolrpaulo

Unsure what to do here... happy to accept a clean PR that doesn't break something, but I don't have such a system to test, and our CI might not catch all the cases.

XhmikosR avatar Mar 19 '22 15:03 XhmikosR

Please try with the latest version which updates Hugo to the latest version and uses universal binaries.

XhmikosR avatar Sep 15 '22 05:09 XhmikosR

This is still an issue for me even after using the latest version hugo-bin that incorporates the Hugo universal binaries.

The problem is that Docker containers based on linux-arm64 Docker images do not identify as arm64. They identify as aarch64:

  • When I run uname -m on my host (M1 Mac) system, I get: arm64
  • When I run uname -m inside a linux-arm64 Docker container running on my mac system I get: aarch64

@XhmikosR I've created a PR based on @joaolrpaulo's suggestion in https://github.com/fenneclab/hugo-bin/issues/118#issuecomment-1072663138 that I think should resolve this issue: #124

joeparsons avatar Nov 10 '22 19:11 joeparsons

After further investigation and testing, I've come to the same conclusion as @joaolrpaulo in https://github.com/fenneclab/hugo-bin/issues/118#issuecomment-1073020617:

Looking deeply into the code I see that bottomline the dependency to detect OS Arch does not properly work in this scenarios https://github.com/feross/arch/issues/19

The real problem lies in the NPM arch package (which is a dependency of os-filter-obj package that the bin-wrapper package depends on). The arch package does not support non-intel architectures and it's unclear how actively that package is maintained at this point. There is an open PR that would add arm64 detection for Darwin systems but not Linux so that wouldn't necessarily fix Docker issues for M1 mac users (like myself).

See also: kevva/os-filter-obj#3

joeparsons avatar Nov 10 '22 21:11 joeparsons

Not a lot we can do here with the current state of things. I've pinged feross in that PR, so if a patch release is made with the fix then things will work.

XhmikosR avatar Nov 11 '22 05:11 XhmikosR

I'm made an issue to replace bin-wrapper with something else lighter and which hopefully works with M1.

If someone makes a clean PR, happy to review.

XhmikosR avatar Apr 05 '23 08:04 XhmikosR

I plan to fork the arch and os-filter-obj packages in the next days to fix this issue.

XhmikosR avatar Jun 05 '23 16:06 XhmikosR

Could someone test the xmr/os-filter-obj branch?

npm i github:fenneclab/hugo-bin#xmr/dev -D

I don't own such an environment, so any help is welcome. We might need to adapt https://github.com/fenneclab/hugo-bin/blob/main/lib/index.js.

XhmikosR avatar Feb 12 '24 08:02 XhmikosR

Is there anyone with such a machine that they can try the above?

XhmikosR avatar Mar 27 '24 06:03 XhmikosR

This has landed on main since a few version ago. I still don't know if the issue is fixed or not, though.

XhmikosR avatar Jun 05 '24 19:06 XhmikosR