Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Register-PSRepository and Register-PackageSource are unable to work correctly on Debian 11 #693

Open
5 tasks done
MFunction96 opened this issue Jan 28, 2023 · 5 comments
Open
5 tasks done

Comments

@MFunction96
Copy link

MFunction96 commented Jan 28, 2023

Prerequisites

Steps to reproduce

  1. Install .NET 6, .NET 7 and Powershell correctly by following official documents on a clean Debian 11.
  2. Follow the document to connect to feed as a Powershell repository.

Expected behavior

Register Powershell repository correctly. 
The commands related to the repository work fine, such as Find-Module.
The result on Debian 11 is same as the one on Windows.

Actual behavior

Registered Powershell repository correctly on Windows only BUT something went wrong on Debian 11.
Throw the following error again and again on the Debian console.


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--V 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.

Error details

Exception             : lt-in dotnet command.
    Type        : System.Management.Automation.CommandNotFoundExceptiont.
    ErrorRecord : o run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
        Exception             : ecified command or file was not found.
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : The term 'NuGet.exe' is not recognized as a name of a cmdlet, function, script file, or executable program.
                      Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
            HResult : -2146233087tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
        TargetObject          : NuGet.exe
        CategoryInfo          : ObjectNotFound: (NuGet.exe:String) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : CommandNotFoundException
    CommandName : NuGet.exe
    Message     : The term 'NuGet.exe' is not recognized as a name of a cmdlet, function, script file, or executable program.
                  Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    HResult     : -2146233087
TargetObject          : NuGet.exe
CategoryInfo          : ObjectNotFound: (NuGet.exe:String) [Get-Command], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
InvocationInfo        : 
    MyCommand        : Get-Command
    ScriptLineNumber : 11590
    OffsetInLine     : 21
    HistoryId        : 18
    ScriptName       : /opt/microsoft/powershell/7/Modules/PowerShellGet/PSModule.psm1
    Line             : $nugetCmd = Microsoft.PowerShell.Core\Get-Command -Name $script:NuGetExeName `
                       
    PositionMessage  : At /opt/microsoft/powershell/7/Modules/PowerShellGet/PSModule.psm1:11590 char:21
                       + … $nugetCmd = Microsoft.PowerShell.Core\Get-Command -Name $script:NuGet …
                       +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PSScriptRoot     : /opt/microsoft/powershell/7/Modules/PowerShellGet
    PSCommandPath    : /opt/microsoft/powershell/7/Modules/PowerShellGet/PSModule.psm1
    InvocationName   : Microsoft.PowerShell.Core\Get-Command
    CommandOrigin    : Internal
ScriptStackTrace      : at Register-PSRepository<Process>, /opt/microsoft/powershell/7/Modules/PowerShellGet/PSModule.psm1: line 11590
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.2
PSEdition                      Core
GitCommitId                    7.3.2
OS                             Linux 5.10.0-21-amd64 PowerShell/PowerShell#1 SMP Debian 5.10.162-1 (2023-01-21)
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

On Windows and expected:
image

On Debian 11 and actual:
image

@StevenBucher98
Copy link
Collaborator

Thanks for opening this issue @MFunction96! This seems more like an issue with PowerShellGet, tagging @alerickson and @anamnavi

@SteveL-MSFT SteveL-MSFT transferred this issue from PowerShell/PowerShell Jan 30, 2023
@daxian-dbw daxian-dbw transferred this issue from PowerShell/PowerShellGetv2 Jan 30, 2023
@daxian-dbw daxian-dbw transferred this issue from PowerShell/PSResourceGet Jan 30, 2023
@alerickson
Copy link
Member

alerickson commented Jan 30, 2023

Hi @MFunction96, could you run dotnet --version? If dotnet is not installed you can find instructions on how to install it here. Please make sure the dotnet executable is under the $env:PATH environment variable as well.

@MFunction96
Copy link
Author

MFunction96 commented Jan 31, 2023

Hi @alerickson. Thanks for your reply! I had installed .NET 6 and .NET 7 properly on Linux refer to the reproduce step.
image

It is clear reason that some procedures inside Register-PSRepository and Register-PackageSource invoked Nuget.exe directly on Linux by Error Detail. Unfortunately, Nuget.exe is not an executable binary on Linux so that it should not be invoked directly on Linux. We should use dotnet nuget <command> on Linux instead of Nuget.exe <command> as far as I know.

@MFunction96
Copy link
Author

I noticed that #677 might be the same issue on Linux environment. The error message seems to be similar with mine.

@anamnavi
Copy link
Member

anamnavi commented Feb 6, 2023

@MFunction96 thanks for sharing this info, we'll investigate into this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants