Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pwsh does not execute script passed with -file on ubuntu #21411

Open
5 tasks done
jjwims opened this issue Apr 3, 2024 · 8 comments
Open
5 tasks done

pwsh does not execute script passed with -file on ubuntu #21411

jjwims opened this issue Apr 3, 2024 · 8 comments
Labels
Needs-Repro The issue author needs to provide repro steps.

Comments

@jjwims
Copy link

jjwims commented Apr 3, 2024

Prerequisites

Steps to reproduce

system: pwsh 7.4.1 ubuntu 22.04 kernel 5.15.0-101-generic
all updated

in bash run pwsh -> works fine
in this pwsh session start a script (hello.ps1) -> works fine
start the script with pwsh -file hello.ps1 -> does not work
not from bash or in a pwsh session
also visualstudio code can not start a remote session to debug powershell

downgraded to 7.3.11 -> everything works fine

Expected behavior

bash> pwsh -file hello.ps1
Hello World!

Actual behavior

bash> pwsh -file hello.ps1
Stack Overflow
Core Dumped

Error details

No response

Environment data

PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Linux 5.15.0-101-generic #111-Ubuntu SMP Tue Mar 5 20:16:58 UTC 2024
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

@jjwims jjwims added the Needs-Triage The issue is new and needs to be triaged by a work group. label Apr 3, 2024
@237dmitry
Copy link

237dmitry commented Apr 3, 2024

Could not reproduce on Arch Linux, pwsh-7.5.0-preview.1, bash-5.2.26

@StevenBucher98
Copy link
Collaborator

Was not able to reproduce on 7.3.4 (yes I need to upgrade my PS version on Ubuntu machine 😆 ) I will upgrade soon and test on 7.4.1, if @237dmitry can't reproduce on preview then perhaps may have been fixed.

@rhubarb-geek-nz
Copy link

rhubarb-geek-nz commented Apr 3, 2024

Jammy with 7.4.1

$ pwsh
PowerShell 7.4.1
PS> exit
$ grep VERSION= /etc/os-release
VERSION="22.04.4 LTS (Jammy Jellyfish)"
$ cat hello.ps1
#!/usr/bin/env pwsh
'Hello World'
$ pwsh ./hello.ps1
Hello World
$ pwsh -file ./hello.ps1
Hello World
$ chmod +x hello.ps1
$ ./hello.ps1
Hello World
$ uname -a
Linux foobar 5.15.0-101-generic #111-Ubuntu SMP Tue Mar 5 20:16:58 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

How did you install PowerShell?

$ dpkg -l powershell
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-==================================================================
ii  powershell     7.4.1-1.deb  amd64        PowerShell is an automation and configuration management platform.

What do the symbolic links for ssl look like?

$ find /opt/microsoft/powershell/7 -type l | xargs ls -l
lrwxrwxrwx 1 root root 22 Jan 13 08:32 /opt/microsoft/powershell/7/libcrypto.so.1.0.0 -> /lib64/libcrypto.so.10
lrwxrwxrwx 1 root root 19 Jan 13 08:32 /opt/microsoft/powershell/7/libssl.so.1.0.0 -> /lib64/libssl.so.10
$ ls  /lib64/libssl.so.10  /lib64/libcrypto.so.10
ls: cannot access '/lib64/libssl.so.10': No such file or directory
ls: cannot access '/lib64/libcrypto.so.10': No such file or directory

@hifron
Copy link

hifron commented Apr 5, 2024

Get-ChildItem -File should do something like Get-ChildItem on Ubuntu snap PowerShell 7.4.1 when symlinks and dirs present, not only common files(or even device files...). Maybe fixed on 7.5 or something Ubuntu snap.

@SeeminglyScience SeeminglyScience added the Needs-Repro The issue author needs to provide repro steps. label Apr 8, 2024
@StevenBucher98 StevenBucher98 removed the Needs-Triage The issue is new and needs to be triaged by a work group. label Apr 8, 2024
@zincarla
Copy link

