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 with a macOS application bundle doesn't support arguments

See original GitHub issue

The problem seems related to the fact that macOS .app bundles are directories, not single files.

Steps to reproduce

# On macOS
# This should be the equivalent of:
#      open -a /Applications/Safari.app http://example.org  # or: open -a Safari http://example.org
{ Start-Process /Applications/Safari.app -ArgumentList http://example.org } |
  Should -Not -Throw

Expected behavior

The test should succeed, and Safari should open to http://example.org

Actual behavior

The test fails:

Expected no exception to be thrown, but an exception "The FileName property should not be a directory unless UseShellExecute is set." was thrown from

Note that not passing arguments (omitting -ArgumentList) works as expected

Environment data

PowerShell Core v7.0.0-preview.3 on macOS 10.14.6

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
computersarecoolcommented, Feb 15, 2023

Hey @microsoft @satyanadella @PowerShellTeam despite a great bug report from @mklement0 this issue has not been addressed (nor even commented on) by anyone from your team more than three years later. This is exactly the thing that demonstrates that you are not serious about making Powershell actually cross-platform. Please fix the issue or at least comment. Thanks!

0reactions
brunoroque06commented, May 11, 2023

Another workaround:

& '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' `
    --disable-web-security `
    --new-window http://localhost:4200 `
    --no-first-run `
    --user-data-dir=$env:TMPDIR/webbrowser
Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I run an application with command line arguments ...
app bundle, select "Show Package Contents", navigate to Info.plist, double click it, find Args key, edit. I don't have an OS X machine...
Read more >
MacOS app - why does CommandLine.arguments of an ...
I think this is because the CommandLine.arguments only works when the app is initially launched and arguments are passed into the main function....
Read more >
Signing a Mac Product For Distribution
To get started, decide on your container format. Mac products support two distribution channels: An app can be distributed via the Mac App...
Read more >
How to get an application executable path from Terminal
I would like to know if there is a command that returns the executable within the application bundle. There is no such command, ......
Read more >
Building a Universal macOS Binary
Create macOS apps and other executables that run natively on both Apple silicon and Intel-based Mac computers.
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