PowerShell / PowerShell/PowerShell

Pwsh still corrupts environment variable on Linux Arm 64

Open
#24,693 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs-Triage WG-Engine WG-NeedsReview
Dominant language
C#
Stars
55.5k
Forks
8.5k
Avg merge
1d 2h
Merged PRs (30d)
88

Description

Prerequisites
Steps to reproduce

use the following docker file building on a Linux Arm machine (I'm using AWS Graviton EC2)

FROM mcr.microsoft.com/dotnet/sdk:9.0.101-noble-${TARGETARCH}${TARGETVARIANT}
ARG TARGETPLATFORM
ARG TARGETARCH
ARG TARGETVARIANT
ARG BUILDVARIANT
ARG ARM64ORX64
RUN printf "I'm building for TARGETPLATFORM=${TARGETPLATFORM}" \
&& printf ", TARGETVARIANT=${TARGETVARIANT}" \
&& printf ", TARGETARCH=${TARGETARCH}" \
&& printf ", BUILDVARIANT=${BUILDVARIANT} \n" \
&& printf ", ARM64ORX64=${ARM64ORX64} \n" \
    && printf "With uname -s : " && uname -s \
    && printf "and  uname -m : " && uname -m

RUN pwsh
RUN pwsh --version
RUN which pwsh
RUN echo $PATH
RUN ls -l /usr/bin/pwsh
RUN pwsh -Command 'Write-Host ${env:PSHOME}'
RUN pwsh -Command 'Write-Host ${env:PATH}'
RUN pwsh -Command 'pwsh -EncodedCommand VwByAGkAdABlAC0ASABvAHMAdAAgACcAaABlAGwAbABvACcA'

and the following Exec format error is output

 > [10/10] RUN pwsh -Command 'pwsh -EncodedCommand VwByAGkAdABlAC0ASABvAHMAdAAgACcAaABlAGwAbABvACcA':

[2024-12-18T13:30:25.569Z] 1.392 ResourceUnavailable: Program 'pwsh' failed to run: An error occurred trying to start process '/usr/share/powershell/.store/powershell.linux.arm64/7.5.0-preview.5/powershell.linux.arm64/7.5.0-preview.5/tools/net9.0/any/pwsh' with working directory '/'. Exec format errorAt line:1 char:1

Full docker output : dockerlog.txt

this was originally raised via Issue https://github.com/PowerShell/PowerShell/issues/24090 and I thought this was resolved in PR https://github.com/PowerShell/PowerShell/pull/24228

Expected behavior
[2024-12-18T13:27:43.017Z] #13 [10/10] RUN pwsh -Command 'pwsh -EncodedCommand VwByAGkAdABlAC0ASABvAHMAdAAgACcAaABlAGwAbABvACcA'


should output "hello"
Actual behavior
[2024-12-18T13:30:25.569Z] #13 1.392 ResourceUnavailable: Program 'pwsh' failed to run: An error occurred trying to start process '/usr/share/powershell/.store/powershell.linux.arm64/7.5.0-preview.5/powershell.linux.arm64/7.5.0-preview.5/tools/net9.0/any/pwsh' with working directory '/'. Exec format errorAt line:1 char:1
Error details

No response

Environment data
RUN pwsh $PSVersionTable

[2024-12-19T10:04:36.769Z] #11 0.636 PowerShell 7.5.0-preview.5
Visuals

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Dockerfile reproduction on a Linux ARM64 host and the pwsh -Command 'pwsh -EncodedCommand ...' entry point. Compare the reported PowerShell 7.5.0-preview.5 behavior with issue #24090 and PR #24228. Done means the command runs successfully in the ARM64 image and outputs hello instead of an Exec format error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, shell
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.