Skip to content

CurrentUser does not operate consistently #64

@trackd

Description

@trackd

Hey,

was testing this out a bit,

I was just curious if this wouldnt make more sense to be changed,

Install-ModuleFast -Name Az.CosmosDB -Destination CurrentUser
WARNING: Parameter -Destination is set to a custom path not in your current PSModulePath. We will add it to your PSModulePath for this session. You can suppress this behavior with the -NoPSModulePathUpdate switch.

# it needs to be 
Install-ModuleFast 'Az.CosmosDB' -Destination 'CurrentUser' -NoProfileUpdate -NoPSModulePathUpdate

But the implication when you choose 'CurrentUser' (on Windows)

elseif ($IsWindows -and $Destination -eq 'CurrentUser') {
      $windowsDefaultDocumentsPath = Join-Path ([Environment]::GetFolderPath('MyDocuments')) 'PowerShell/Modules'
      $Destination = $windowsDefaultDocumentsPath
      # so you could add
      $NoPSModulePathUpdate = $true
      $NoProfileUpdate = $true
}

That already means we do not need to update the $env:PSModulePath or the $Profile so could just disable the updates.


as i was typing this out i found the bug that was causing it.
$PSModulePaths is not defined

    if (-not $NoPSModulePathUpdate) {
      if ($defaultRepoPath -ne $Destination -and $Destination -notin $PSModulePaths) {
        Write-Warning 'Parameter -Destination is set to a custom path not in your current PSModulePath. We will add it to your PSModulePath for this session. You can suppress this behavior with the -NoPSModulePathUpdate switch.'
        $NoProfileUpdate = $true
      }

just needs to add

    $PSModulePaths = $env:PSModulePath.Split([Path]::PathSeparator, [StringSplitOptions]::RemoveEmptyEntries)

to Install-ModuleFast function

could still set the values in the'CurrentUser' block so it skips NoPSModulePathUpdate check for that scenario.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions