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

Group Main was not found when calling Dependencies.Remove for last dependency #1950

Closed
mrward opened this Issue Oct 8, 2016 · 4 comments

Comments

Projects
None yet
2 participants
@mrward

mrward commented Oct 8, 2016

Description

Programmatically removing the last NuGet package from a paket.dependencies file, using Dependencies.Remove, throws an 'Group Main was not found' exception.

Paket version: 3.21.4

Repro steps

  1. Create a paket.dependencies file containing a single NuGet package:

    source https://www.nuget.org/api/v2
    nuget NUnit

  2. Install the NUnit NuGet package using paket install

3, Then programatically remove the NUnit NuGet package using code similar to the following C# code:

Dependencies
    .Locate (dependenciesFileName)
    .Remove (packageId);

Expected behavior

The NuGet package is removed from the paket.dependencies file without any exception.

Actual behavior

The NuGet package is removed from the paket.dependencies file but an exception is thrown.

Removing NUnit from d:\temp\test\paket.dependencies (group Main)
Dependencies files saved to d:\temp\test\paket.dependencies
Group Main was not found in d:\temp\test\paket.dependencies.

System.Exception: Group Main was not found in d:\temp\test\paket.dependencies.
   at <StartupCode$Paket-Core>.$DependenciesFile.GetGroup@160-3.Invoke(String message)
   at Paket.UpdateProcess.preferredVersions@116-1.Invoke(Tuple`2 tupledArg)
   at Microsoft.FSharp.Collections.MapTreeModule.mapiOpt[a,b,c](FSharpFunc`3 f, MapTree`2 m)
   at Microsoft.FSharp.Collections.FSharpMap`2.Map[b](FSharpFunc`2 f)
   at Microsoft.FSharp.Collections.MapModule.Map[TKey,T,TResult](FSharpFunc`2 mapping, FSharpMap`2 table)
   at Paket.UpdateProcess.selectiveUpdate(Boolean force, FSharpFunc`2 getSha1, FSharpFunc`2 getSortedVersionsF, FSharpFunc`2 getPackageDetailsF, LockFile lockFile, DependenciesFile dependenciesFile, UpdateMode updateMode, SemVerUpdateMode semVerUpdateMode)
   at Paket.UpdateProcess.SelectiveUpdate(DependenciesFile dependenciesFile, UpdateMode updateMode, SemVerUpdateMode semVerUpdateMode, Boolean force)
   at Paket.RemoveProcess.remove(FSharpFunc`2 removeFromProjects, String dependenciesFileName, GroupName groupName, PackageName package, Boolean force, Boolean installAfter)
   at Paket.RemoveProcess.Remove(String dependenciesFileName, FSharpOption`1 groupName, PackageName packageName, Boolean force, Boolean interactive, Boolean installAfter)
   at <StartupCode$Paket-Core>.$PublicAPI.Remove@444-9.Invoke(Unit unitVar0)
   at Paket.Utils.RunInLockedAccessMode[a](String rootFolder, FSharpFunc`2 action)
   at Paket.Dependencies.Remove(FSharpOption`1 groupName, String package, Boolean force, Boolean interactive, Boolean installAfter)
   at Paket.Dependencies.Remove(FSharpOption`1 groupName, String package)

Known workarounds

If the paket.dependencies file has two NuGet packages (e.g. NUnit and jQuery) then removing the NUnit package works without any exception being thrown.

Removing NUnit from d:\temp\test\paket.dependencies (group Main)
Dependencies files saved to d:\temp\test\paket.dependencies
Resolving packages for group Main:
 - jQuery 3.1.1
Locked version resolution written to d:\temp\test\paket.lock
Garbage collecting NUnit
@mrward

This comment has been minimized.

Show comment
Hide comment
@mrward

mrward Oct 9, 2016

I get the same behaviour if I try to remove the last NuGet dependency using paket.exe remove nuget nunit from the command line:

paket.exe remove nuget nunit --verbose
Paket version 3.21.4.0
found: D:\temp\test\paket.dependencies
Parsing D:\temp\test\paket.dependencies
Removing nunit from D:\temp\test\paket.dependencies (group Main)
Dependencies files saved to D:\temp\test\paket.dependencies
Paket failed with:
        Group Main was not found in D:\temp\test\paket.dependencies.
StackTrace:
     at <StartupCode$Paket-Core>.$DependenciesFile.GetGroup@160-3.Invoke(Stringmessage)
   at Paket.UpdateProcess.preferredVersions@116-1.Invoke(Tuple`2 tupledArg)
   at Microsoft.FSharp.Collections.MapTreeModule.mapiOpt[a,b,c](FSharpFunc`3 f,MapTree`2 m)
   at Microsoft.FSharp.Collections.FSharpMap`2.Map[b](FSharpFunc`2 f)
   at Paket.UpdateProcess.selectiveUpdate(Boolean force, FSharpFunc`2 getSha1, FSharpFunc`2 getSortedVersionsF, FSharpFunc`2 getPackageDetailsF, LockFile lockFile, DependenciesFile dependenciesFile, UpdateMode updateMode, SemVerUpdateMode semVerUpdateMode)
   at Paket.UpdateProcess.SelectiveUpdate(DependenciesFile dependenciesFile, UpdateMode updateMode, SemVerUpdateMode semVerUpdateMode, Boolean force)
   at Paket.RemoveProcess.remove(FSharpFunc`2 removeFromProjects, String dependenciesFileName, GroupName groupName, PackageName package, Boolean force, BooleaninstallAfter)
   at <StartupCode$Paket-Core>.$PublicAPI.Remove@444-9.Invoke(Unit unitVar0)
   at Paket.Utils.RunInLockedAccessMode[a](String rootFolder, FSharpFunc`2 action)
   at Paket.Program.main@395-12.Invoke(ParseResults`1 results)
   at Paket.Program.processWithValidation[T](Boolean silent, FSharpFunc`2 validateF, FSharpFunc`2 commandF, ParseResults`1 result)
   at Paket.Program.main$cont@380(ParseResults`1 results, Boolean silent, Unit unitVar)
   at Paket.Program.main()

