fix(tools): prevent awk errors in setup_rust on restricted containers (#9985)

Add error suppression and || true to awk commands that parse rustc version.
Prevents 'Operation not permitted' errors in containers with restricted syscalls.
This commit is contained in:
CanbiZ
2025-12-15 15:22:32 +01:00
committed by GitHub
parent 9374e5d183
commit c2034039e8

View File

@ -4424,7 +4424,7 @@ function setup_rust() {
# Get currently installed version # Get currently installed version
local CURRENT_VERSION="" local CURRENT_VERSION=""
if command -v rustc &>/dev/null; then if command -v rustc &>/dev/null; then
CURRENT_VERSION=$(rustc --version 2>/dev/null | awk '{print $2}') CURRENT_VERSION=$(rustc --version 2>/dev/null | awk '{print $2}' 2>/dev/null) || true
fi fi
# Scenario 1: Rustup not installed - fresh install # Scenario 1: Rustup not installed - fresh install
@ -4443,7 +4443,8 @@ function setup_rust() {
return 1 return 1
fi fi
local RUST_VERSION=$(rustc --version 2>/dev/null | awk '{print $2}') local RUST_VERSION
RUST_VERSION=$(rustc --version 2>/dev/null | awk '{print $2}' 2>/dev/null) || true
if [[ -z "$RUST_VERSION" ]]; then if [[ -z "$RUST_VERSION" ]]; then
msg_error "Failed to determine Rust version" msg_error "Failed to determine Rust version"
return 1 return 1
@ -4474,7 +4475,8 @@ function setup_rust() {
# Ensure PATH is updated for current shell session # Ensure PATH is updated for current shell session
export PATH="$CARGO_BIN:$PATH" export PATH="$CARGO_BIN:$PATH"
local RUST_VERSION=$(rustc --version 2>/dev/null | awk '{print $2}') local RUST_VERSION
RUST_VERSION=$(rustc --version 2>/dev/null | awk '{print $2}' 2>/dev/null) || true
if [[ -z "$RUST_VERSION" ]]; then if [[ -z "$RUST_VERSION" ]]; then
msg_error "Failed to determine Rust version after update" msg_error "Failed to determine Rust version after update"
return 1 return 1