Skip to content

dotnet install fails for prefixed packages #2629

@rkm

Description

@rkm

search you tried in the issue tracker

dotnet tool

describe your issue

A bit of an oversight when constructing tool_name here:

# Determine tool from the packaged file <tool_name>.<version>.nupkg
build_outputs = os.listdir(os.path.join(prefix.prefix_dir, build_dir))
for output in build_outputs:
tool_name = output.split('.')[0]

E.g.

$ pre-commit try-repo https://github.com/rkm/sample-dotnet-tool
[INFO] Initializing environment for https://github.com/rkm/sample-dotnet-tool.
===============================================================================
Using config:
===============================================================================
repos:
-   repo: https://github.com/rkm/sample-dotnet-tool
    rev: e53a3601bc06bb038dac30da813572291dd8d58f
    hooks:
    -   id: sample-dotnet-tool
===============================================================================
[INFO] Installing environment for https://github.com/rkm/sample-dotnet-tool.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/home/rkm/bin/dotnet', 'tool', 'install', '--tool-path', '/tmp/tmp6bk4v26x/repotefhurdg/dotnetenv-default/bin', '--add-source', 'pre-commit-build', 'Rkm')
return code: 1
expected return code: 0
stdout:
    /tmp/1873db78-d0a7-48ba-bbff-10a7ef85a2a6/restore.csproj : error NU1101: Unable to find package rkm. No packages exist with this id in source(s): /tmp/tmp6bk4v26x/repotefhurdg/pre-commit-build, nuget.org

stderr:
    The tool package could not be restored.
    Tool 'rkm' failed to install. This failure may have been caused by:

    * You are attempting to install a preview release and did not use the --version option to specify the version.
    * A package by this name was found, but it was not a .NET tool.
    * The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
    * You mistyped the name of the tool.

    For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool

Check the log at /home/rkm/.cache/pre-commit/pre-commit.log

pre-commit --version

pre-commit 2.20.0

.pre-commit-config.yaml

repos:
-   repo: https://github.com/rkm/sample-dotnet-tool
    rev: e53a3601bc06bb038dac30da813572291dd8d58f
    hooks:
    -   id: sample-dotnet-tool

~/.cache/pre-commit/pre-commit.log (if present)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions