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

Not enough space in game folder to install modules on Mac #3768

Closed
DougStoker opened this issue Jan 30, 2023 · 3 comments · Fixed by #3850
Closed

Not enough space in game folder to install modules on Mac #3768

DougStoker opened this issue Jan 30, 2023 · 3 comments · Fixed by #3850
Labels
Bug Something is not working as intended Core (ckan.dll) Issues affecting the core part of CKAN macOS Issues specific for macOS

Comments

@DougStoker
Copy link

DougStoker commented Jan 30, 2023

Background

  • Operating System: macos catalina
  • CKAN Version: 1.31.2
  • KSP Version: 1.12.5

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

Problem

Describe the bug
crash when download mod

Screen Shot 2023-01-29 at 5 55 09 PM

Steps to reproduce

  • Go to...
  • Click on...
  • See error

Expected behavior

Screenshots (if applicable)

CKAN error code (if applicable):

Unhandled Exception:                                                          │
CKAN.NotEnoughSpaceKraken: Not enough space in game folder to install modules!┘
Need to store 2.3 MiB to /Applications/ksp_osx, but only 0 B is available!     
Free up space on that device or change your settings to use another location.

  at CKAN.CKANPathUtils.CheckFreeSpace (System.IO.DirectoryInfo where, System.Int64 bytesToStore, System.String errorDescription) [0x00042] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ModuleInstaller.InstallList (System.Collections.Generic.ICollection`1[T] modules, CKAN.RelationshipResolverOptions options, CKAN.RegistryManager registry_manager, System.Collections.Generic.HashSet`1[System.String]& possibleConfigOnlyDirs, CKAN.IDownloader downloader, System.Boolean ConfirmPrompt) [0x00086] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ConsoleUI.InstallScreen.Run (CKAN.ConsoleUI.Toolkit.ConsoleTheme theme, System.Action`1[T] process) [0x00125] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ConsoleUI.Toolkit.ConsoleScreen.LaunchSubScreen (CKAN.ConsoleUI.Toolkit.ConsoleTheme theme, CKAN.ConsoleUI.Toolkit.ConsoleScreen cs, System.Action`1[T] newProc) [0x00000] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ConsoleUI.ModListScreen.ApplyChanges (CKAN.ConsoleUI.Toolkit.ConsoleTheme theme) [0x00019] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ConsoleUI.ModListScreen.<.ctor>b__0_26 (System.Object sender, CKAN.ConsoleUI.Toolkit.ConsoleTheme theme) [0x00000] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ConsoleUI.Toolkit.ScreenContainer.Interact (CKAN.ConsoleUI.Toolkit.ConsoleTheme theme) [0x00038] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ConsoleUI.Toolkit.ScreenContainer.Run (CKAN.ConsoleUI.Toolkit.ConsoleTheme theme, System.Action`1[T] process) [0x00021] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ConsoleUI.ConsoleCKAN..ctor (CKAN.GameInstanceManager mgr, System.String themeName, System.Boolean debug) [0x00089] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ConsoleUI.ConsoleUI.Main_ (System.String[] args, CKAN.GameInstanceManager manager, System.String themeName, System.Boolean debug) [0x00005] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.CmdLine.MainClass.ConsoleUi (CKAN.GameInstanceManager manager, CKAN.CmdLine.ConsoleUIOptions opts, System.String[] args) [0x00034] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.CmdLine.MainClass.RunSimpleAction (CKAN.CmdLine.Options cmdline, CKAN.CmdLine.CommonOptions options, System.String[] args, CKAN.IUser user, CKAN.GameInstanceManager manager) [0x002df] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.CmdLine.MainClass.Execute (CKAN.GameInstanceManager manager, CKAN.CmdLine.CommonOptions opts, System.String[] args) [0x00296] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.CmdLine.MainClass.Main (System.String[] args) [0x000e9] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: CKAN.NotEnoughSpaceKraken: Not enough space in game folder to install modules!
Need to store 2.3 MiB to /Applications/ksp_osx, but only 0 B is available!
Free up space on that device or change your settings to use another location.

  at CKAN.CKANPathUtils.CheckFreeSpace (System.IO.DirectoryInfo where, System.Int64 bytesToStore, System.String errorDescription) [0x00042] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ModuleInstaller.InstallList (System.Collections.Generic.ICollection`1[T] modules, CKAN.RelationshipResolverOptions options, CKAN.RegistryManager registry_manager, System.Collections.Generic.HashSet`1[System.String]& possibleConfigOnlyDirs, CKAN.IDownloader downloader, System.Boolean ConfirmPrompt) [0x00086] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ConsoleUI.InstallScreen.Run (CKAN.ConsoleUI.Toolkit.ConsoleTheme theme, System.Action`1[T] process) [0x00125] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ConsoleUI.Toolkit.ConsoleScreen.LaunchSubScreen (CKAN.ConsoleUI.Toolkit.ConsoleTheme theme, CKAN.ConsoleUI.Toolkit.ConsoleScreen cs, System.Action`1[T] newProc) [0x00000] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ConsoleUI.ModListScreen.ApplyChanges (CKAN.ConsoleUI.Toolkit.ConsoleTheme theme) [0x00019] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ConsoleUI.ModListScreen.<.ctor>b__0_26 (System.Object sender, CKAN.ConsoleUI.Toolkit.ConsoleTheme theme) [0x00000] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ConsoleUI.Toolkit.ScreenContainer.Interact (CKAN.ConsoleUI.Toolkit.ConsoleTheme theme) [0x00038] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ConsoleUI.Toolkit.ScreenContainer.Run (CKAN.ConsoleUI.Toolkit.ConsoleTheme theme, System.Action`1[T] process) [0x00021] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ConsoleUI.ConsoleCKAN..ctor (CKAN.GameInstanceManager mgr, System.String themeName, System.Boolean debug) [0x00089] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.ConsoleUI.ConsoleUI.Main_ (System.String[] args, CKAN.GameInstanceManager manager, System.String themeName, System.Boolean debug) [0x00005] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.CmdLine.MainClass.ConsoleUi (CKAN.GameInstanceManager manager, CKAN.CmdLine.ConsoleUIOptions opts, System.String[] args) [0x00034] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.CmdLine.MainClass.RunSimpleAction (CKAN.CmdLine.Options cmdline, CKAN.CmdLine.CommonOptions options, System.String[] args, CKAN.IUser user, CKAN.GameInstanceManager manager) [0x002df] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.CmdLine.MainClass.Execute (CKAN.GameInstanceManager manager, CKAN.CmdLine.CommonOptions opts, System.String[] args) [0x00296] in <79ae9046bd9c43dabfd2f7be4b883034>:0 
  at CKAN.CmdLine.MainClass.Main (System.String[] args) [0x000e9] in <79ae9046bd9c43dabfd2f7be4b883034>:0
