Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hugo bin is not working with Docker on Mac M1 Pro #118

Open
joaolrpaulo opened this issue Mar 14, 2022 · 19 comments
Open

Hugo bin is not working with Docker on Mac M1 Pro #118

joaolrpaulo opened this issue Mar 14, 2022 · 19 comments

Comments

@joaolrpaulo
Copy link

joaolrpaulo commented Mar 14, 2022

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 > package@0.1.0 generate-hugo-files
#56 0.433 > cd app && npm run generate
#56 0.433
#56 0.606
#56 0.606 > doks-child-theme@0.2.3 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

@XhmikosR
Copy link
Collaborator

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.

@sakes
Copy link

sakes commented Mar 16, 2022

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

I installed on my m1 via homebrew

hugo: stable 0.94.2

@XhmikosR
Copy link
Collaborator

Well, this is where the platform choice happens

hugo-bin/lib/index.js

Lines 14 to 47 in c809456

const extendedBin = new BinWrapper()
.src(`${baseUrl}hugo_extended_${hugoVersion}_Linux-64bit.tar.gz`, 'linux', 'x64')
.src(`${baseUrl}hugo_extended_${hugoVersion}_macOS-64bit.tar.gz`, 'darwin', 'x64')
.src(`${baseUrl}hugo_extended_${hugoVersion}_macOS-ARM64.tar.gz`, 'darwin', 'arm64')
.src(`${baseUrl}hugo_extended_${hugoVersion}_Windows-64bit.zip`, 'win32', 'x64')
// Fall back to the normal version on unsupported platforms
.src(`${baseUrl}hugo_${hugoVersion}_FreeBSD-64bit.tar.gz`, 'freebsd', 'x64')
.src(`${baseUrl}hugo_${hugoVersion}_Linux-32bit.tar.gz`, 'linux', 'x86')
.src(`${baseUrl}hugo_${hugoVersion}_Linux-ARM.tar.gz`, 'linux', 'arm')
.src(`${baseUrl}hugo_${hugoVersion}_Linux-ARM64.tar.gz`, 'linux', 'arm64')
.src(`${baseUrl}hugo_${hugoVersion}_NetBSD-64bit.tar.gz`, 'netbsd', 'x64')
.src(`${baseUrl}hugo_${hugoVersion}_OpenBSD-64bit.tar.gz`, 'openbsd', 'x64')
.src(`${baseUrl}hugo_${hugoVersion}_Windows-32bit.zip`, 'win32', 'x86')
.src(`${baseUrl}hugo_${hugoVersion}_Windows-ARM.zip`, 'win32', 'arm')
.src(`${baseUrl}hugo_${hugoVersion}_Windows-ARM64.zip`, 'win32', 'arm64')
.dest(destDir)
.use(binName);
const normalBin = new BinWrapper()
.src(`${baseUrl}hugo_${hugoVersion}_FreeBSD-64bit.tar.gz`, 'freebsd', 'x64')
.src(`${baseUrl}hugo_${hugoVersion}_Linux-32bit.tar.gz`, 'linux', 'x86')
.src(`${baseUrl}hugo_${hugoVersion}_Linux-64bit.tar.gz`, 'linux', 'x64')
.src(`${baseUrl}hugo_${hugoVersion}_Linux-ARM.tar.gz`, 'linux', 'arm')
.src(`${baseUrl}hugo_${hugoVersion}_Linux-ARM64.tar.gz`, 'linux', 'arm64')
.src(`${baseUrl}hugo_${hugoVersion}_macOS-64bit.tar.gz`, 'darwin', 'x64')
.src(`${baseUrl}hugo_${hugoVersion}_macOS-ARM64.tar.gz`, 'darwin', 'arm64')
.src(`${baseUrl}hugo_${hugoVersion}_NetBSD-64bit.tar.gz`, 'netbsd', 'x64')
.src(`${baseUrl}hugo_${hugoVersion}_OpenBSD-64bit.tar.gz`, 'openbsd', 'x64')
.src(`${baseUrl}hugo_${hugoVersion}_Windows-32bit.zip`, 'win32', 'x86')
.src(`${baseUrl}hugo_${hugoVersion}_Windows-64bit.zip`, 'win32', 'x64')
.src(`${baseUrl}hugo_${hugoVersion}_Windows-ARM.zip`, 'win32', 'arm')
.src(`${baseUrl}hugo_${hugoVersion}_Windows-ARM64.zip`, 'win32', 'arm64')
.dest(destDir)
.use(binName);

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.

@sakes
Copy link

sakes commented Mar 17, 2022

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"
                }
            }
        }
    }
}

@joaolrpaulo
Copy link
Author

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.

@XhmikosR
Copy link
Collaborator

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

@sakes
Copy link

sakes commented Mar 19, 2022

@XhmikosR pr created - #119

@joaolrpaulo
Copy link
Author

joaolrpaulo commented Mar 19, 2022

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

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

@joaolrpaulo
Copy link
Author

Looking deeply into the code I see that bottomline the dependency to detect OS Arch does not properly work in this scenarios feross/arch#19

@XhmikosR
Copy link
Collaborator

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
Copy link
Collaborator

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

@joeparsons
Copy link

joeparsons commented Nov 10, 2022

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 #118 (comment) that I think should resolve this issue: #124

@joeparsons
Copy link

joeparsons commented Nov 10, 2022

After further investigation and testing, I've come to the same conclusion as @joaolrpaulo in #118 (comment):

Looking deeply into the code I see that bottomline the dependency to detect OS Arch does not properly work in this scenarios feross/arch#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

@XhmikosR XhmikosR reopened this Nov 11, 2022
@XhmikosR
Copy link
Collaborator

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
Copy link
Collaborator

XhmikosR commented Apr 5, 2023

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
Copy link
Collaborator

XhmikosR commented Jun 5, 2023

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

@XhmikosR
Copy link
Collaborator

XhmikosR commented Feb 12, 2024

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
Copy link
Collaborator

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

@XhmikosR
Copy link
Collaborator

XhmikosR commented Jun 5, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants