Skip to content

fix(installer): macOS support — bash 3.2 compat + correct miner paths#8005

Open
rebel117 wants to merge 2 commits into
Scottcjn:mainfrom
rebel117:fix-7975-macos-install-script
Open

fix(installer): macOS support — bash 3.2 compat + correct miner paths#8005
rebel117 wants to merge 2 commits into
Scottcjn:mainfrom
rebel117:fix-7975-macos-install-script

Conversation

@rebel117

Copy link
Copy Markdown
Contributor

Fixes #7975.

The one-line installer (scripts/install.sh) crashes immediately on macOS. Two root causes, both fixed here.

What was broken

1. declare -A is a bash 4+ feature; macOS ships bash 3.2

declare -A MULT_TABLE=(
    [sparc]="2.9"   [mips]="3.0"    [68k]="3.5"
    ...
)

Run this on any stock Mac and you get bash: line 60: sparc: unbound variable — the script never gets past the constants block.

2. Miner URLs hard-coded to miners/linux/ (404 on macOS)

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

The actual macOS miner lives under miners/macos/rustchain_mac_miner_v2.5.py, so even after fixing #1 the download step would 404. Verified against the raw URLs:

  • miners/linux/rustchain_linux_miner.py → 200 (Linux only)
  • miners/macos/rustchain_mac_miner_v2.5.py → 200
  • miners/macos/fingerprint_checks.py → 200

The fix

  • Replaced the associative array with a plain case-based arch_multiplier() helper. Same values, works on bash 3.2 through 5.x.
  • Detect the OS once at the top (uname -s) and pick the right subdir + filename: miners/macos/rustchain_mac_miner_v2.5.py for Darwin, miners/linux/rustchain_linux_miner.py otherwise.
  • The macOS miner imports the sibling color_logs module, so that is now fetched for Darwin installs.
  • miner_crypto.py is only shipped for Linux (optional attestation signing); on macOS it is skipped instead of failing the install.
  • Updated ExecStart (systemd) and the launchd plist to reference the real downloaded filename.

Verification

  • bash -n scripts/install.sh passes (no syntax errors).
  • arch_multiplier / get_multiplier unit-checked for all 13 arch values — output matches the old table exactly, including the 0.0005 fallback for ARM/aarch64 and 1.0 default.
  • No bash 4+ constructs remain (declare -A, ${var,,}, mapfile/readarray all zero occurrences).
  • Resolved URLs checked against raw.githubusercontent.com — Linux paths stay 200, macOS paths now 200 (were 404).
  • Linux install path unchanged in behavior: same files downloaded to the same locations, same service definition.

The one-line installer crashed on macOS for two reasons:

1. The MULT_TABLE associative array (declare -A) is a bash 4+ feature.
   macOS ships bash 3.2, so the script died immediately with
   "sparc: unbound variable". Replaced with a plain case-based
   arch_multiplier() function that returns the same values.

2. The miner download URLs were hard-coded to miners/linux/, which 404s
   on macOS since the macOS miner lives under miners/macos/. Now the
   OS is detected at the top and the correct per-OS subdir and filename
   are used (rustchain_mac_miner_v2.5.py for Darwin, rustchain_linux_miner.py
   otherwise).

Also: the macOS miner imports the sibling color_logs module, so that is
now fetched for Darwin installs; miner_crypto.py (Linux-only, optional
attestation signing) is skipped on macOS rather than failing the install.
Service ExecStart and launchd plist paths updated to use the real filename.

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 and removed BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) labels Jul 17, 2026
@Scottcjn

Copy link
Copy Markdown
Owner

Good news first: this touches only scripts/install.sh — no workflow/CI files — and the bash 3.2 + macOS-path fix itself is real and the cleaner of your two installer PRs. But the test job fails for a real reason (not pre-existing): the repo's installer-contract tests in tests/test_scripts_installer_downloads.py assert on install.sh, and your restructure breaks two:

  1. test_scripts_installer_uses_existing_linux_miner_paths expects the literal MINER_URL="${REPO_RAW}/miners/linux/rustchain_linux_miner.py" — make sure the Linux branch still downloads that exact path.
  2. test_scripts_installer_fails_on_http_download_errors expects the [ ! -s "${INSTALL_DIR}/miner_crypto.py" ] empty-file guard — your 'miner_crypto Linux-only/optional' change dropped it.

These tests protect the curl | bash install UX, so please update the installer to keep both invariants (or, if the new structure is deliberately different, update those two tests to match and explain why) so test goes green. Once CI passes this is mergeable — it's the version I'd take over #7995.

- Restore literal MINER_URL=".../miners/linux/rustchain_linux_miner.py"
  on Linux so test_scripts_installer_uses_existing_linux_miner_paths passes
- Always run download_file ${MINER_CRYPTO_URL} on Linux and keep the
  [ ! -s .../miner_crypto.py ] empty-file guard so
  test_scripts_installer_fails_on_http_download_errors passes again
- macOS keeps the conditional color_logs + no-miner_crypto path
@github-actions github-actions Bot added the BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) label Jul 18, 2026
@rebel117

Copy link
Copy Markdown
Contributor Author

Good catches, both. Fixed in 3ebbdc1:

  • Linux branch keeps the literal MINER_URL="${REPO_RAW}/miners/linux/rustchain_linux_miner.py" and the other miners/linux/ paths the contract tests assert on.
  • download_file "${MINER_CRYPTO_URL}" runs unconditionally on Linux again, and the [ ! -s "${INSTALL_DIR}/miner_crypto.py" ] guard is back so test_scripts_installer_fails_on_http_download_errors passes.

macOS still gets the miners/macos/ paths + the conditional color_logs.py and skips miner_crypto.py. All three tests in test_scripts_installer_downloads.py pass locally.

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

2 participants