Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux: Import of Az.Accounts fails with obscure error message when $HOME is not set #24813

Open
samuel-kogler-AP opened this issue May 6, 2024 · 1 comment
Assignees
Labels
Accounts Issues in Az.Accounts except authentication related Azure PS Team customer-reported feature-request This issue requires a new behavior in the product in order be resolved. Tracking We will track status and follow internally

Comments

@samuel-kogler-AP
Copy link

Description

When importing Az.Accounts on Linux, the startup checks assume that $HOME is set to a non-empty string. Some CI servers (TeamCity at least) do not set this by default.

The error is thrown in

$pathToInstallationChecks = Join-Path (Join-Path $HOME ".Azure") "AzInstallationChecks.json"

Maybe it would be better to check whether $HOME is set before calling Join-Path there, and either skip the check or produce a meaningful error message.

Issue script & Debug output

Set-Variable -Name Home -Value "" -Force
Import-Module Az.Accounts

Join-Path: {REDACTED}/.local/share/powershell/Modules/Az.Accounts/2.19.0/StartupScripts/AzError.ps1:32
Line |
  32 |      $pathToInstallationChecks = Join-Path (Join-Path $HOME ".Azure")  …
     |                                                       ~~~~~
     | Cannot bind argument to parameter 'Path' because it is an empty string.
InvalidOperation: {REDACTED}/.local/share/powershell/Modules/Az.Accounts/2.19.0/StartupScripts/AzError.ps1:34
Line |
  34 |      if (!(Test-Path $pathToInstallationChecks -ErrorAction Ignore))
     |                      ~~~~~~~~~~~~~~~~~~~~~~~~~
     | The variable '$pathToInstallationChecks' cannot be retrieved because it has not been
     | set.

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Ubuntu 22.04.4 LTS
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.19.0                Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}

Error output

No response

@samuel-kogler-AP samuel-kogler-AP added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels May 6, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported needs-triage This is a new issue that needs to be triaged to the appropriate team. and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels May 6, 2024
@isra-fel isra-fel added Azure PS Team feature-request This issue requires a new behavior in the product in order be resolved. Accounts Issues in Az.Accounts except authentication related Tracking We will track status and follow internally and removed bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels May 7, 2024
@isra-fel
Copy link
Member

isra-fel commented May 7, 2024

Makes sense. We'll evaluate the impact of removing the dependency to $home but at least we can fail gracefully. Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accounts Issues in Az.Accounts except authentication related Azure PS Team customer-reported feature-request This issue requires a new behavior in the product in order be resolved. Tracking We will track status and follow internally
Projects
None yet
Development

No branches or pull requests

3 participants