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

Docker build fails with: unbound variable on darwin #704

Open
half2me opened this issue Aug 31, 2023 · 2 comments
Open

Docker build fails with: unbound variable on darwin #704

half2me opened this issue Aug 31, 2023 · 2 comments

Comments

@half2me
Copy link

half2me commented Aug 31, 2023

Steps to reproduce:

git clone --depth 1 https://github.com/RPI-Distro/pi-gen.git
cd pi-gen
echo "IMG_NAME=Foo" > config
./build-docker.sh

I get the following error: ./build-docker.sh: line 147: DOCKER_CMDLINE_PRE[@]: unbound variable

Output of docker --version

Client:
 Cloud integration: v1.0.35-desktop+001
 Version:           24.0.5
 API version:       1.43
 Go version:        go1.20.6
 Git commit:        ced0996
 Built:             Fri Jul 21 20:32:30 2023
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.22.0 (117440)
 Engine:
  Version:          24.0
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.6
  Git commit:       HEAD
  Built:            Sun Jul 30 02:09:41 2023
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
@reubenmiller
Copy link
Contributor

reubenmiller commented Sep 5, 2023

This problem happens because MacOS has a very old version of bash by default which is missing some more "modern" features like arrays. Currently the default version is "3.2.57", where as iirc arrays was added to bash in >= 4.x.

  1. Install a newer version of bash (e.g. using homebrew). Afterwards make sure it is included in the PATH variable before the /bin folder. Though you can see information online for further instructions if you run into problems installing it

  2. Replace the shebang in the build-docker.sh script to the following:

    #!/usr/bin/env bash
    set -eu

Though you might run into some follow up problems (I'm currently doing the same thing and try to debug as I go).

Update

I was able to build the images with the above tweak to the build-docker.sh script on my MacOS M1, though you need to checkout the arm64 branch! This is mentioned in the troubleshooting section of the docs, but I overlooked it at the beginning. Below shows how to clone the project's arm64 branch (taken from the README.md)

git clone --branch arm64 https://github.com/RPI-Distro/pi-gen.git

@reubenmiller
Copy link
Contributor

FYI: I've created a PR to the arm64 branch with a change to the build-docker.sh script to support running on MacOS with the default version of bash (e.g. version 3.x).

#705

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

2 participants