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

Cannot initialize ruby plugin: failed to load ruby library after update to Big Sur #1742

Closed
maxw3 opened this issue Jan 3, 2021 · 27 comments · Fixed by #2475
Closed

Cannot initialize ruby plugin: failed to load ruby library after update to Big Sur #1742

maxw3 opened this issue Jan 3, 2021 · 27 comments · Fixed by #2475
Assignees
Labels

Comments

@maxw3
Copy link

maxw3 commented Jan 3, 2021

After updating to MacOS 11.1, I got this error: "Cannot initialize ruby plugin: failed to load ruby library". Game still runs tho. I updated ruby to 2.7.2p137 using rbenv... problem persists. My next course of action is to try and build from source, never done that before.

@lethosor lethosor added the ruby label Jan 3, 2021
@lethosor
Copy link
Member

lethosor commented Jan 3, 2021

The Ruby plugin only looks for the Ruby library in the following two places on macOS, so updating your system-wide Ruby alone wouldn't be enough:

"hack/libruby.dylib",
"/System/Library/Frameworks/Ruby.framework/Ruby",

Can you upload your stderr.log file?

@maxw3
Copy link
Author

maxw3 commented Jan 3, 2021

stderr.log

@maxw3
Copy link
Author

maxw3 commented Jan 3, 2021

Seems libruby.dylib is missing... but why

@lethosor
Copy link
Member

lethosor commented Jan 3, 2021

Does hack/libruby.dylib exist? Looks like it might not, according to the log. If it does, can you try running xattr -d com.apple.quarantine hack/libruby.dylib and see if that helps?

This particularly library is also pretty old, and there's a chance it doesn't work on macOS 11, but I would expect a different message other than image not found if that were the case. I've been working on updating it, but I'm not sure if we have a stable build yet.

@lethosor
Copy link
Member

lethosor commented Jan 3, 2021

Disregard my comment about hack/libruby.dylib - it looks like we've always relied on the system-provided Ruby on 64-bit macOS instead of distributing that file.

Does /System/Library/Frameworks/Ruby.framework/Ruby or /System/Library/Frameworks/Ruby.framework exist?

@maxw3
Copy link
Author

maxw3 commented Jan 3, 2021

It does, but I did some digging around, turns out the symlink(alias) is broken between ...Ruby.framework/Ruby and the actual ruby install within the Versions folder. So dfhack worked in pointing out there was a problem with ruby. Any idea as to how I can go about fixing this?

@lethosor
Copy link
Member

lethosor commented Jan 3, 2021

Interesting - that's similar to #1613, but there wasn't a broken symlink issue there.

If you want to try out the Ruby build I've been working on for #1718, you can get a recent version from https://github.com/lethosor/ruby-build/actions/runs/447673168 (direct link to macOS download). Ruby scripts themselves will have issues without additional updates to the plugin itself, but it would be useful to me to know if this at least loads on macOS 11 successfully, and if simple scripts like multicmd or startdwarf work (or even just :rb puts RUBY_VERSION).

@maxw3
Copy link
Author

maxw3 commented Jan 5, 2021

Ok, so the macOS libruby.dylib worked like a charm and is loaded. :rb puts RUBY_VERSION prints 2.7.2. startdwarf and multicmd works fine but print E: RuntimeError: too low.

@lethosor
Copy link
Member

lethosor commented Jan 5, 2021

Oh, that error is expected if you run startdwarf without specifying a number above 7. The fact that it shows up every time you run a Ruby script after triggering that error is one of the bugs I was referring to that requires updates to the Ruby plugin.

Good to know that the library works for you, though! I plan to put out a wider call for testing a Ruby upgrade for a future release.

@lethosor lethosor added the bug label Jan 29, 2021
@lethosor lethosor self-assigned this Jan 29, 2021
@BryanWitha-y
Copy link

@lethosor Hey I have this exact same problem and this is the only thread on the entire internet that identifies it. I tried to download your Ruby build but the link is broken. Help me please.

@lethosor
Copy link
Member

Were you logged in to GitHub when you clicked on the link? You'll get a 404 if you're logged out, but it still works for me when I'm logged in.

@BryanWitha-y
Copy link

Ah thanks it works now!

@artemsmikh
Copy link

artemsmikh commented Feb 24, 2021

@lethosor hi, thanks for your work! I have the same issue, but putting libruby-2-7-2.dylib into the /hack folder does nothing.
Any ideas what could be the reason? I might have symlink issues on my OS, but Ruby works fine from the Terminal.

Screenshot 2021-02-25 at 2 02 48 AM

@lethosor
Copy link
Member

lethosor commented Feb 25, 2021

Did you rename it to libruby.dylib? And are you on macOS?

@artemsmikh
Copy link

I'm on macOS Big Sur and after renaming to libruby.dylib everything is working fine. Thanks!

@oevseev
Copy link

oevseev commented Apr 14, 2021

For those who are late to the party (the artifacts from #1742 (comment) unfortunately appear to have expired): this prebuilt Ruby 2.7.3 binary from rubies.travis-ci.org seems to be working for me on 11.2:

Loading bindings from data/init/interface.txt
Resetting textures
DFHack is ready. Have a nice day!
DFHack version 0.47.05-r1 (release) on x86_64
Type in '?' or 'help' for general help, 'ls' to see all commands.
[DFHack]# :rb puts RUBY_VERSION
2.7.3

Just put the lib/libruby.2.7.dylib from the archive as hack/libruby.dylib, and you're good to go.

@lethosor
Copy link
Member

lethosor commented Apr 15, 2021

Sorry about that. https://github.com/lethosor/ruby-build/runs/2349569885 should have binaries when it's done. Some dependency broke, possibly due to a GitHub Actions upgrade.

A status update from #1718: currently, Ruby 2.7 has problems on Windows, and I have very limited bandwidth to troubleshoot those problems, so that is preventing us from moving to Ruby 2.7 across all platforms (which I would strongly prefer over the current setup). Unfortunately I don't have any estimate as to when these issues will be resolved.

@pvtvega
Copy link

pvtvega commented May 9, 2021

Interesting - that's similar to #1613, but there wasn't a broken symlink issue there.

If you want to try out the Ruby build I've been working on for #1718, you can get a recent version from https://github.com/lethosor/ruby-build/actions/runs/447673168 (direct link to macOS download). Ruby scripts themselves will have issues without additional updates to the plugin itself, but it would be useful to me to know if this at least loads on macOS 11 successfully, and if simple scripts like multicmd or startdwarf work (or even just :rb puts RUBY_VERSION).

Thanks for all the help you've been providing in this thread. I'm a new Mac user and am having the same issue as OP, however I can't download those Ruby files because it appears the link has expired. Any chance you could post a fresh link?

Thank you!

@lethosor
Copy link
Member

lethosor commented May 9, 2021

@pvtvega unfortunately I cannot, due to #1742 (comment). A change in the GitHub Actions environment (possibly an autotools upgrade) has broken the macOS build between December and now.

The instructions from #1742 (comment) might help you, though - specifically a Ruby 2.7 (not 3.0) build for a relatively recent macOS version should work.

@pvtvega
Copy link

pvtvega commented May 9, 2021 via email

@lethosor
Copy link
Member

If you're running on an ARM machine, it could be an issue like https://www.bay12games.com/dwarves/mantisbt/view.php?id=11734 (unclear to me how widespread the issue is)

@pablo8itall
Copy link

pablo8itall commented Jan 3, 2022

~~ I tried to download your Ruby build but it says its expired. Is there a newer version to try?~~

re-read you comment above and downloaded the 2.7 version to the hack directory and renamed it. working now. :D

Oh had to go to Prefs>>Security and unlock, Allow the lib there and run the command you mentioned:

xattr -d com.apple.quarantine hack/libruby.dylib

@lethosor
Copy link
Member

lethosor commented Jan 8, 2022

If your error didn't have anything to do with Ruby, this is definitely not the right place. I would recommend bringing it up in the Lazy Mac Pack thread.

@lethosor lethosor mentioned this issue Apr 7, 2022
27 tasks
@lethosor
Copy link
Member

lethosor commented Apr 7, 2022

For visibility: our current plan is to remove Ruby support because of issues like this being too difficult and time-consuming to address, and because Ruby doesn't play very well as an embedded language. See #2081 for more details.

@zargogo
Copy link

zargogo commented Jul 31, 2022

Total noob. Trying to play DF for the first time on my M1 Macbook Air and I wanted the Isometric view with Stone Sense. Setting my "Print Mode" in Lazy Mac Pack to "2D" gives me this error too. And my DF screen also turns blank

I ran the command "brew install ruby" but that didn't solve it

@lethosor
Copy link
Member

lethosor commented Jul 31, 2022

The print mode setting has nothing to do with this issue, and this issue isn't related to stonesense. As for homebrew, it probably installs ruby somewhere that DFHack isn't looking.

For stonesense problems, please open a new issue.

@PhoenixWhitebrow
Copy link

PhoenixWhitebrow commented Dec 21, 2023

Thanks for your help guys!
Installing Ruby 2.7.2 with rvm, copying libruby.2.7.dylib to a /hack folder and renaming the file to libruby.dylib worked for me.
It was a pain to do, because at first brew was returning an error due to an old version of Xcode – I solved this by downloading 13.2.1 version from here: https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_13.2.1/Xcode_13.2.1.xip and placing the Xcode.app to my Applications folder. I'm not sure if it's necessary, but I also did this: https://developer.apple.com/forums/thread/677124 before installing the 13.2.1 Xcode.app
Then rvm was unable to compile Ruby 2.7.2 because Ruby 2.7.x doesn't support OpenSSL 3 – I've found a solution here https://stackoverflow.com/questions/76975314/rvm-error-while-running-make-install-in-ruby and used OpenSSL 1.
After all of this I finally was able to get a libruby.2.7.dylib file from a /Users/[username]/.rvm/rubies/ruby-2.7.2/lib directory and go to bed 😁
I hope this info will help somebody experiencing the same issue on Big Sur. Good luck fellow Urists!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants