Title: New-Item -Type SymbolicLink doesn't define symlinks with relative directory targets as directory symlinks · Issue #9127 · PowerShell/PowerShell · GitHub
Open Graph Title: New-Item -Type SymbolicLink doesn't define symlinks with relative directory targets as directory symlinks · Issue #9127 · PowerShell/PowerShell
X Title: New-Item -Type SymbolicLink doesn't define symlinks with relative directory targets as directory symlinks · Issue #9127 · PowerShell/PowerShell
Description: PR #8783 addressed #3500, which brought the ability to define symlinks whose targets are defined as relative paths. On Unix-like platforms, symlinks aren't typed; the symlink behaves as if it were the same type (file or directory) of wha...
Open Graph Description: PR #8783 addressed #3500, which brought the ability to define symlinks whose targets are defined as relative paths. On Unix-like platforms, symlinks aren't typed; the symlink behaves as if it were ...
X Description: PR #8783 addressed #3500, which brought the ability to define symlinks whose targets are defined as relative paths. On Unix-like platforms, symlinks aren't typed; the symlink behaves as if it w...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/9127
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"New-Item -Type SymbolicLink doesn't define symlinks with relative directory targets as directory symlinks","articleBody":"PR #8783 addressed #3500, which brought the ability to define symlinks whose targets are defined as _relative_ paths.\r\n\r\nOn Unix-like platforms, symlinks aren't _typed_; the symlink behaves as if it were the same type (file or directory) of whatever type its _target_ is.\r\n\r\nOn Windows, by contrast, you must explicitly match the target type at symlink creation time for symlinks to _directories_ to act like directories.\r\nSince `New-Item` currently does _not_ allow you to specify a symlink type - enum value `SymbolicLink` is currently the only option - it must itself _infer_ the appropriate type based on the specified _target_.\r\n\r\nAs an aside: Since this inference requires that the target already _exist_, creating symlinks to non-existing targets - which is a legitimate use case - presents a conceptual problem that must be solved separately - see #9067\r\n\r\nCurrently, the inference doesn't work if the target is specified as a _relative_ path to an existing target _directory_.\r\n\r\n# Steps to reproduce (on Windows)\r\n\r\nNote: If you don't have developer mode enabled, run the tests as admin (elevated).\r\n\r\n```powershell\r\nDescribe \"New-Item: symlink with relative path test\" {\r\n BeforeAll {\r\n Push-Location TestDrive:/\r\n # Create a directory...\r\n $null = New-Item -Type Directory someDir\r\n # ... and a symlink to that directory, as a sibling, using a *relative* path.\r\n New-Item -Type SymbolicLink someDirLinkRelative -Target someDir\r\n # ... and a symlink to that directory, as a sibling, using a *relative* path.\r\n New-Item -Type SymbolicLink someDirLinkAbsolute -Target (Convert-Path someDir)\r\n # Echo the symlink target information.\r\n Get-Item someDirLinkRelative, someDirLinkAbsolute | Select LinkType, Target | Out-String | write-verbose -vb\r\n }\r\n AfterAll {\r\n Pop-Location\r\n }\r\n \r\n It \"Symlink with absolute path to existing directory behaves like a directory.\" {\r\n (Get-Item someDirLinkAbsolute) | Should -BeOfType System.IO.DirectoryInfo\r\n }\r\n\r\n It \"Symlink with relative path to existing directory behaves like a directory.\" {\r\n (Get-Item someDirLinkRelative) | Should -BeOfType System.IO.DirectoryInfo\r\n }\r\n \r\n}\r\n```\r\n\r\n# Expected behavior\r\n\r\nBoth tests should succeed.\r\n\r\n# Actual behavior\r\n\r\nThe test with the relative target path fails.\r\nThat is, a _file_ symlink rather than a directory symlink was mistakenly created.\r\n\r\n# Environment data\r\n\r\n```none\r\nPowerShell Core v6.2.0-rc.1 on Microsoft Windows 10 Pro (64-bit; Version 1803, OS Build: 17134.590)\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2019-03-12T21:05:01Z","url":"https://github.com/PowerShell/PowerShell/issues/9127"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5a25004f-3c5f-8433-56c7-3a340a68ea3a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E9B6:3257C8:1F86D6:2AB6D9:6AFD5046 |
| html-safe-nonce | f03143f2b508d64550974221a98aed4ed60557aef66be6ac095ecc11fc2590c8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOUI2OjMyNTdDODoxRjg2RDY6MkFCNkQ5OjZBRkQ1MDQ2IiwidmlzaXRvcl9pZCI6IjY2MzE1MTE2ODY3MjMyMjc3MTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 163625756d743ad42bf46af76bcb524f4eba03435dc1da8c9926de64db951f88 |
| hovercard-subject-tag | issue:420205231 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/9127/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4a2fcd6e900bc85e90ca414a2f38c7cdb355b28e8623851276f3e5b080641a83/PowerShell/PowerShell/issues/9127 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4a2fcd6e900bc85e90ca414a2f38c7cdb355b28e8623851276f3e5b080641a83/PowerShell/PowerShell/issues/9127 |
| og:image:alt | PR #8783 addressed #3500, which brought the ability to define symlinks whose targets are defined as relative paths. On Unix-like platforms, symlinks aren't typed; the symlink behaves as if it were ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width