You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Alpine Docker环境下Healpix无法通过echo配置,Ubuntu可正常运行

Fixing Healpix Configure Failure in Alpine Docker Images

I’ve run into exactly this kind of shell compatibility snag when switching from Ubuntu (bash) to Alpine (ash) before—let’s break down what’s going wrong and how to fix it:

Root Cause

Alpine uses ash as its default shell instead of bash, and ash enforces stricter rules for the exit command: it only accepts integer values between 0 and 255. The Healpix configure script uses exit -1 to signal errors, which ash rejects as an "Illegal number"—that’s the core of your error.

The line number mismatch (your configure script is shorter than line 162) is probably because the error is coming from a subscript called by ./configure, not the main script itself.

Solutions

1. Fix Invalid Exit Codes in the Configure Script

Use sed to replace all instances of exit -1 with exit 1 (a standard non-zero error code for Unix scripts) before running configure:

FROM alpine
RUN apk --no-cache add gcc g++ gfortran make wget musl-dev
WORKDIR /home
RUN wget http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio_latest.tar.gz \
    && tar xzf cfitsio_latest.tar.gz
WORKDIR cfitsio
RUN ./configure --prefix=/usr && make && make install
WORKDIR /home
RUN wget https://sourceforge.net/projects/healpix/files/Healpix_3.50/Healpix_3.50_2018Dec10.tar.gz \
    && tar xzf Healpix*.tar.gz
WORKDIR Healpix_3.50
# Fix ash-incompatible exit codes
RUN sed -i 's/exit -1/exit 1/g' ./configure
RUN echo "3\ngfortran\n\nY\n\n\ngcc\n\n\n\n\nN\n1\nY\nN\nN\n0\n" | ./configure && make

2. Force Configure to Run with Bash

If modifying the script feels too hacky, install bash and explicitly use it to execute the configure script:

FROM alpine
RUN apk --no-cache add gcc g++ gfortran make wget bash musl-dev
WORKDIR /home
RUN wget http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio_latest.tar.gz \
    && tar xzf cfitsio_latest.tar.gz
WORKDIR cfitsio
RUN ./configure --prefix=/usr && make && make install
WORKDIR /home
RUN wget https://sourceforge.net/projects/healpix/files/Healpix_3.50/Healpix_3.50_2018Dec10.tar.gz \
    && tar xzf Healpix*.tar.gz
WORKDIR Healpix_3.50
# Run configure with bash instead of ash
RUN echo "3\ngfortran\n\nY\n\n\ngcc\n\n\n\n\nN\n1\nY\nN\nN\n0\n" | bash ./configure && make

Quick Dependency Note

I added musl-dev to the apk install command—Alpine uses musl as its standard C library, and some build processes require the dev package to access necessary headers, which avoids potential compilation failures.

内容的提问来源于stack exchange,提问作者Paddy Roddy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 04:45:56