@HebaruSan HebaruSan added macOS Issues specific for macOS Support Issues that are support requests labels Jan 30, 2023
@HebaruSan HebaruSan changed the title [Bug] ckan confused about disk space left Not enough space in game folder to install modules on Mac Feb 20, 2023
@rob5408
Copy link

rob5408 commented Feb 25, 2023

Same, except I have 110GB free. I tried changing DownloadCacheDir to a different location and changed CacheSizeLimit to a a very very large number and it still failed.

@HebaruSan
Copy link
Member

HebaruSan commented Feb 25, 2023

Here's the logic we use for checking free space, in case either of you wants to audit it for things that wouldn't work on a Mac:

CKAN/Core/CKANPathUtils.cs

Lines 200 to 212 in 04034c0

public static void CheckFreeSpace(DirectoryInfo where, long bytesToStore, string errorDescription)
{
var bytesFree = where.GetDrive()?.AvailableFreeSpace;
if (bytesFree.HasValue && bytesToStore > bytesFree.Value) {
throw new NotEnoughSpaceKraken(errorDescription, where,
bytesFree.Value, bytesToStore);
}
log.DebugFormat("Storing {0} to {1} ({2} free)...",
CkanModule.FmtSize(bytesToStore),
where.FullName,
bytesFree.HasValue ? CkanModule.FmtSize(bytesFree.Value)
: "unknown bytes");
}

private static bool StringArrayStartsWith(string[] child, string[] parent)
{
if (parent.Length > child.Length)
{
// Only child is allowed to have extra pieces
return false;
}
var opt = Platform.IsWindows ? StringComparison.InvariantCultureIgnoreCase
: StringComparison.InvariantCulture;
for (int i = 0; i < parent.Length; ++i)
{
if (!parent[i].Equals(child[i], opt))
{
return false;
}
}
return true;
}
/// <summary>
/// Check whether a given path is an ancestor of another
/// </summary>
/// <param name="parent">The path to treat as potential ancestor</param>
/// <param name="child">The path to treat as potential descendant</param>
/// <returns>true if child is a descendant of parent, false otherwise</returns>
public static bool IsAncestorOf(this DirectoryInfo parent, DirectoryInfo child)
=> StringArrayStartsWith(
child.FullName.Split(new char[] {Path.DirectorySeparatorChar},
StringSplitOptions.RemoveEmptyEntries),
parent.FullName.Split(new char[] {Path.DirectorySeparatorChar},
StringSplitOptions.RemoveEmptyEntries));
/// <summary>
/// Extension method to fill in the gap of getting from a
/// directory to its drive in .NET.
/// Returns the drive with the longest RootDirectory.FullName
/// that's a prefix of the dir's FullName.
/// </summary>
/// <param name="dir">Any DirectoryInfo object</param>
/// <returns>The DriveInfo associated with this directory</returns>
public static DriveInfo GetDrive(this DirectoryInfo dir)
=> DriveInfo.GetDrives()
.Where(dr => dr.RootDirectory.IsAncestorOf(dir))
.OrderByDescending(dr => dr.RootDirectory.FullName.Length)
.FirstOrDefault();

At a guess, maybe GetDrives() doesn't work?

@HebaruSan HebaruSan added Bug Something is not working as intended Core (ckan.dll) Issues affecting the core part of CKAN and removed Support Issues that are support requests labels Feb 25, 2023
@rob5408
Copy link

rob5408 commented Feb 25, 2023

Yeah my guess too, I'm trying to ./build osx on my Mac but getting errors (I've been writing up an issue for that here). I got two hours into debugging it last night and realized I was basically just doing my day job instead of playing KSP so I took a break, ha.

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 Core (ckan.dll) Issues affecting the core part of CKAN macOS Issues specific for macOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants