Skip to content

.ckan install bug workaround for issue #2652 is functional but CKAN doesn't properly update its own state #2676

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

Closed
Jacke4913 opened this issue Jan 31, 2019 · 7 comments
Labels
Bug Something is not working as intended GUI Issues affecting the interactive GUI

Comments

@Jacke4913
Copy link

Jacke4913 commented Jan 31, 2019

Background

CKAN Version:
CKAN v1.25.4

KSP Version:
KSP v1.6.1

Operating System:
Windows 10 1803 Home

Have you made any manual changes to your GameData folder (i.e., not via CKAN)?
Unknown

Problem

What steps did you take in CKAN?

This CKAN issue:

#2652

Currently, a .ckan generated with a list of mods installed with "File > Export installed mods...", when used to recreate the install in an unmodded one with "File > Install from .ckan..." and selecting the .ckan, only installs some of the mods listed in the .ckan.

A workaround was given in the CKAN KSP forum topic here.

https://forum.kerbalspaceprogram.com/index.php?/topic/154922-ckan-the-comprehensive-kerbal-archive-network-v1254-kennedy/&page=62&tab=comments#comment-3521257

It advised editting the .ckan to change the "recommends" to "depends"

When this is done, the mods listed in the .ckan are installed but then CKAN appears to not update its state that it just installed those mods. It still thinks it doesn't have any mods installed. It then detects all the directories in GameData and labels the mods as "AD" (autodetected?), as not installed by CKAN but by other means. There appears to be no way to fix CKAN's state except by manually removing all the mods, then using the CKAN main window to install the mods.

Reproduction steps

  1. Created a list of mods installed with "Export installed mods...". 
  2. Editted the created .ckan and changed "recommends" to "depends".
  3. On an unmodded install, using "Install from .ckan...", selected the editted .ckan. 

What did you expect to happen?

Install the mods in the exported list normally

What happened instead?

All the mods listed in the .ckan are installed. Howevere, it appears CKAN forgets it installed all those mods. Afterwards, detects all installed mods as "AD" (autodetected?) which means it thinks the mods were not installed by CKAN. Refreshed and restarted CKAN client but they still show up as "AD".

An alternate workaround would be to look at the internal listing of mods in the .ckan and use the CKAN main window to install the listed mods.

Screenshots:

CKAN error codes (if applicable):

System.NullReferenceException: Object reference not set to an instance of an object.
   at CKAN.Main.UpdateChangesDialog(List`1 changeset, BackgroundWorker installWorker)
   at CKAN.Main.PostInstallMods(Object sender, RunWorkerCompletedEventArgs e)
   at System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(RunWorkerCompletedEventArgs e)
System.NullReferenceException: Object reference not set to an instance of an object.
   at CKAN.Main.UpdateChangesDialog(List`1 changeset, BackgroundWorker installWorker)
   at CKAN.Main.ChangeSetUpdated()
   at CKAN.Main.set_ChangeSet(IEnumerable`1 value)
   at CKAN.Main.<UpdateChangeSetAndConflicts>d__61.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at CKAN.Main.<ModList_CellValueChanged>d__264.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
@HebaruSan
Copy link
Member

Please share your .ckan file. We tested this already and it worked fine, so we need to know what's different in your case.

@HebaruSan HebaruSan added the Needs more info We need more info label Jan 31, 2019
@Jacke4913
Copy link
Author

Attaching the .ckan with "recommends" and "depends" (with added ".txt" to file names), as well as two details for crashes I had.

Tried recreating the issue several times in KSP installs with new empty CKAN setup and only came close once. On one install with "depends" in the troubleshooting sequence below, had CKAN say had 19 mods installed but when filtered to show installed, all the 19 checkboxes were empty. However, it didn't happen the same way and upon relaunch CKAN appeared to be in a good state.

It appears to be a rare error caused by a state I couldn't recreate. I tried several variations with the changes I do to compatible KSP versions and adding the MechJeb2-dev repository. Didn't get the issue and several times the "depends" .ckan succeeded.


Troubleshooting I did.

To be thorough, I created a CKAN-cleared KSP install by:

  1. Removing all mods in CKAN
  2. Forgetting the install in CKAN
  3. In the KSP install, cleared GameData leaving only Squad
  4. In the KSP install, deleted CKAN
  5. Closed CKAN client
  6. Launched CKAN client
  7. Added the KSP install to CKAN
  8. Selected the KSP install
  9. Set compatible KSP versions to include 1.6, 1.5, and 1.4.
  10. Refreshed the repositories

Tried it on the original .ckan with "recommends".
Wanted to install 5 of the 19 mods in the .ckan:
Portrait Stats
Toolbar Controller
KEI
Sensible Screenshots
Dated Quicksaves

Cancelled that, got unhandled exception.
Details saved in 20190131a.CKAN_crash_text.txt (included).

Closed the client and relaunched it.

Tried to install the .ckan with "depends".
Appears to install all 19 mods.

Check KSP install GameData directory. 18 directories and ModuleManager.4.0.1.dll added.

In CKAN, 19 mods listed as installed.

Started to remove all mods with CKAN. On clicking on 1st check box, CKAN crashed.
Details saved in 20190131b.CKAN_crash_text.txt (included).

Closed the client and relaunched it.

Successfully removed all mods with CKAN.

Added MechJeb2-dEV repository.

Refreshed the repositories.

Tried to install the .ckan with "depends".
Appears to install all 19 mods.
CKAN says 19 mods all installed.
CKAN client shows greyed-out Apply changes icon.
When Filter set to installed, shows 19 mods with boxes unchecked.
If I add checkmark to one mod, Apply changes icon now lit.
Upon clicking Apply changes, shows CKAN wanting to remove the other 18 mods.
Cancel Apply, uncheck box, close CKAN client.

Relaunched CKAN. Shows 19 mods installed.

At this point, I tried several times with a clean empty CKAN setup to recreate the original issue and even just the blank checkbox issues and failed.

20190131a.CKAN_crash_text.txt
20190131b.CKAN_crash_text.txt
20190128a.161.min-Sci-recce.depends.ckan.txt
20190128a.161.min-Sci-recce.recommends.ckan.txt

@HebaruSan HebaruSan added Bug Something is not working as intended GUI Issues affecting the interactive GUI and removed Needs more info We need more info labels Feb 1, 2019
@HebaruSan
Copy link
Member

HebaruSan commented Feb 4, 2019

Finally having a chance to look into this...

On the first reported crash flow, I don't get an unhandled exception when cancelling the "recommends" import with current master HEAD. So hopefully that's fixed already, maybe in #2653 or #2602. (It also lists all 19 mods because #2652 is fixed, so I might also try this with an older client to make sure.)

For the second problem, after installing successfully via the "depends" import, I can uncheck and uninstall the mods without exceptions.

For the third problem, after installing successfully via the "depends" import, switching to the installed filter does not uncheck the boxes.

(And at no point did anything revert to AD status.)

To sum up, everything seems fine. I'm on Linux for what that's worth, so maybe I should try this in Windows.

@Jacke4913 , can you try the latest bleeding edge download and see if you still have these problems?

@HebaruSan
Copy link
Member

Inspecting the stack traces in context does produce a hypothesis. This line might throw an NRE:

: $"{m.name} {m.version} ({m.download.Host ?? ""}, {CkanModule.FmtSize(m.download_size)})",

... if m.download is null, which would be the case for the metapackage representing the imported .ckan file. And cancelling out of the import leaves behind a mod list row for the metapackage, which can be toggled for installation, which triggers the above line. I think that accounts for the second exception in the OP. So we need to consider how to handle metapackages.

@Jacke4913
Copy link
Author

I've done a few loads of depends .ckan's over the last weekend with the current v1.25.4 and at no time did I get the bug. It must be rare or depend on starting in a rare state. The no-mod initial state may even be needed. I've downloaded version 1.25.5 dated 20190201.0208 you linked above and will use it and report back.

@Jacke4913
Copy link
Author

I'm going to be switching back to the v1.25.4 client. The new client is mostly functional, had some crashes I didn't capture the error log from. But now I'm trying to update it with 2 updates pending and every time I click on one of the update checkboxes, I get an error. And it never enables Apply changes.

Here's one sequence of 3 crashes from one of those update attempts. Got a sequence of 3 errors before the program was terminated, with the 3rd error in a different error reporting window.

20190204a.CKAN_crash.txt
20190204b.CKAN_crash.txt
20190204c.CKAN_crash.txt

And going back to v1.25.4, I could update successfully.

@HebaruSan
Copy link
Member

Extracted from those files:

System.Exception: Should never be called on Installed
   at CKAN.SelectionReason.Installed.get_Parent()
   at CKAN.Main.CreateSortedModList(IEnumerable`1 changes, ModChange parent)
   at CKAN.Main.CreateSortedModList(IEnumerable`1 changes, ModChange parent)
   at CKAN.Main.UpdateChangesDialog(List`1 changeset, BackgroundWorker installWorker)
   at CKAN.Main.ChangeSetUpdated()
   at CKAN.Main.set_ChangeSet(IEnumerable`1 value)
   at CKAN.Main.<UpdateChangeSetAndConflicts>d__61.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at CKAN.Main.<ModList_CellValueChanged>d__270.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext()
   at System.Windows.Forms.Application.ExitInternal()
   at System.Windows.Forms.Application.ThreadContext.OnThreadException(Exception t)
   at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext()
   at System.Windows.Forms.Application.ExitInternal()
   at System.Windows.Forms.Application.ThreadContext.OnThreadException(Exception t)
   at System.Windows.Forms.Control.WndProcException(Exception e)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at CKAN.Main..ctor(String[] cmdlineArgs, KSPManager mgr, GUIUser user, Boolean showConsole)
   at CKAN.GUI.Main_(String[] args, KSPManager manager, Boolean showConsole)
   at CKAN.CmdLine.MainClass.RunSimpleAction(Options cmdline, CommonOptions options, String[] args, IUser user, KSPManager manager)
   at CKAN.CmdLine.MainClass.Execute(KSPManager manager, CommonOptions opts, String[] args)
   at CKAN.CmdLine.MainClass.Main(String[] args) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended GUI Issues affecting the interactive GUI
Projects
None yet
Development

No branches or pull requests

2 participants