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

[Bug] Convert-RepositoryUri : Cannot bind argument to parameter 'Uri' because it is an empty string. #4917

Closed
lorengordon opened this issue May 12, 2022 · 18 comments · Fixed by #4960 or #4982
Labels

Comments

@lorengordon
Copy link

Bug Report

Current Behavior

With scoop version 0.2.0, scoop bucket add extras generates an error:

PS C:\Users\Administrator> scoop bucket add extras
Convert-RepositoryUri : Cannot bind argument to parameter 'Uri' because it is an empty string.
At C:\Users\Administrator\scoop\apps\scoop\current\lib\buckets.ps1:165 char:41
+         if ((Convert-RepositoryUri -Uri $remote) -eq $uni_repo) {
+                                         ~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Convert-RepositoryUri], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Convert-RepositoryUri

Checking repo... OK
The extras bucket was added successfully.

Since I'm running this in a script with $ErrorActionPreference = "Stop", this causes the script to abort:

PS C:\Users\Administrator> $ErrorActionPreference = "Stop"
PS C:\Users\Administrator> scoop bucket add extras
Convert-RepositoryUri : Cannot bind argument to parameter 'Uri' because it is an empty string.
At C:\Users\Administrator\scoop\apps\scoop\current\lib\buckets.ps1:165 char:41
+         if ((Convert-RepositoryUri -Uri $remote) -eq $uni_repo) {
+                                         ~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Convert-RepositoryUri], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Convert-RepositoryUri

Expected Behavior

Expect to be able to add a bucket without generating an error.

System details

Windows version: Windows Server 2016

OS architecture: 64bit

PowerShell version: 5.1.14393.5066

Scoop Configuration

{
    "lastUpdate":  "2022-05-12T17:38:26.3906272+00:00",
    "aria2-warning-enabled":  false
}
@rashil2000
Copy link
Member

rashil2000 commented May 12, 2022

Can't repro this on Windows 11, PS 5.1.22616.1

image

@lorengordon
Copy link
Author

lorengordon commented May 12, 2022

I was checking the code and am pretty sure it has something to do with the assumptions built into this line:

$remote = git -C "$bucketsdir\$bucket" config --get remote.origin.url

@lorengordon
Copy link
Author

This is a fresh new system, no prior installation or anything. We run an elevated powershell terminal, install scoop using -RunAsAdmin, and then:

scoop install aria2
scoop config aria2-warning-enabled false
scoop install --global 7zip git  # Needed to manage buckets and update scoop
scoop bucket add extras

Reproduces every time.

@Vedabahu
Copy link

Vedabahu commented May 12, 2022

Same for me also.
I am getting same error.
image
I use Windows 7 Version 6.1 (Build 7601: Service Pack 1)

@lorengordon
Copy link
Author

Here's the output of the git command on this system (it's empty):

PS C:\Users\Administrator> git -C "C:\Users\Administrator\scoop\buckets\main" config --get remote.origin.url
PS C:\Users\Administrator> git --version
git version 2.36.1.windows.1

@lorengordon
Copy link
Author

Sure enough, it's not a git repo:

PS C:\Users\Administrator\scoop\buckets\main> ls


    Directory: C:\Users\Administrator\scoop\buckets\main


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        5/12/2022   7:59 PM                .github
d-----        5/12/2022   7:59 PM                .vscode
d-----        5/12/2022   7:59 PM                bin
d-----        5/12/2022   7:59 PM                bucket
d-----        5/12/2022   7:59 PM                deprecated
d-----        5/12/2022   7:59 PM                scripts
-a----        5/12/2022   9:30 AM            452 .editorconfig
-a----        5/12/2022   9:30 AM             84 .gitattributes
-a----        5/12/2022   9:30 AM             44 .gitignore
-a----        5/12/2022   9:30 AM             71 .markdownlint.json
-a----        5/12/2022   9:30 AM           1235 LICENSE
-a----        5/12/2022   9:30 AM            958 README.md
-a----        5/12/2022   9:30 AM            129 Scoop-Bucket.Tests.ps1

@lorengordon
Copy link
Author

If I remove the "main" bucket and re-add it, then everything works:

PS C:\Users\Administrator> scoop bucket add main
Checking repo... OK
The main bucket was added successfully.
PS C:\Users\Administrator> scoop bucket add extras
Checking repo... OK
The extras bucket was added successfully.

@lorengordon
Copy link
Author

At this point, the git command does indeed return a valid url:

PS C:\Users\Administrator> git -C "C:\Users\Administrator\scoop\buckets\main" config --get remote.origin.url
https://github.com/ScoopInstaller/Main

@lorengordon
Copy link
Author

I just went through the steps to reproduce entirely:

  1. Delete the scoop directory
  2. Reinstall scoop
  3. Confirm the directory scoop\buckets\main is not a git repo
  4. Run scoop bucket add extras

image

@lorengordon
Copy link
Author

lorengordon commented May 12, 2022

If I try to run scoop update, which attempts to convert the bucket to a git repo, I run into the same error. And also, it deletes the bucket directory entirely. Oops.

PS C:\Users\Administrator> scoop update
Updating Scoop...
Updating 'main' bucket...
 Converting 'main' bucket to git...
0
Convert-RepositoryUri : Cannot bind argument to parameter 'Uri' because it is an empty string.
At C:\Users\Administrator\scoop\apps\scoop\current\lib\buckets.ps1:159 char:44
+     $uni_repo = Convert-RepositoryUri -Uri $repo
+                                            ~~~~~
    + CategoryInfo          : InvalidData: (:) [Convert-RepositoryUri], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Convert-RepositoryUri

@lorengordon
Copy link
Author

Ok, got a workaround. Install scoop, install git and 7zip, remove the main bucket, readd the main bucket. Then everything works as before.

Creating shim...
Scoop was installed successfully!
Type 'scoop help' for instructions.
PS C:\Users\Administrator> scoop bucket rm main
PS C:\Users\Administrator> scoop bucket add main
Checking repo... OK
The main bucket was added successfully.
PS C:\Users\Administrator> scoop bucket add extras
Checking repo... OK
The extras bucket was added successfully.

@niheaven
Copy link
Member

Okay, a hotfix will be added soon.

@ikappaki
Copy link

Hi @niheaven, may I please enquire about the status of this issue. It appears as if it has been fixed with #4923, but I am still getting the same error when installing from get.scoop.sh; I suppose the fix hasn't been released yet? Thanks

@Francommit
Copy link

Getting the same issue - work around has fixed it for now.

@cech12
Copy link

cech12 commented May 21, 2022

Getting the same issue - work around has fixed it for now.

Same for me

@niheaven
Copy link
Member

It has been fixed in develop branch and will be merged into 'master' in a few days.

@SonaliBendre
Copy link

please fix

@ghost
Copy link

ghost commented Jun 14, 2022

My 'main' bucket no longer existed when I checked. So I ran 'scoop add bucket main' which worked fine. Then running 'scoop update' started working again. I can now run everything with scoop.

Reinstalling everything was a pain though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
8 participants