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.

Join-Path doesn't handle provider prefixes correctly on Unix-like platforms

See original GitHub issue

Steps to reproduce

On macOS or Linux:

Join-Path (Get-Item .).PSParentPath foo | Should -Be "$((Get-Item .).PSParentPath)/foo"

Expected behavior

The test should succeed.

Actual behavior

The test fails, because the existing provider prefix isn’t recognized as such, causing its \ separator to be normalized to / and another provider prefix to be prepended.

Expected strings to be the same, but they were different. Expected length: 65 Actual length:   103 Strings differ at index 38. Expected: '...tem::/User...' But was:  '...tem::Micro...'

That is, Join-Path’s output was something like (note the doubled provider prefix, with the 2nd one using /):

Microsoft.PowerShell.Core\FileSystem::Microsoft.PowerShell.Core/FileSystem::/Users/jdoe/Desktop/foo

Environment data

PowerShell Core 7.2.0-preview.2

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
vexx32commented, Jun 27, 2021

@octos4murai I haven’t seen anyone else wanting to take it up, and it seems a fairly clear case of the behaviour being bugged, so yeah, we may as well consider it up for grabs. 🙂

1reaction
mklement0commented, Jan 7, 2021

@iSazonov, yes, because the problem is related to normalizing \ to /.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why doesn't os.path.join() work in this case?
join () is to make your program cross-platform (linux/windows/etc). Even one slash ruins it. So it only makes sense when being used with...
Read more >
Path.Combine() isn't as cross-platform as you think it is
I started using .NET pretty close to the beginning, in either 2002 or 2003. It's hard to accurately remember things that happened before...
Read more >
prevent PowerShell autocomplete from adding dot prefix
As far as I'm concerned, I'd like it to be turned off everywhere—I can remember to type .\foo.exe instead of foo.exe for the...
Read more >
Join-Path - PowerShell
This command uses Join-Path to combine a path with a childpath. Since the command is executed from the FileSystem provider, it provides the...
Read more >
Joining Linux Hosts to an Active Directory Domain with ...
Read this guide to learn how to integrate Linux with Active Directory. We'll also cover how to join AD using realmd, what using...
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