mrward commented Oct 9, 2016

I get the same behaviour if I try to remove the last NuGet dependency using paket.exe remove nuget nunit from the command line:

paket.exe remove nuget nunit --verbose
Paket version 3.21.4.0
found: D:\temp\test\paket.dependencies
Parsing D:\temp\test\paket.dependencies
Removing nunit from D:\temp\test\paket.dependencies (group Main)
Dependencies files saved to D:\temp\test\paket.dependencies
Paket failed with:
        Group Main was not found in D:\temp\test\paket.dependencies.
StackTrace:
     at <StartupCode$Paket-Core>.$DependenciesFile.GetGroup@160-3.Invoke(Stringmessage)
   at Paket.UpdateProcess.preferredVersions@116-1.Invoke(Tuple`2 tupledArg)
   at Microsoft.FSharp.Collections.MapTreeModule.mapiOpt[a,b,c](FSharpFunc`3 f,MapTree`2 m)
   at Microsoft.FSharp.Collections.FSharpMap`2.Map[b](FSharpFunc`2 f)
   at Paket.UpdateProcess.selectiveUpdate(Boolean force, FSharpFunc`2 getSha1, FSharpFunc`2 getSortedVersionsF, FSharpFunc`2 getPackageDetailsF, LockFile lockFile, DependenciesFile dependenciesFile, UpdateMode updateMode, SemVerUpdateMode semVerUpdateMode)
   at Paket.UpdateProcess.SelectiveUpdate(DependenciesFile dependenciesFile, UpdateMode updateMode, SemVerUpdateMode semVerUpdateMode, Boolean force)
   at Paket.RemoveProcess.remove(FSharpFunc`2 removeFromProjects, String dependenciesFileName, GroupName groupName, PackageName package, Boolean force, BooleaninstallAfter)
   at <StartupCode$Paket-Core>.$PublicAPI.Remove@444-9.Invoke(Unit unitVar0)
   at Paket.Utils.RunInLockedAccessMode[a](String rootFolder, FSharpFunc`2 action)
   at Paket.Program.main@395-12.Invoke(ParseResults`1 results)
   at Paket.Program.processWithValidation[T](Boolean silent, FSharpFunc`2 validateF, FSharpFunc`2 commandF, ParseResults`1 result)
   at Paket.Program.main$cont@380(ParseResults`1 results, Boolean silent, Unit unitVar)
   at Paket.Program.main()

mrward added a commit to mrward/monodevelop-paket-addin that referenced this issue Oct 15, 2016

Refresh UI and files after failing to remove last NuGet package
Paket currently throws an error when removing the last NuGet package:

Group Main was not found in paket.dependencies.

fsprojects/Paket#1950

This left the UI and files still showing the original information even
though Paket does remove the NuGet package from the dependencies and
references files. So now the addin still notifies that these files
have changed when there was an error removing a NuGet package. This
ensures the Solution window is updated with the correct information
and the files are reloaded if they are open in the text editor.
@forki

This comment has been minimized.

Show comment
Hide comment
@forki

forki Oct 29, 2016

Member

Should be fixed in latest version. Can you please retry?

Member

forki commented Oct 29, 2016

Should be fixed in latest version. Can you please retry?

@forki forki closed this Oct 29, 2016

@mrward

This comment has been minimized.

Show comment
Hide comment
@mrward

mrward Oct 29, 2016

I am still seeing the same error with Paket 3.25.2.0

paket.exe remove nuget nunit --verbose
Paket version 3.25.2.0
found: D:\temp\test\paket.dependencies
Removing Package nunit from D:\temp\test\paket.references
References file saved to D:\temp\test\paket.references
Parsing D:\temp\test\paket.dependencies
Removing nunit from D:\temp\test\paket.dependencies
(group Main)
Dependencies files saved to D:\temp\test\paket.dependencies
Paket failed with:
        Group Main was not found in D:\temp\test\paket.dependencies.
StackTrace:
     at <StartupCode$Paket-Core>.$DependenciesFile.GetGroup@160-3.Invoke(Stringmessage)
   at Paket.UpdateProcess.preferredVersions@116-1.Invoke(Tuple`2 tupledArg)
   at Microsoft.FSharp.Collections.MapTreeModule.mapiOpt[a,b,c](FSharpFunc`3 f,MapTree`2 m)
   at Microsoft.FSharp.Collections.FSharpMap`2.Map[b](FSharpFunc`2 f)
   at Paket.UpdateProcess.selectiveUpdate(Boolean force, FSharpFunc`2 getSha1, FSharpFunc`2 getSortedVersionsF, FSharpFunc`2 getPackageDetailsF, LockFile lockFile, DependenciesFile dependenciesFile, UpdateMode updateMode, SemVerUpdateMode semVerUpdateMode)
   at Paket.UpdateProcess.SelectiveUpdate(DependenciesFile dependenciesFile, UpdateMode updateMode, SemVerUpdateMode semVerUpdateMode, Boolean force)
   at Paket.RemoveProcess.remove(FSharpFunc`2 removeFromProjects, String dependenciesFileName, GroupName groupName, PackageName package, Boolean force, BooleaninstallAfter)
   at <StartupCode$Paket-Core>.$PublicAPI.Remove@454-9.Invoke(Unit unitVar0)
   at Paket.Utils.RunInLockedAccessMode[a](String rootFolder, FSharpFunc`2 action)
   at Paket.Program.main@397-12.Invoke(ParseResults`1 results)
   at Paket.Program.processWithValidation[T](Boolean silent, FSharpFunc`2 validateF, FSharpFunc`2 commandF, ParseResults`1 result)
   at Paket.Program.main$cont@382(ParseResults`1 results, Boolean silent, Boolean fromBootstrapper, Unit unitVar)
   at Paket.Program.main()

