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
Loading ruby gems #118
Comments
Mac has the same issue regarding |
In the end I ended up using this to fix the loading issues: $:.push('stdlib') unless System.platform[/macOS/]
$:.push('stdlib/x64-mingw32') if System.platform[/Windows/]
$:.push('stdlib/x86_64-linux') if System.platform[/Linux/]
$:.push('../Resources/Ruby/3.1.0/x86_64-darwin') if System.platform[/macOS/]
$:.push('gems') |
There is also an issue with using https with On macOS there is no issue and it already works with current setup. For Linux you just need to remove Windows is the most complicated. Again you need to remove
right after
Commit: enumag@54c7704 On all platforms there is the additional issue that you need either disable verification (not recommended) or provide a own ca_file to use for the verification. You can get it for instance from https://curl.se/docs/caextract.html. Code example: require 'net/http'
uri = URI('https://...')
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :ca_file => 'cacert.pem') do |http|
http.request(Net::HTTP::Get.new(uri)) do |response|
# ...
end
end |
I was having some problems on Linux because it needs
|
@Nathan-MV That doesn't make sense, why would you have rbconfig in |
I'm using Ruby 3.2.2, there's no such a thing as |
That sounds very suspicious. Mingw is a windows tool so a directory called x64-mingw32 should not exist in linux stdlib. If it does it's most likely a bug and the contents of rbconfig.rb will likely be incorrect. Do you have a build with ruby 3.2 on your github actions? |
Wait for @Splendide-Imaginarius to start the actions of this PR #131 |
I wanted to use rubyzip in my game so I was looking for how to load gems.
The results written here are a result of brainstorming with Nathan and Splendide Imaginarius in Maple Shrine Discord - big thanks to both!
Third party gems
As long as it's a pure ruby gem (written in just ruby without C) they can be loaded by adding this into
mkxp.json
:And copying the gem's ruby files (typically the content's of
lib
directory) into thisgems/
directory which should be next to themkxp.json
.Standard library
This however didn't work on it's own for
rubyzip
because it requires some standard ruby libraries to work. Fortunately mkxp ships withstdlib
directory. According to current documentation it can be loaded like this:For some reason it's apparently built in on mac so this step is unnecessary. (Disclaimer: I didn't test things on mac yet so I can't confirm it for now.)
However from testing this is essentially equivalent to just adding the stdlib directory to rubyLoadPath:
There is one thing worth noting: the
stdlib
directory is intentionally different for windows and linux meaning you can't simply use the same one for all platforms. Ideally use the correct one for windows and linux and omit it altogether on mac.rbconfig
This however still wasn't enough for
rubyzip
because it usesrbconfig
which is platform dependent. We fixed it by changing mkxp.json like this:On linux it should instead be like this:
Yes, this means that mkxp.json needs to be different for each platform as well.
With that rubyzip finally worked for me. I'll post further info about linux and mac later.
One caveat I should note that when I made a typo in mkxp.json the gems simply weren't loaded but there was no error about mkxp.json being invalid (#116).
The text was updated successfully, but these errors were encountered: