question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Start-Process on Unix: trying to launch / open a nonexistent file doesn't trigger an error

See original GitHub issue

Note: Windows is not affected.

Steps to reproduce

# Fails on macOS and Linux - no statement-terminating error occurs.
{ Start-Process nosuch } | Should -Throw

If you run Start-Process nosuch directly, a system error message that cannot be captured prints directly to stderr:

  • Ubuntu:
"gio: file:///.../nosuch: Error when getting information for file “/.../nosuch”: No such file or directory"
  • macOS:
The file /.../nosuch does not exist.

Expected behavior

The test should succeed.

Actual behavior

The test fails, because no statement-terminating error is triggered, even though no such file in the current directory / no such executable in the path exists.

Expected an exception, to be thrown, but no exception was thrown.

Environment data

PowerShell Core v7.2.0-preview.4 on macOS 10.15.7
PowerShell Core v7.2.0-preview.4 on Ubuntu 18.04.5 LTS

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
SteveL-MSFTcommented, Mar 17, 2021

The way Start-Process works is it tries to find the target first. If it’s not found, and no arguments were provided, then it tries UseShellExecute = true. At this point, it’s all handled by the dotnet runtime. Dotnet relies on xdg-open on Linux and open on macOS. You can try this by running open foo on macOS and you’ll see the stderr message. It appears that dotnet runtime writes this directly to the console and thus you can’t actually redirect. Created https://github.com/dotnet/runtime/issues/49788

1reaction
joeyaiellocommented, Mar 17, 2021

Seems like a reasonable ask to me, barring difficulty of implementation

Read more comments on GitHub >

github_iconTop Results From Across the Web

linux - How can I launch a new process that is NOT a child ...
I tried putting the 30 second wait (and the second set of commands) into a separate script and calling "./secondScript &" but the...
Read more >
Start Process doesn't work correctly with my exe - Activities
Hello, I created a python script and converted it to an .exe. If I click on the exe it works correctly and creates...
Read more >
os package - os
IsNotExist returns a boolean indicating whether the error is known to report that a file or directory does not exist. It is satisfied...
Read more >
Subprocess management — Python 3.11.4 documentation
A Popen creationflags parameter to specify that a new process does not inherit the error mode of the calling process. Instead, the new...
Read more >
42 FRM-41838 to FRM-99999
Cause : A fatal error occurred while reading the logging configuration file. Action: Do one of the following: 1. Make sure that the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found