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

Allow for Non Default/Unusual KSP Install Location #23

Closed
techman83 opened this issue Oct 4, 2014 · 12 comments
Closed

Allow for Non Default/Unusual KSP Install Location #23

techman83 opened this issue Oct 4, 2014 · 12 comments
Labels
Bug Something is not working as intended Enhancement New features or functionality

Comments

@techman83
Copy link
Member

I'm weird, but I'm probably not alone :) - I have installed KSP on my SSD, but most other steam games reside in my home folder which is spinning rust.

leon@beast:~/git/CKAN/CKAN/CKAN/bin/Debug$ mono CKAN.exe scan
Setting up CKAN for the first time...
Creating /home/leon/.steam/steam/SteamApps/common/Kerbal Space Program/CKAN
Scanning for installed mods...

Unhandled Exception:
System.IO.DirectoryNotFoundException: Directory '/home/leon/.steam/steam/SteamApps/common/Kerbal Space Program/GameData' not found.
  at System.IO.Directory.ValidateDirectoryListing (System.String path, System.String searchPattern, System.Boolean& stop) [0x00000] in <filename unknown>:0 
  at System.IO.Directory.GetFileSystemEntries (System.String path, System.String searchPattern, FileAttributes mask, FileAttributes attrs) [0x00000] in <filename unknown>:0 
  at System.IO.Directory.GetFiles (System.String path, System.String searchPattern) [0x00000] in <filename unknown>:0 
  at System.IO.Directory.GetFilesRecurse (System.String path, System.String searchPattern, System.Collections.Generic.List`1 all) [0x00000] in <filename unknown>:0 
  at System.IO.Directory.GetFiles (System.String path, System.String searchPattern, SearchOption searchOption) [0x00000] in <filename unknown>:0 
  at CKAN.KSP.scanGameData () [0x00000] in <filename unknown>:0 
  at CKAN.KSP.init () [0x00000] in <filename unknown>:0 
  at CKAN.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.DirectoryNotFoundException: Directory '/home/leon/.steam/steam/SteamApps/common/Kerbal Space Program/GameData' not found.
  at System.IO.Directory.ValidateDirectoryListing (System.String path, System.String searchPattern, System.Boolean& stop) [0x00000] in <filename unknown>:0 
  at System.IO.Directory.GetFileSystemEntries (System.String path, System.String searchPattern, FileAttributes mask, FileAttributes attrs) [0x00000] in <filename unknown>:0 
  at System.IO.Directory.GetFiles (System.String path, System.String searchPattern) [0x00000] in <filename unknown>:0 
  at System.IO.Directory.GetFilesRecurse (System.String path, System.String searchPattern, System.Collections.Generic.List`1 all) [0x00000] in <filename unknown>:0 
  at System.IO.Directory.GetFiles (System.String path, System.String searchPattern, SearchOption searchOption) [0x00000] in <filename unknown>:0 
  at CKAN.KSP.scanGameData () [0x00000] in <filename unknown>:0 
  at CKAN.KSP.init () [0x00000] in <filename unknown>:0 
  at CKAN.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 

A symlink makes things happy for now.

leon@beast:~/.cryptfast/git/CKAN/CKAN/CKAN/bin/Debug$ mono CKAN.exe scan
Setting up CKAN for the first time...
Creating /home/leon/.steam/steam/SteamApps/common/Kerbal Space Program/CKAN
Scanning for installed mods...
Creating /home/leon/.steam/steam/SteamApps/common/Kerbal Space Program/CKAN/downloads
@pjf
Copy link
Member

pjf commented Oct 4, 2014

Aye, right now the KSP directory is hard coded, which is going to be wrong for most people.

I think what we need is:

  • A better way to find the installed copy (steam/non-steam, linux, windows, mac)
  • A way for the user to specify their own path to KSP.

In both cases, we need a way of storing that. I wonder if C#/Mono provides a standardised way to access a system registry that we can place it into?

@pjf pjf added Bug Something is not working as intended Enhancement New features or functionality help wanted labels Oct 4, 2014
@sumghai
Copy link

sumghai commented Oct 4, 2014

I definitely would like to see this feature as well, since I run KSP off an external HDD (so that I can take the game with me whenever I'm visiting a friend).

@pjf
Copy link
Member

pjf commented Oct 4, 2014

@sumghai : Thank you! I hadn't even thought about people with portable installs.

It looks like Mono does support registry features, so we'll use that to store our default KSP location. The CKAN is written with the idea of having multiple KSP installs in mind, each which keeps their own meta-info, so once we know where the install is, everything else should work fine. (And CKAN should be fine being on portable media.)

The gotcha, of course, is that portable media can change location, especially on Windows. While one will always be able to specify the KSP location on the command-line, that's a bit of a pain.

It feels like an easy option here is to have CKAN check the directory it's installed in first, and then go checking the registry or other locations to find KSP. That means all that's required for a portable install is to drop it into the same directory as KSP itself. (And since any released code will be using mkbundle for packaging, it'll just be a single file, so removing it will also be as easy.)

@sumghai : Would that suit your portable use-case?

@sumghai
Copy link

sumghai commented Oct 4, 2014

The gotcha, of course, is that portable media can change location, especially on Windows. While one will always be able to specify the KSP location on the command-line, that's a bit of a pain.

It feels like an easy option here is to have CKAN check the directory it's installed in first, and then go checking the registry or other locations to find KSP. That means all that's required for a portable install is to drop it into the same directory as KSP itself. (And since any released code will be using mkbundle for packaging, it'll just be a single file, so removing it will also be as easy.)

A most excellent idea!

pjf added a commit that referenced this issue Oct 4, 2014
@techman83
Copy link
Member Author

@pjf Out of curiosity, how would the registry work on Linux? Assume I know very little about C#/mono :-)

@pjf
Copy link
Member

pjf commented Oct 4, 2014

@techman83: My understanding is that the registry will cheerfully hold keys which are set by Mono applications, but starts off empty. So looking in it for Steam paths under Mac and Linux will return nothing, but we can quite happily set our own key in there, and expect to find it later on.

(As an aside, we now have a logging system (using log4net), and a bin/build script which will build, bundle, and produce a tidy, cross-platform, stand-alone executable from the commandline.)

pjf added a commit that referenced this issue Oct 4, 2014
We now look in the local directory to see if we can find KSP
there. This means one can just copy the client into your
KSP install, and it will Just Work™.

Addresses part of #23.
@pjf
Copy link
Member

pjf commented Oct 4, 2014

@techman83 , @sumghai : I've made it so that CKAN will look in the current working directory first, and only then other locations when searching for KSP. This means that CKAN client as part of a portable install should always work, regardless of whether there's another KSP on the system.

I've built an executable that should work on everything, but you can always build your own using monodevelop/xbuild/visual studio. You can add --verbose or --debug to any command to see more of what it's doing. ckan list --debug should reveal how it's searching for an install.

Given that I'm now building actual executables, I'll need to figure out some sort of test/devel release process soon, lest I go mad from needing to manually copy a file into Dropbox. :)

@Wizarth
Copy link
Contributor

Wizarth commented Oct 4, 2014

CKAN - Multiple KSP Installs

It's a common use case for modders to have multiple installations/copies of KSP.
I suggest a per-user index of installs. This is enough data to point one instance of
CKAN to different installs of KSP, each with it's own per-install data store.

We can safely assume any install folder will be writable by CKAN (or else how would we
install mods).

ckan list-installs
ckan add-install name path/to/install
ckan modify-install name changed/path/to/install
ckan remove-install name

This then allows users to specify which install they want to operate against. If one is not
specified, assume special case default.

ckan --install=0.24_IQ list

If no installs defined, CKAN should attempt to automatically detect default. (E.G. Steam).
If not possible to detect, user should be prompted to define default install.

This leaves an open question re: portable installs. Per-user data shouldn't generally be bundled in the same folder as the executable for non-portable installs.
Perhaps CKAN should check for a settings file in the folder with the executable, and if present, use it rather then the default per-user location.
This could be determined at the time of creating the first install location. If it's the current directory, assume it's a portable installation, set the default to install to "./" and store the install mapping file in the current folder

@pjf
Copy link
Member

pjf commented Oct 4, 2014

@Wizarth : Ooh, I like the idea of being able to give installs names. Then I could ckan --install=RSS install RealSolarSystem and similar, rather than specifying some sort of unwieldy path, or having to copy a ckan executable into each one.

I'm not sure if we want to call them installs, since that sounds a lot like the install keyword we already have, but I do like the idea of naming them.

The main thing I want to make sure of is that no matter what we do here, we should never require a typical user to care about them. That means autoconfiguring default if we can do so easily, and providing an easy way to set the default install if we can't.

With regards to portable installs (which now work!), we're checking to see if the ckan executable is actually located in the KSP directory itself. That means we don't have any bootstrapping issues (the CKAN registry and assets get written the first time it runs), so I think we already have the functionality we need there. (Although we should still permit the user to do a ckan --install=foo ... if they want to administer another install.)

Also, if you can figure out how to get our cmdline argument parser to recognise switches before the verb, that by itself would be a blessing. (There's a reason why --debug and --verbose go after the verb, even though I think they'd be better before it.)

So that's a yes please, I'd love this. I'm guessing the list of installs themselves should live in the Windows/Mono registry, as we can't access the CKAN registry until we know where it is.

@pjf
Copy link
Member

pjf commented Oct 4, 2014

I'm going to split this into three tickets:

The first is essential, and the last is nice to have.

@pjf
Copy link
Member

pjf commented Oct 4, 2014

Branched this ticket out to #28, #29, and #30, with #28 (user specified installs) being the most pressing.

Closing this ticket, since it's now fully covered by the child tickets.

@pjf pjf closed this as completed Oct 4, 2014
@techman83
Copy link
Member Author

Using the build script (after remembering to pull the tags and not just master :P), the produced executable works nicely in the KSP directory (I removed the symlink and cleared out the CKAN data)

leon@beast:~/.fast/Games/SteamLibrary/SteamApps/common/Kerbal Space Program$ mono ckan.exe scan
Setting up CKAN for the first time...
Creating /home/leon/.fast/Games/SteamLibrary/SteamApps/common/Kerbal Space Program/CKAN
Scanning for installed mods...
Registering ModuleManager -> ModuleManager.2.2.0.dll
Registering AJE -> AJE/Plugins/AJE.dll
Registering FerramAerospaceResearch -> FerramAerospaceResearch/Plugins/FerramAerospaceResearch.dll
Registering ferramGraph -> FerramAerospaceResearch/Plugins/ferramGraph.dll
Registering MechJeb2 -> MechJeb2/Plugins/MechJeb2.dll
Registering MissionControllerEC -> MissionControllerEC/MissionControllerEC.dll
Registering kOS -> kOS/kOS.dll
Registering ICSharpCode -> kOS/Plugins/ICSharpCode.SharpZipLib.dll
Creating /home/leon/.cryptfast/Games/SteamLibrary/SteamApps/common/Kerbal Space Program/CKAN/downloads
Registering ModuleManager -> ModuleManager.2.2.0.dll
Registering AJE -> AJE/Plugins/AJE.dll
Registering FerramAerospaceResearch -> FerramAerospaceResearch/Plugins/FerramAerospaceResearch.dll
Registering ferramGraph -> FerramAerospaceResearch/Plugins/ferramGraph.dll
Registering MechJeb2 -> MechJeb2/Plugins/MechJeb2.dll
Registering MissionControllerEC -> MissionControllerEC/MissionControllerEC.dll
Registering kOS -> kOS/kOS.dll
Registering ICSharpCode -> kOS/Plugins/ICSharpCode.SharpZipLib.dll

That's a pretty workable solution for now. Awesome work!!

pjf added a commit that referenced this issue Oct 5, 2014
Clean up directory checks and find Steam on OSX.

Closes #31
Addresses #23 and friends.
RichardLake pushed a commit to RichardLake/CKAN that referenced this issue May 30, 2015
RichardLake pushed a commit to RichardLake/CKAN that referenced this issue May 30, 2015
We now look in the local directory to see if we can find KSP
there. This means one can just copy the client into your
KSP install, and it will Just Work™.

Addresses part of KSP-CKAN#23.
RichardLake pushed a commit to RichardLake/CKAN that referenced this issue May 30, 2015
CKAN-core now buildable and testable by itself
RichardLake pushed a commit to RichardLake/CKAN that referenced this issue May 30, 2015
RichardLake pushed a commit to RichardLake/CKAN that referenced this issue May 30, 2015
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 Enhancement New features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants