PowerShellGetv2
PowerShellGetv2 copied to clipboard
Register-PSRepository fails if user profile path contains a space
Steps to reproduce
Register-PSRepository -Name iQmetrix -SourceLocation "https://pkgs.dev.azure.com/iqmetrix/_packaging/iqmetrix/nuget/v2" -PublishLocation "https://pkgs.dev.azure.com/iqmetrix/_packaging/iqmetrix/nuget/v2"
Expected behavior
A new PSRepository registration called iQmetrix
is created.
Actual behavior
PS C:\code\PowerShellGet\src\code> Register-PSRepository -Name iQmetrix -SourceLocation "https://pkgs.dev.azure.com/iqmetrix/_packaging/iqmetrix/nuget/v2" -PublishLocation "https://pkgs.dev.azure.com/iqmetrix/_packaging/iqmetrix/nuget/v2"
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet-C:\Users\Jonathan does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet-C:\Users\Jonathan does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Exception calling "Match" with "2" argument(s): "Value cannot be null.
Parameter name: input"
At C:\Users\Jonathan Gilbert\Documents\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9370 char:5
+ $username = [System.Text.RegularExpressions.Regex]::Match($conten ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentNullException
Exception calling "Match" with "2" argument(s): "Value cannot be null.
Parameter name: input"
At C:\Users\Jonathan Gilbert\Documents\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9371 char:5
+ $password = [System.Text.RegularExpressions.Regex]::Match($conten ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentNullException
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet-C:\Users\Jonathan does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet-C:\Users\Jonathan does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Exception calling "Match" with "2" argument(s): "Value cannot be null.
Parameter name: input"
At C:\Users\Jonathan Gilbert\Documents\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9370 char:5
+ $username = [System.Text.RegularExpressions.Regex]::Match($conten ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentNullException
Exception calling "Match" with "2" argument(s): "Value cannot be null.
Parameter name: input"
At C:\Users\Jonathan Gilbert\Documents\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9371 char:5
+ $password = [System.Text.RegularExpressions.Regex]::Match($conten ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentNullException
Register-PSRepository : The specified repository 'iQmetrix' is unauthorized and cannot be registered. Try running with
-Credential.
At line:1 char:1
+ Register-PSRepository -Name iQmetrix -SourceLocation "https://pkgs.de ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : RepositoryCannotBeRegistered,Register-PSRepository
PS C:\code\PowerShellGet\src\code>
Environment data
This is almost certainly the trigger for this bug:
> $env:HOMEPATH
\Users\Jonathan Gilbert
The path to my user profile contains a space. Process Monitor reports that PowerShell, in the execution of Register-PSRepository
, is creating child processes such as:
"dotnet" C:\Users\Jonathan Gilbert/.nuget/plugins/netcore/CredentialProvider.Microsoft/CredentialProvider.Microsoft.dll -V verbose -U https://pkgs.dev.azure.com/iqmetrix/_packaging/iqmetrix/nuget/v2
Note that this is passing in a path to a file inside the .nuget
folder in my user profile but it isn't quoted, so the space splits the path into multiple arguments to dotnet
.
Other things the template asked for:
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.610
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.610
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> Get-Module -ListAvailable PowerShellGet,PackageManagement
Directory: C:\Users\Jonathan Gilbert\Documents\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.4.7 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Pack...
Script 2.2.5 PowerShellGet {Find-Command, Find-DSCResource, Find-Module, Find-RoleCa...
Script 2.2.4.1 PowerShellGet {Find-Command, Find-DSCResource, Find-Module, Find-RoleCa...
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Pack...
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}
> Get-PackageProvider -ListAvailable
Name Version DynamicOptions
---- ------- --------------
msi 3.0.0.0 AdditionalArguments
msu 3.0.0.0
nuget 2.8.5.208
NuGet 3.0.0.1 Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTa...
PowerShellGet 2.2.5.0 PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck,...
PowerShellGet 2.2.4.1
PowerShellGet 1.0.0.1
Programs 3.0.0.0 IncludeWindowsInstaller, IncludeSystemComponent