If I run this

#!/bin/bash

ARCH=$(python fetch_architecture.py)
if [ $ARCH == "aarch64" -o $ARCH == "armv71" ] ; then
    export PATH=/opt/local/llvm/bin:${PATH}
    cd /app
    RUSTFLAGS="-C linker=lld" wasm-pack build --target web --release plume-front
else
    wasm-pack build --target web --release plume-front
fi

via the terminal, it works just fine. But when I run it via the Dockerfile,

COPY . . 
RUN cargo install wasm-pack 
RUN chmod a+x ./script/plume-front.sh 
RUN sleep 1 
RUN ./script/plume-front.sh

It says python: command not found and then [: too many arguments

  • @[email protected]
    link
    fedilink
    English
    14
    edit-2
    12 days ago

    Python is not found, so $ARCH gets assigned to "", and you didn’t double quote your variables in the comparison, so the code parses as [ == "aarch64" which is a syntax error.

    Also, maybe uname -m could work instead of that Python script.

    • @sabreW4K3OP
      link
      712 days ago

      This was super insightful. Thank you so much.

    • @sabreW4K3OP
      link
      212 days ago

      Rust:1.78-bookworm.

      Thank you, manually included it.

  • @[email protected]
    link
    fedilink
    711 days ago

    You should use python3 anyway not python. The latter is sometimes Python 3, sometimes Python 2 and sometimes doesn’t exist. python3 works reliably, assuming you have it installed.

    (And assuming you aren’t using the official Windows Python installer, but that doesn’t seem like the case here!)

    • @sabreW4K3OP
      link
      311 days ago

      I ended up adding Python3 as it moaned when I just added Python. Thank you so much for your advice though. I’m grateful.

  • @[email protected]
    link
    fedilink
    612 days ago

    Python is not on the Path for docker. The error message “python: command not found” is then passed to the [ command (also called test) which says too many arguments.

    Add the path /use/bin/ to your python command. Or figure out why it isn’t on the docker path.

    • @sabreW4K3OP
      link
      112 days ago

      Apologies, I thought it was Python because I was trying to execute a Python script. And double sorry for not knowing how to interpret the error message.