Skip to content

fix(install): macOS bash 3.2 crash and wrong download paths#7995

Closed
rebel117 wants to merge 1 commit into
Scottcjn:mainfrom
rebel117:fix-7975-macos-install
Closed

fix(install): macOS bash 3.2 crash and wrong download paths#7995
rebel117 wants to merge 1 commit into
Scottcjn:mainfrom
rebel117:fix-7975-macos-install

Conversation

@rebel117

Copy link
Copy Markdown
Contributor

Problem

The installer (scripts/install.sh) has two bugs that prevent it from running on macOS:

1. declare -A crashes on macOS bash 3.2

macOS ships bash 3.2 by default, which doesn't support associative arrays. Running the script produces:

bash: line 36: sparc: unbound variable

2. Hardcoded Linux download paths

MINER_URL, FINGERPRINT_URL, and MINER_CRYPTO_URL all point at miners/linux/ regardless of OS. On macOS the script downloads the Linux miner and tries to download miner_crypto.py which doesn't exist in miners/macos/.

Fix

  1. Replaced declare -A MULT_TABLE with a get_mult_value() function using a plain case statement — works on bash 3.2+
  2. Added OS detection for MINER_SUBDIR so macOS gets miners/macos/rustchain_mac_miner_v2.5.py instead of the Linux miner
  3. Made miner_crypto.py download conditional on Linux (macOS miner is self-contained)
  4. Introduced MINER_SCRIPT variable so systemd/launchd service files reference the correct script name per platform
  5. Bumped install.sh (root) macOS miner reference from v2.4 to v2.5

Testing

  • bash -n scripts/install.sh — syntax OK
  • bash -n install.sh — syntax OK
  • Verified get_mult_value() returns correct values for all arch keys
  • Confirmed no declare -A remains in either script

Fixes #7975

scripts/install.sh used declare -A for the multiplier table, which
crashes on macOS bash 3.2 (sparc: unbound variable). Replaced with a
plain case statement function that works on all bash versions.

The Linux installer also hardcoded download URLs pointing at
miners/linux/ even on macOS. Now selects the correct platform-specific
miner script (rustchain_mac_miner_v2.5.py) and skips miner_crypto.py
which doesn't exist for macOS.

Updated install.sh to reference the latest macOS miner v2.5 instead
of v2.4.

Fixes Scottcjn#7975
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Non-doc PRs have a BCOS-L1 or BCOS-L2 label
  • Doc-only PRs are exempt from BCOS tier labels when they only touch docs/**, *.md, or common image/PDF files
  • New code files include an SPDX license header
  • You've tested your changes against the live node

Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150)

A maintainer will review your PR soon. Thanks for contributing!

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/M PR: 51-200 lines labels Jul 15, 2026
@elevasyncsolutions-jpg

Copy link
Copy Markdown
Contributor

Review of PR #7995 — macOS bash 3.2 Compatibility + Download Path Fix

Observation 1: MINER_URL still hardcodes rustchain_linux_miner.py even when MINER_SUBDIR=macos (scripts/install.sh)

The initial assignment on line 55 uses:

MINER_URL="${REPO_RAW}/miners/${MINER_SUBDIR}/rustchain_linux_miner.py"

When MINER_SUBDIR=macos, this resolves to miners/macos/rustchain_linux_miner.py — which is wrong. The subsequent if block corrects it to rustchain_mac_miner_v2.5.py, but the initial wrong URL is assigned first. While the if block fixes it, this creates a confusing code path. Consider setting MINER_URL conditionally from the start, or using a case statement to set all three URLs together.

Observation 2: declare -A replacement uses parallel arrays which may break if entries are reordered (scripts/install.sh)

The fix replaces declare -A with parallel arrays MULT_KEYS and MULT_VALUES. This works, but the lookup relies on matching indices. If someone adds an entry to one array but forgets the other, the lookup silently returns the wrong multiplier. Consider using a single case statement instead:

get_multiplier() {
    case "$1" in
        sparc) echo "2.9";; mips) echo "3.0";; 68k) echo "3.5";;
        g4) echo "2.5";; g5) echo "2.0";; g3) echo "1.8";;
        power8) echo "1.5";; riscv) echo "1.4";; retro) echo "1.4";;
        apple_silicon) echo "1.2";; modern) echo "1.0";; aarch64) echo "0.0005";;
        *) echo "1.0";;
    esac
}

This is more idiomatic for bash 3.2 and avoids the index-matching fragility.

Observation 3: The aarch64 multiplier 0.0005 seems suspiciously low

A multiplier of 0.0005 means aarch64 miners get 0.05% of the base reward. This is 2000x less than modern (1.0). If this is intentional (e.g. aarch64 is not yet supported), it should have a comment explaining why. If it's a placeholder, it could cause confusion for users who see nearly zero rewards on ARM64 Linux.

Positive notes

  • The uname -s approach for detecting macOS is portable and correct.
  • The macOS miner path version bump from v2.4 to v2.5 is clearly documented.
  • The bash 3.2 compatibility fix is the right approach — associative arrays were only added in bash 4.0.

@Scottcjn

Copy link
Copy Markdown
Owner

You have two PRs doing the same macOS bash-3.2 installer fix — this one and #8005. #8005 is the cleaner implementation (single-branch OS resolution, graceful fallbacks), so let's consolidate there. Closing this in favor of #8005; I've left the specifics of the remaining CI failure on that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/M PR: 51-200 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: install script at rustchain.org has wrong file paths and crashes on macOS

3 participants