{"action":"created","issue":{"url":"https://api.github.com/repos/chocolatey/choco/issues/1042","repository_url":"https://api.github.com/repos/chocolatey/choco","labels_url":"https://api.github.com/repos/chocolatey/choco/issues/1042/labels{/name}","comments_url":"https://api.github.com/repos/chocolatey/choco/issues/1042/comments","events_url":"https://api.github.com/repos/chocolatey/choco/issues/1042/events","html_url":"https://github.com/chocolatey/choco/issues/1042","id":188081714,"number":1042,"title":"Join-Path error when installing Chocolatey as SYSTEM","user":{"login":"splatteredbits","id":1082153,"avatar_url":"https://avatars.githubusercontent.com/u/1082153?v=3","gravatar_id":"","url":"https://api.github.com/users/splatteredbits","html_url":"https://github.com/splatteredbits","followers_url":"https://api.github.com/users/splatteredbits/followers","following_url":"https://api.github.com/users/splatteredbits/following{/other_user}","gists_url":"https://api.github.com/users/splatteredbits/gists{/gist_id}","starred_url":"https://api.github.com/users/splatteredbits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/splatteredbits/subscriptions","organizations_url":"https://api.github.com/users/splatteredbits/orgs","repos_url":"https://api.github.com/users/splatteredbits/repos","events_url":"https://api.github.com/users/splatteredbits/events{/privacy}","received_events_url":"https://api.github.com/users/splatteredbits/received_events","type":"User","site_admin":false},"labels":[{"id":163217498,"url":"https://api.github.com/repos/chocolatey/choco/labels/0%20-%20Backlog","name":"0 - Backlog","color":"CCCCCC","default":false},{"id":161961289,"url":"https://api.github.com/repos/chocolatey/choco/labels/Bug","name":"Bug","color":"fc2929","default":false},{"id":161961292,"url":"https://api.github.com/repos/chocolatey/choco/labels/Up%20For%20Grabs","name":"Up For Grabs","color":"159818","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/chocolatey/choco/milestones/29","html_url":"https://github.com/chocolatey/choco/milestones/0.10.4","labels_url":"https://api.github.com/repos/chocolatey/choco/milestones/29/labels","id":2017020,"number":29,"title":"0.10.4","description":"","creator":{"login":"ferventcoder","id":63502,"avatar_url":"https://avatars.githubusercontent.com/u/63502?v=3","gravatar_id":"","url":"https://api.github.com/users/ferventcoder","html_url":"https://github.com/ferventcoder","followers_url":"https://api.github.com/users/ferventcoder/followers","following_url":"https://api.github.com/users/ferventcoder/following{/other_user}","gists_url":"https://api.github.com/users/ferventcoder/gists{/gist_id}","starred_url":"https://api.github.com/users/ferventcoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ferventcoder/subscriptions","organizations_url":"https://api.github.com/users/ferventcoder/orgs","repos_url":"https://api.github.com/users/ferventcoder/repos","events_url":"https://api.github.com/users/ferventcoder/events{/privacy}","received_events_url":"https://api.github.com/users/ferventcoder/received_events","type":"User","site_admin":false},"open_issues":68,"closed_issues":0,"state":"open","created_at":"2016-09-20T16:55:45Z","updated_at":"2016-11-08T20:45:04Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2016-11-08T19:29:12Z","updated_at":"2016-11-08T20:46:09Z","closed_at":null,"body":"### What You Are Seeing?\r\n\r\nAfter installing Chocolatey as SYSTEM, $Global:Error has this error:\r\n\r\n```\r\nJoin-Path : A positional parameter cannot be found that accepts argument 'chocolatey'.\r\nAt C:\\Windows\\TEMP\\chocolatey\\chocInstall\\tools\\chocolateysetup.psm1:198 char:27\r\n\r\n+     $defaultInstallPath = Join-Path [Environment]::GetFolderPath(\"\"CommonApplicat ...\r\n+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\nat Ensure-Permissions, C:\\Windows\\TEMP\\chocolatey\\chocInstall\\tools\\chocolateysetup.psm1: line 198\r\nat Initialize-Chocolatey, C:\\Windows\\TEMP\\chocolatey\\chocInstall\\tools\\chocolateysetup.psm1: line 81\r\nat <ScriptBlock>, C:\\Windows\\TEMP\\chocolatey\\chocInstall\\tools\\chocolateyInstall.ps1: line 16\r\nat <ScriptBlock>, <No file>: line 194\r\nat <ScriptBlock>, E:\\Build\\WhsInit\\Initialize-Computer.ps1: line 183\r\nat <ScriptBlock>, <No file>: line 1\r\n    + CategoryInfo          : InvalidArgument: (:) [Join-Path], ParameterBindingException\r\n    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.JoinPathCommand\r\n```\r\n\r\nOur unattended installer reports this as a failed install because of the error (it looks in $Global:Error).\r\n\r\nWhen I look at the code, I see that this error is handled by a try/catch block. Unfortunately in PowerShell, caught exceptions are still populated in $Global:Error.\r\n\r\n\r\n### What is Expected?\r\n\r\nI expect that handled errors won't appear in $Global:Error. Otherwise, how do I know if the installation failed or not? \r\n\r\n### How Did You Get This To Happen? (Steps to Reproduce)\r\n\r\n* Open PowerShell as SYSTEM: `psexec -d -i -s powershell.exe`\r\n* Run `join-path [Environment]::GetFolderPath(\"CommonApplicationData\") 'chocolatey'`\r\n* Note the error.\r\n\r\nIf you assign the value of `[Environment]::GetFolderPath(\"CommonApplicationData\")` to a variable, and join with that, you avoid the error, e.g.\r\n\r\n```\r\n$commonAppDataPath = [Environment]::GetFolderPath(\"CommonApplicationData\")\r\njoin-path $commonAppDatPath 'chocolatey'\r\n```\r\n\r\nOr, wrap `[Environment]::GetFolderPath(\"CommonApplicationData\")` with parenthesis:\r\n\r\n```\r\njoin-path ([Environment]::GetFolderPath(\"CommonApplicationData\")) 'chocolatey'\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/chocolatey/choco/issues/comments/259254484","html_url":"https://github.com/chocolatey/choco/issues/1042#issuecomment-259254484","issue_url":"https://api.github.com/repos/chocolatey/choco/issues/1042","id":259254484,"user":{"login":"ferventcoder","id":63502,"avatar_url":"https://avatars.githubusercontent.com/u/63502?v=3","gravatar_id":"","url":"https://api.github.com/users/ferventcoder","html_url":"https://github.com/ferventcoder","followers_url":"https://api.github.com/users/ferventcoder/followers","following_url":"https://api.github.com/users/ferventcoder/following{/other_user}","gists_url":"https://api.github.com/users/ferventcoder/gists{/gist_id}","starred_url":"https://api.github.com/users/ferventcoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ferventcoder/subscriptions","organizations_url":"https://api.github.com/users/ferventcoder/orgs","repos_url":"https://api.github.com/users/ferventcoder/repos","events_url":"https://api.github.com/users/ferventcoder/events{/privacy}","received_events_url":"https://api.github.com/users/ferventcoder/received_events","type":"User","site_admin":false},"created_at":"2016-11-08T20:46:09Z","updated_at":"2016-11-08T20:46:09Z","body":"> Or, wrap [Environment]::GetFolderPath(\"CommonApplicationData\") with parenthesis\r\n\r\nTIL"}}
{"actor":{"display_login":"ferventcoder"}}