mrward commented Oct 29, 2016

I am still seeing the same error with Paket 3.25.2.0

paket.exe remove nuget nunit --verbose
Paket version 3.25.2.0
found: D:\temp\test\paket.dependencies
Removing Package nunit from D:\temp\test\paket.references
References file saved to D:\temp\test\paket.references
Parsing D:\temp\test\paket.dependencies
Removing nunit from D:\temp\test\paket.dependencies
(group Main)
Dependencies files saved to D:\temp\test\paket.dependencies
Paket failed with:
        Group Main was not found in D:\temp\test\paket.dependencies.
StackTrace:
     at <StartupCode$Paket-Core>.$DependenciesFile.GetGroup@160-3.Invoke(Stringmessage)
   at Paket.UpdateProcess.preferredVersions@116-1.Invoke(Tuple`2 tupledArg)
   at Microsoft.FSharp.Collections.MapTreeModule.mapiOpt[a,b,c](FSharpFunc`3 f,MapTree`2 m)
   at Microsoft.FSharp.Collections.FSharpMap`2.Map[b](FSharpFunc`2 f)
   at Paket.UpdateProcess.selectiveUpdate(Boolean force, FSharpFunc`2 getSha1, FSharpFunc`2 getSortedVersionsF, FSharpFunc`2 getPackageDetailsF, LockFile lockFile, DependenciesFile dependenciesFile, UpdateMode updateMode, SemVerUpdateMode semVerUpdateMode)
   at Paket.UpdateProcess.SelectiveUpdate(DependenciesFile dependenciesFile, UpdateMode updateMode, SemVerUpdateMode semVerUpdateMode, Boolean force)
   at Paket.RemoveProcess.remove(FSharpFunc`2 removeFromProjects, String dependenciesFileName, GroupName groupName, PackageName package, Boolean force, BooleaninstallAfter)
   at <StartupCode$Paket-Core>.$PublicAPI.Remove@454-9.Invoke(Unit unitVar0)
   at Paket.Utils.RunInLockedAccessMode[a](String rootFolder, FSharpFunc`2 action)
   at Paket.Program.main@397-12.Invoke(ParseResults`1 results)
   at Paket.Program.processWithValidation[T](Boolean silent, FSharpFunc`2 validateF, FSharpFunc`2 commandF, ParseResults`1 result)
   at Paket.Program.main$cont@382(ParseResults`1 results, Boolean silent, Boolean fromBootstrapper, Unit unitVar)
   at Paket.Program.main()
@forki

This comment has been minimized.

Show comment
Hide comment
@forki

forki Oct 29, 2016

Member

Shit thought another thing fixed it as well. Will take another look next
week

Am 29.10.2016 14:46 schrieb "Matt Ward" notifications@github.com:

I am still seeing the same error with Paket 3.25.2.0

paket.exe remove nuget nunit --verbose
Paket version 3.25.2.0
found: D:\temp\test\paket.dependencies
Removing Package nunit from D:\temp\test\paket.references
References file saved to D:\temp\test\paket.references
Parsing D:\temp\test\paket.dependencies
Removing nunit from D:\temp\test\paket.dependencies
(group Main)
Dependencies files saved to D:\temp\test\paket.dependencies
Paket failed with:
Group Main was not found in D:\temp\test\paket.dependencies.
StackTrace:
at <StartupCode$Paket-Core>.$DependenciesFile.GetGroup@160-3.Invoke(Stringmessage)
at Paket.UpdateProcess.preferredVersions@116-1.Invoke(Tuple2 tupledArg) at Microsoft.FSharp.Collections.MapTreeModule.mapiOpt[a,b,c](FSharpFunc3 f,MapTree2 m) at Microsoft.FSharp.Collections.FSharpMap2.Map[b](FSharpFunc2 f) at Paket.UpdateProcess.selectiveUpdate(Boolean force, FSharpFunc2 getSha1, FSharpFunc2 getSortedVersionsF, FSharpFunc2 getPackageDetailsF, LockFile lockFile, DependenciesFile dependenciesFile, UpdateMode updateMode, SemVerUpdateMode semVerUpdateMode)
at Paket.UpdateProcess.SelectiveUpdate(DependenciesFile dependenciesFile, UpdateMode updateMode, SemVerUpdateMode semVerUpdateMode, Boolean force)
at Paket.RemoveProcess.remove(FSharpFunc2 removeFromProjects, String dependenciesFileName, GroupName groupName, PackageName package, Boolean force, BooleaninstallAfter) at <StartupCode$Paket-Core>.$PublicAPI.Remove@454-9.Invoke(Unit unitVar0) at Paket.Utils.RunInLockedAccessMode[a](String rootFolder, FSharpFunc2 action)
at Paket.Program.main@397-12.Invoke(ParseResults1 results) at Paket.Program.processWithValidation[T](Boolean silent, FSharpFunc2 validateF, FSharpFunc2 commandF, ParseResults1 result)
at Paket.Program.main$cont@382(ParseResults`1 results, Boolean silent, Boolean fromBootstrapper, Unit unitVar)
at Paket.Program.main()


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#1950 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADgNJIkmCGZXwhKBSQ6e3kW1jxMn60Vks5q40AbgaJpZM4KRtVm
.

Member

forki commented Oct 29, 2016

Shit thought another thing fixed it as well. Will take another look next
week

Am 29.10.2016 14:46 schrieb "Matt Ward" notifications@github.com:

I am still seeing the same error with Paket 3.25.2.0

paket.exe remove nuget nunit --verbose
Paket version 3.25.2.0
found: D:\temp\test\paket.dependencies
Removing Package nunit from D:\temp\test\paket.references
References file saved to D:\temp\test\paket.references
Parsing D:\temp\test\paket.dependencies
Removing nunit from D:\temp\test\paket.dependencies
(group Main)
Dependencies files saved to D:\temp\test\paket.dependencies
Paket failed with:
Group Main was not found in D:\temp\test\paket.dependencies.
StackTrace:
at <StartupCode$Paket-Core>.$DependenciesFile.GetGroup@160-3.Invoke(Stringmessage)
at Paket.UpdateProcess.preferredVersions@116-1.Invoke(Tuple2 tupledArg) at Microsoft.FSharp.Collections.MapTreeModule.mapiOpt[a,b,c](FSharpFunc3 f,MapTree2 m) at Microsoft.FSharp.Collections.FSharpMap2.Map[b](FSharpFunc2 f) at Paket.UpdateProcess.selectiveUpdate(Boolean force, FSharpFunc2 getSha1, FSharpFunc2 getSortedVersionsF, FSharpFunc2 getPackageDetailsF, LockFile lockFile, DependenciesFile dependenciesFile, UpdateMode updateMode, SemVerUpdateMode semVerUpdateMode)
at Paket.UpdateProcess.SelectiveUpdate(DependenciesFile dependenciesFile, UpdateMode updateMode, SemVerUpdateMode semVerUpdateMode, Boolean force)
at Paket.RemoveProcess.remove(FSharpFunc2 removeFromProjects, String dependenciesFileName, GroupName groupName, PackageName package, Boolean force, BooleaninstallAfter) at <StartupCode$Paket-Core>.$PublicAPI.Remove@454-9.Invoke(Unit unitVar0) at Paket.Utils.RunInLockedAccessMode[a](String rootFolder, FSharpFunc2 action)
at Paket.Program.main@397-12.Invoke(ParseResults1 results) at Paket.Program.processWithValidation[T](Boolean silent, FSharpFunc2 validateF, FSharpFunc2 commandF, ParseResults1 result)
at Paket.Program.main$cont@382(ParseResults`1 results, Boolean silent, Boolean fromBootstrapper, Unit unitVar)
at Paket.Program.main()


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#1950 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADgNJIkmCGZXwhKBSQ6e3kW1jxMn60Vks5q40AbgaJpZM4KRtVm
.

forki added a commit that referenced this issue Oct 30, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment