geefr / BSIPA-Linux

A MInimised Linux-native port of BSIPA to support wineless Beat Saber mod installation
Other
5 stars 0 forks source link

IPA-Minimal can't find Unity files #4

Closed businessfish closed 3 years ago

businessfish commented 3 years ago

My Beat Saber install's file structure is different than what the IPA-Minimal binary expects. I tried running the binary in my Beat Saber directory and got this error:

./IPA-Minimal "Beat Saber.exe" -n -f
Beat Saber.exe,-n,-f
DataPath: /home/fish/.local/share/Steam/steamapps/common/Beat Saber/UnityCrashHandler64_Data
EngineFile: /home/fish/.local/share/Steam/steamapps/common/Beat Saber/UnityCrashHandler64_Data/Managed/UnityEngine.CoreModule.dll
ERROR: Game does not seem to be a Unity project. Could not find the libraries to patch.

I looked around the install directory and found the UnityEngine.CoreModule.dll it was looking for is actually located here for me: Beat Saber/Beat Saber_Data/Managed/UnityEngine.CoreModule.dll

Any help/input is greatly appreciated!

Further system details in my ShellSaber post: https://github.com/Ominitay/ShellSaber/issues/5

geefr commented 3 years ago

Interesting issue, similar to something I encountered during the Linux port. Pretty sure I've reproduced this locally, will see about a fix.

On Windows IPA gets called without any arguments, and there's a section of code that does an 'ls', and picks the first .exe it finds. I think this is a bit of an oversight in the original IPA implementation - assumes that a published unity project only has one executable, but in beat saber's case there's 'Beat Saber.exe' and 'UnityCrashHandler.exe'.

That's the reason Beataroni and Shaber pass in the executable name, triggers the bit at Program.cs:100, which is supposed to take the 'FirstOrDefault' positional argument.

Turns out IPA ignores the first argument...Maybe I broke something with my last set of changes

This doesn't work

/home/gareth/source/BSIPA-Linux/IPA-bin/bin/Debug/net5.0/IPA-Minimal -n "Beat Saber.exe" -f --relativeToPwd

But this does

/home/gareth/source/BSIPA-Linux/IPA-bin/bin/Debug/net5.0/IPA-Minimal foo -n "Beat Saber.exe" -f --relativeToPwd
geefr commented 3 years ago

Yeah I see what happened, it's due to this:

// Arguments.cs
// Stock IPA pulls args from the environment
public static readonly Arguments CmdLine = new Arguments(Environment.GetCommandLineArgs());
// And then strips the first argument (The program name) in order to get the actual args
public Arguments(string[] args)
{
    toParse = args.Skip(1).ToArray();
}

Now for the Linux port I'm building IPA as both an executable (command line tool/hackers), and as a dll (built into beataroni). As a dll Environment.GetCommandLineArgs() will return the wrong thing, so I converted Program.Main to actually take arguments.

But of course a C# Main(string[] args) doesn't include the program name in the argument list (doh!)

ominitay commented 3 years ago

The script will update it automatically! Thank you for the quick help.

geefr commented 3 years ago

As a sidenote Beataroni should have 'just worked' as it passed the extra argument through anyways

Thanks for finding the bug, this is all held together with string ;)

ominitay commented 3 years ago

I'm quite surprised that I didn't encounter this on my own system

businessfish commented 3 years ago

You guys rock! Thanks for getting on this - things like this make me proud to be a part of the Linux community.

As a last note - the IPA install failed a couple more times, but this one was an easy fix. It looks like either shaber or IPA uses two directories without making sure they actually exist, those being Beat Saber/IPA/Libs and Beat Saber/IPA/Data in my case. Manually creating those directories made the patch execute cleanly.

shaber ipa patch
Info: All checks passed, continuing to patch...
Beat Saber.exe,-n,-f,--relativeToPwd
Restoring old version... 
Installing files... 
ERROR: Oops! This should not have happened.

System.IO.DirectoryNotFoundException: Could not find a part of the path '/data/fish/.local/share/Steam/steamapps/common/Beat Saber/IPA/Libs'.
   at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
   at System.IO.Enumeration.FileSystemEnumerator`1.Init()
   at System.IO.Enumeration.FileSystemEnumerator`1..ctor(String directory, Boolean isNormalized, EnumerationOptions options)
   at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized)
   at System.IO.Enumeration.FileSystemEnumerableFactory.FileInfos(String directory, String expression, EnumerationOptions options, Boolean isNormalized)
   at System.IO.DirectoryInfo.InternalEnumerateInfos(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
   at System.IO.DirectoryInfo.GetFiles(String searchPattern, EnumerationOptions enumerationOptions)
   at System.IO.DirectoryInfo.GetFiles()
   at IPA.Program.CopyAll(DirectoryInfo source, DirectoryInfo target, Boolean aggressive, BackupUnit backup, Func`3 interceptor, Boolean recurse)
   at IPA.Program.Install(PatchContext context)
geefr commented 3 years ago

Those folders should exist - IPA-Minimal requires that the full-fat IPA be extracted/installed first. IPA-Minimal is just that - The installation logic, doesn't include any of the actual files packaged with BSIPA. In beataroni that's done by just checking the 'BSIPA' mod.

ominitay commented 3 years ago

That is on my end. Shaber should have made these and symlinked files over. Please run shaber m r BSIPA, then run shaber i dl -V. Please send the logs to your issue on my repo -- I'll reopen it now.