Principia DLL won't load on macOS Sequoia
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 :(
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.
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.
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
Seems to work! The question is, why did I need to put in in there?
Oddly, I do see stat64 /Applications/KSP_osx/GameData/Principia/MacOS64/principia.so in the log also.
Yeah, and the error specifically stated that was what it couldn't find
Silly question: does the file have executable permissions? (What does ls -lh /Applications/KSP_osx/GameData/Principia/MacOS64/principia.so say?)
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)
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
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.
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.
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.
Edit: And yes, I am on macOS Sequoia, not some random linux distro nobody cares about.
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.
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
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?
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'
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.
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?
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
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.)
'/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
installing llvm 20 helped. Please update faq