I had the same issue on Ubuntu 22.04 with PowerShell 7.4.1 today and was fixed by updating to PowerShell version 7.4.2.

It started only in the last few hours, and was working earlier today. Running a script from within pwsh interactively worked fine. Running scripts from bash as pwsh -file "./helloworld.ps1" would fail with:

Stack overflow.
Aborted (core dumped)

But again, I seem to be good now after updating.

@zincarla
Copy link

zincarla commented Apr 26, 2024

Issue came back yesterday for me. Still on PowerShell 7.4.2 and Ubuntu 22.04.4 LTS. Rebooting did not fix it. It crashes even with something as simple as pwsh -command "Write-Host 'test'". It is account dependent for me and seems to only crash when running scripts or commands outside of an interactive pwsh session as root. Curious if the same is true for others. Oddly, it was working fine this last week, no idea what changed. Running similar commands or scripts without root works without crashing such as:

ziviz@ziviz-ubuntu:~$ pwsh -command "write-host 'test'"
test
ziviz@ziviz-ubuntu:~$ sudo pwsh -command "write-host 'test'"
Stack overflow.
Aborted

Running commands interactively works fine however

ziviz@ziviz-ubuntu:~$ sudo pwsh
PowerShell 7.4.2
PS /home/ziviz> write-host "test"
test
PS /home/ziviz> exit

@zincarla
Copy link

I found a workaround for myself, but I have no clue what to make of it. If powershell starts crashing with Stack overflow, I can run pwsh with -nol -noni -nop -w hidden and after getting the warning that Linux does not support the windowstyle parameter, magically powershell starts working again.... at least for about 5 days when I need to run this command again... I'm now on my 3rd instance of running this command to temporarily resolve the issue over the last 2-3 weeks.

ziviz@ziviz-ubuntu:~$ sudo /usr/bin/pwsh -command "write-host 'test'"
Stack overflow.
Aborted
ziviz@ziviz-ubuntu:~$ sudo /usr/bin/pwsh -nol -command "write-host 'test'"
Stack overflow.
Aborted
ziviz@ziviz-ubuntu:~$ sudo /usr/bin/pwsh -nol -command "write-host 'test'"
Stack overflow.
Aborted
ziviz@ziviz-ubuntu:~$ sudo /usr/bin/pwsh -nol -noni -command "write-host 'test'"
Stack overflow.
Aborted
ziviz@ziviz-ubuntu:~$ sudo /usr/bin/pwsh -nol -noni -command "write-host 'test'"
Stack overflow.
Aborted
ziviz@ziviz-ubuntu:~$ sudo /usr/bin/pwsh -nol -noni -nop -command "write-host 'test'"
Stack overflow.
Aborted
ziviz@ziviz-ubuntu:~$ sudo /usr/bin/pwsh -nol -noni -nop -command "write-host 'test'"
Stack overflow.
Aborted
ziviz@ziviz-ubuntu:~$ sudo /usr/bin/pwsh -nol -noni -nop -w hidden -command "write-host 'test'"
Parameter -WindowStyle is not implemented on this platform.
ziviz@ziviz-ubuntu:~$ sudo /usr/bin/pwsh -command "write-host 'test'"
test

@zcla
Copy link

zcla commented May 21, 2024

I found a workaround for myself, but I have no clue what to make of it. If powershell starts crashing with Stack overflow, I can run pwsh with -nol -noni -nop -w hidden and after getting the warning that Linux does not support the windowstyle parameter, magically powershell starts working again.... at least for about 5 days when I need to run this command again... I'm now on my 3rd instance of running this command to temporarily resolve the issue over the last 2-3 weeks.

I tested this workaround here, but unfortunately it didn't work. Thanks for your reply, anyway.

I'm having this problem inside a vscode devcontainer, and restarting it doesn't solve the problem. I have to rebuild it every time this happens. I've tried 7.4.[0-2] versions but the problem persists. I'll keep trying with other versions and report here if I get any good results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Repro The issue author needs to provide repro steps.
Projects
None yet
Development

No branches or pull requests

8 participants