ort icon indicating copy to clipboard operation
ort copied to clipboard

Issue building from docker on MacOS with M1

Open sjoerd222888 opened this issue 2 years ago • 2 comments

Executing docker build -t ort . results in the following error:

#9 16.22 ## Run `sudo apt-get install -y nodejs` to install Node.js 16.x and npm
#9 16.22 ## You may also need development tools to build native addons:
#9 16.22      sudo apt-get install gcc g++ make
#9 16.22 ## To install the Yarn package manager, run:
#9 16.22      curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
#9 16.22      echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
#9 16.22      sudo apt-get update && sudo apt-get install yarn
#9 16.22 
#9 16.22 
#9 16.93 Hit:1 http://ports.ubuntu.com/ubuntu-ports focal InRelease
#9 16.93 Hit:2 https://deb.nodesource.com/node_16.x focal InRelease
#9 16.95 Hit:3 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease
#9 16.95 Get:4 http://ppa.launchpad.net/git-core/ppa/ubuntu focal InRelease [23.8 kB]
#9 16.97 Hit:5 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease
#9 16.99 Hit:6 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease
#9 17.24 Get:7 http://ppa.launchpad.net/git-core/ppa/ubuntu focal/main arm64 Packages [3,162 B]
#9 17.96 Hit:8 https://scala.jfrog.io/artifactory/debian all InRelease
#9 18.03 Fetched 27.0 kB in 1s (23.6 kB/s)
#9 18.03 Reading package lists...
#9 18.68 Hit:1 http://ports.ubuntu.com/ubuntu-ports focal InRelease
#9 18.68 Hit:2 http://ppa.launchpad.net/git-core/ppa/ubuntu focal InRelease
#9 18.70 Hit:3 https://deb.nodesource.com/node_16.x focal InRelease
#9 18.70 Hit:4 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease
#9 18.72 Hit:5 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease
#9 18.74 Hit:6 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease
#9 20.32 Hit:7 https://scala.jfrog.io/artifactory/debian all InRelease
#9 20.38 Reading package lists...
#9 20.93 Reading package lists...
#9 21.44 Building dependency tree...
#9 21.55 Reading state information...
#9 21.62 E: Unable to locate package lib32stdc++6
#9 21.62 E: Couldn't find any package by regex 'lib32stdc++6'
#9 21.62 E: Unable to locate package sbt
------
executor failed running [/bin/sh -c apt-get update &&     apt-get install -y --no-install-recommends ca-certificates gnupg software-properties-common &&     echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | tee -a /etc/apt/sources.list.d/sbt.list &&     curl -ksS "https://keyserver.ubuntu.com/pks/lookup?op=get&options=mr&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | apt-key adv --import - &&     curl -sL https://deb.nodesource.com/setup_16.x | bash - &&     add-apt-repository -y ppa:git-core/ppa &&     apt-get update &&     apt-get install -y --no-install-recommends         lib32stdc++6         libffi-dev         libgmp-dev         libxext6         libxi6         libxrender1         libxtst6         make         netbase         openssh-client         unzip         xz-utils         zlib1g-dev         cvs         git         mercurial         subversion         cargo=$CARGO_VERSION         composer=$COMPOSER_VERSION         nodejs         python-dev         python-setuptools         python3-dev         python3-pip         python3-setuptools         ruby-dev         sbt=$SBT_VERSION     &&     rm -rf /var/lib/apt/lists/*]: exit code: 100    

Docker config:

{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": false,
  "features": {
    "buildkit": true
  }
}

sjoerd222888 avatar Jun 02 '22 14:06 sjoerd222888

@MarcelBochtler can you reproduce this?

sschuberth avatar Jun 02 '22 16:06 sschuberth

Yes, and I also had no luck building the image with instructions like this.

When building the image, I see logs like this:

❯ docker build -t ort .
...
#11 1.204 Get:8 http://ports.ubuntu.com/ubuntu-ports focal/main arm64 Packages [1,234 kB]
...

Indicating that docker tries to build an arm64 image, which is expected, but requires each and every tool in the container to have an arm64 version. This is not the case, at least for ScanCode I know that it can only run on M1 Macs using Rosetta 2.

What might work is forcing the x86_64 architecture to be used by Docker and therefore using the Rosetta 2 translation layer when running it:

❯ docker build --platform x86_64 -t ort .

However, on my M1 Max this is already building for >~50~ 110 min, and therefore is not really a feasible solution.

Building and running ORT without Docker works quite well on the M1 using e.g. Azul's Zulu JDK, but if you want to use it with ScanCode, support for ScanCode 31 needs to be implemented, as this is the first version of ScanCode that supports M1.

MarcelBochtler avatar Jun 02 '22 17:06 MarcelBochtler