Scoop: Uninstalling app with `_` or `:` in name uninstalls app which matches the part before that character (scoop_ruby_20_to25 => scoop)

Created on 14 Feb 2019  路  13Comments  路  Source: lukesampson/scoop

I have created a manifest scoop_ruby_20_to_25 via a Gist that contains an older version of the ruby Manifest: https://gist.githubusercontent.com/janpio/40e014d0ae31215b4bab2b5bbe5a69e8/raw/3500373c9484ca8c3c89aac4998cda333451a555/scoop_ruby_20_to_25.json

I use it to install older Ruby versions, like e.g. 2.4.5:

scoop_ruby_20_to_25 2.4.5-1

No I tried to uninstall that app. Look what happens:

PS C:\Users\Jan> scoop list
Installed apps:

  7zip 18.06
  ...
  scoop_ruby_20_to_25 2.4.5-1 [https://gist.githubusercontent.com/janpio/40e014d0ae31215b4bab2b5bbe5a69e8/raw/3500373c9484ca8c3c89aac4998cda333451a555/scoop_ruby_20_to_25.json]
  ...
  winscp 5.13.7 [extras]

PS C:\Users\Jan> scoop uninstall scoop_ruby_20_to_25
Uninstalling 'scoop' (current).
Unlinking ~\scoop\apps\scoop\current
The directory is not empty.
'scoop' was uninstalled.
PS C:\Users\Jan> scoop
& : The term 'C:\Users\Jan\scoop\shims\..\apps\scoop\current\bin\scoop.ps1' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At C:\Users\Jan\scoop\shims\scoop.ps1:3 char:71
+ ... on.expectingInput) { $input | & $path  @args } else { & $path  @args  ...
+                                                             ~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\Jan\sc...t\bin\scoop.ps1:String) [], ParentContainsErrorRecord
   Exception
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Users\Jan>

So seems that scoop uninstalled itself.

Is something wrong with my manifest?
Is it a bad idea to name stuff beginning with scoop?
Or is this a bug with scoop?

Also, how can I uninstall the scoop_ruby_20_to_25 app now?

All 13 comments

Definitely bug. Haven't found cause yet.

There is strange behaviour with underscores overall.

Should be OK when you install using dashes (scoop-ruby...)

OK

Hm, what is the best way to get rid of the app anyway? Just delete the folder in scoop/apps?

I also tried other routes to deinstall the app, which maybe shows another possible problem:

PS C:\Users\Jan> scoop uninstall https://gist.githubusercontent.com/janpio/40e014d0ae31215b4bab2b5bbe5a69e8/raw/3500373c9484ca8c3c89aac4998cda333451a555/scoop_ruby_20_to_25.json
ERROR 'https' isn't installed.

I wouldn't have expected this to be cut to https as well.

Congrats! You found a bug of Scoop! 馃啋 The problem is the parse_app() function in core.ps1 returns scoop as the app name when you pass the app name which contains underscore, scoop_ruby_20_to_25.

$ 'scoop_ruby_20_to_25' -match '(?:(?<bucket>[a-zA-Z0-9-]+)\/)?(?<app>.*.json$|[a-zA-Z0-9-.]+)(?:@(?<version>.*))?'
True
$ $matches['app'], $matches['bucket'], $matches['version']
scoop

To fix this, or to say support app name that contains underscore, just add underscore into the regex.

$ 'scoop_ruby_20_to_25' -match '(?:(?<bucket>[a-zA-Z0-9-]+)\/)?(?<app>.*.json$|[a-zA-Z0-9-_.]+)(?:@(?<version>.*))?'
True
$ $matches['app'], $matches['bucket'], $matches['version']
scoop_ruby_20_to_25

I have provided the details about the issue, now you can open a pull request to contribute to scoop and become a contributor! 馃槃

I updated the title of the issue to reflect that new knowledge.

I could get rid of the app by renaming the folder scoop_ruby_20_to_25 in C:\Users\Jan\scoop\apps to ruby20to25 and then running scoop uninstall ruby20to25.

Did as you said @h404bi: #3129

I would also suggest adding an additional check to scoop-uninstall.ps1, just in case something diffrent happens. 馃榿

https://github.com/lukesampson/scoop/blob/bd5918f7e69272a8411cf2b0bfe8ff50447c56fe/libexec/scoop-uninstall.ps1#L39-L43

After ($app, $global) = $_

    if($app -eq 'scoop') {
        # Skip uninstalling scoop
        continue
    }

Safe nets / guards are never enough 馃槀

Well, I though it was kind of impressive that I could use scoop to uninstall scoop...

That's normal feature. When you write scoop uninstall scoop all apps will be uninstalled and then scoop will be deleted too.

2781, https://github.com/lukesampson/scoop/wiki/Uninstalling-Scoop

Oh ok, so just the "unintentional" uninstall is unwanted, especially without any additional check. At least it didn't also uninstall all the other apps.

Add tests, check from https://github.com/lukesampson/scoop/issues/3128#issuecomment-463672334 and it should never happened. This use case should not be reproducible in any state.

It could solve even #2666, #2370

Was this page helpful?
0 / 5 - 0 ratings

Related issues

klauern picture klauern  路  3Comments

muhlpachr picture muhlpachr  路  3Comments

eBaeza picture eBaeza  路  3Comments

ShivanshuKantPrasad picture ShivanshuKantPrasad  路  3Comments

nitrocode picture nitrocode  路  3Comments