Principia icon indicating copy to clipboard operation
Principia copied to clipboard

Principia DLL won't load on macOS Sequoia

Open rsparkyc opened this issue 1 year ago • 24 comments

image

Additional Context: Running MacOS Sequoia, followed everything that was listed in discord beginning here: https://discord.com/channels/319857228905447436/480397772248580098/1129098065563893781

Also started a conversation here about it: https://discord.com/channels/319857228905447436/480397772248580098/1301195449968885760

note: the SO file never shows up as getting blocked in system settings, and yet I can see the file exists when I look at the path

And apologies, I know you hate mac support :(

rsparkyc avatar Nov 04 '24 15:11 rsparkyc

KSP.log

rsparkyc avatar Nov 04 '24 15:11 rsparkyc

Is there anything like ktrace or truss on macOS? A trace of the system calls that happen when it's trying to launch the game might help.

pleroy avatar Nov 04 '24 17:11 pleroy

So I wrote this script:

#!/bin/bash

# Define the output file
OUTPUT_FILE="ksp_fs_usage.log"

# Start KSP
open -a /Applications/KSP_osx/KSP.app
echo "Launching KSP..."

# Start fs_usage and filter for "KSP", saving the output to a file
echo "Monitoring file and network activity with fs_usage and saving to $OUTPUT_FILE..."
sudo fs_usage | grep "KSP" > "$OUTPUT_FILE"

I've gzipped the output and attached it here: ksp_fs_usage.log.gz


I could also try dtrace, but need to disable system integrity protection for that one.

rsparkyc avatar Nov 04 '24 21:11 rsparkyc

Interestingly, I saw these lines in that file:

318469:16:31:27  stat64            /Applications/KSP_osx/KSP.app/Contents/Frameworks/principia.so                   0.000008   KSP
318470:16:31:27  access            /Applications/KSP_osx/KSP.app/Contents/Frameworks/principia.so                   0.000002   KSP

I tried dropping the so file in there, and it seems to have loaded

rsparkyc avatar Nov 04 '24 21:11 rsparkyc

image

Seems to work! The question is, why did I need to put in in there?

rsparkyc avatar Nov 04 '24 21:11 rsparkyc

Oddly, I do see stat64 /Applications/KSP_osx/GameData/Principia/MacOS64/principia.so in the log also.

rnlahaye avatar Nov 04 '24 22:11 rnlahaye

Yeah, and the error specifically stated that was what it couldn't find

rsparkyc avatar Nov 04 '24 23:11 rsparkyc

Silly question: does the file have executable permissions? (What does ls -lh /Applications/KSP_osx/GameData/Principia/MacOS64/principia.so say?)

rnlahaye avatar Nov 05 '24 00:11 rnlahaye

it does not:

-rw-rw-r--@ 1 ryancaskey  staff    25M Oct 29 19:11 ./principia.so

after a chmod +x principia.so we get this:

-rwxrwxr-x@ 1 ryancaskey  staff    25M Oct 29 19:11 ./principia.so

however, the problem persists (unless, of course, I drop the unadulterated file into KSP_osx/KSP.app/Contents/Frameworks)

rsparkyc avatar Nov 05 '24 01:11 rsparkyc

I've run into similar issue either. Seems the loader didn't cooperate well along with my OS or Mono environment:

Here's my log: https://pastebin.com/FYiXGyBY

astro-angelfish avatar Nov 06 '24 07:11 astro-angelfish

That last comment is some kind of Linux (we are not told which distro), so unrelated to the rest of the issue. I updated the title to clarify that this issue is about macOS.

pleroy avatar Nov 06 '24 08:11 pleroy

That last comment is some kind of Linux (we are not told which distro), so unrelated to the rest of the issue. I updated the title to clarify that this issue is about macOS.

Ok. I'm gonna open another new issue for it with more detailed information.

astro-angelfish avatar Nov 06 '24 08:11 astro-angelfish

I am also having this issue, however dropping the file in /Applications/KSP_osx/GameData/Principia/MacOS64/principia.so does not work. Adding it here also does not help either : /Applications/KSP_osx/KSP.app/Contents/Frameworks/principia.so I also ran the shell script to obtain the logs, and that path never even appeared.

ksp_fs_usage.log.zip

Edit: And yes, I am on macOS Sequoia, not some random linux distro nobody cares about.

BaconCat1 avatar Aug 31 '25 04:08 BaconCat1

I also ran the shell script to obtain the logs, and that path never even appeared.

I actually do see that in your log file:

16:31:27  stat64            /Applications/KSP_osx/KSP.app/Contents/Frameworks/principia.so                   0.000008   KSP         
16:31:27  access            /Applications/KSP_osx/KSP.app/Contents/Frameworks/principia.so                   0.000002   KSP         

However, I tried firing this up with the latest version (‎Lamé), and am seeing the same behavior now as well.

rsparkyc avatar Sep 18 '25 13:09 rsparkyc

after some more chatGPT prompting I got it to work: https://chatgpt.com/share/68cc0dac-e37c-8001-984b-8769d2fd816b

Had to link the so files with an x86_64 build of libc

rsparkyc avatar Sep 18 '25 13:09 rsparkyc

That ChatGPT thread is mightily long and has a lot of alternatives to explore. Is there a short TL;DR of the things to do to fix the problem?

pleroy avatar Sep 18 '25 16:09 pleroy

It is, but I intentionally left it all because I didn't know what step actually did the trick. But what I think did it was the following:

/usr/bin/arch -x86_64 /bin/bash -lc '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'

/usr/bin/arch -x86_64 /bin/bash -lc 'brew install llvm@17 || brew install llvm'

chmod u+w "/Applications/KSP_osx/GameData/Principia/MacOS64/principia.so"
chmod u+w "/Applications/KSP_osx/KSP.app/Contents/Frameworks/principia.so"

install_name_tool -change /usr/local/opt/llvm/lib/c++/libc++.1.dylib \
  /usr/lib/libc++.1.dylib \
  "/Applications/KSP_osx/GameData/Principia/MacOS64/principia.so"

install_name_tool -change /usr/local/opt/llvm/lib/c++/libc++abi.1.dylib \
  /usr/lib/libc++abi.dylib \
  "/Applications/KSP_osx/GameData/Principia/MacOS64/principia.so"

install_name_tool -change /usr/local/opt/llvm/lib/unwind/libunwind.1.dylib \
  /usr/local/opt/llvm@17/lib/libunwind.1.dylib \
  "/Applications/KSP_osx/GameData/Principia/MacOS64/principia.so"

install_name_tool -change /usr/local/opt/llvm/lib/c++/libc++.1.dylib \
  /usr/lib/libc++.1.dylib \
  "/Applications/KSP_osx/KSP.app/Contents/Frameworks/principia.so"

install_name_tool -change /usr/local/opt/llvm/lib/c++/libc++abi.1.dylib \
  /usr/lib/libc++abi.dylib \
  "/Applications/KSP_osx/KSP.app/Contents/Frameworks/principia.so"

install_name_tool -change /usr/local/opt/llvm/lib/unwind/libunwind.1.dylib \
  /usr/local/opt/llvm@17/lib/libunwind.1.dylib \
  "/Applications/KSP_osx/KSP.app/Contents/Frameworks/principia.so"

Honestly, it may only require doing those steps to the principia.so file that I've placed within KSP.app. It would be good to get some others to try to see if they can boil this down to the minimum set of steps.

Edit: forgot /usr/bin/arch -x86_64 /bin/bash -lc 'brew install llvm@17 || brew install llvm'

rsparkyc avatar Sep 18 '25 16:09 rsparkyc

It would be interesting to know whether it still works if you get rid of the copy of principia.so in /Applications/KSP_osx/KSP.app/Contents/Frameworks/principia.so.

That one is probably not going to be found in Lánczos (to be released Sunday), because of #4308.

eggrobin avatar Sep 18 '25 16:09 eggrobin

I think that after the first step (which installs brew for x86_64) there has to be an extra step of installing llvm@17 for x86_64. We have to do something like that for building Principia on our M1, see the macOS instructions.

I take it that you are running on an ARM machine?

pleroy avatar Sep 18 '25 16:09 pleroy

I am using an arm mac (m2)

I think i forgot this command:

/usr/bin/arch -x86_64 /bin/bash -lc 'brew install llvm@17 || brew install llvm'

going to update my post

rsparkyc avatar Sep 18 '25 17:09 rsparkyc

I have added words to the FAQs, focusing on the case where the shared library is in the canonical location. (The reason why you had to have a copy in KSP.app/Contents/Frameworks has never been clear to me, and I would rather not invite users to do the copy unless they have to; this is going to be a sure mess when they upgrade, especially with upcoming changes to the way we load the shared library.)

pleroy avatar Sep 20 '25 09:09 pleroy

'/Users/adigyran/Library/Application Support/Steam/steamapps/common/Kerbal Space Program/KSP.app'

my ksp in here so those fixes not work at all :( moved so file, installed llvm and such and still this error. m3 max sequoia

adigyran avatar Oct 26 '25 19:10 adigyran

Image

adigyran avatar Oct 26 '25 20:10 adigyran

installing llvm 20 helped. Please update faq

adigyran avatar Oct 26 '25 20:10 adigyran