enebo / Purugin

Ruby Minecraft Plugin support on top of bukkit
237 stars 32 forks source link

How do you load gems? #62

Open NigelThorne opened 7 years ago

NigelThorne commented 7 years ago

I want a plugin to use 'parslet'.

I have something like this...

class AutoBuildPlugin
  include Purugin::Plugin, Purugin::Colors
  description 'AutoBuild', 0.1
  gem "parslet"

  def on_enable
    require 'parslet'
    #...
  end
end

I get the following error on the server...

[16:41:38 INFO]: [AutoBuild] version 0.1 DISABLED
[16:41:38 INFO]: unable to load gem: parslet
[16:41:38 ERROR]: Error occurred (in the plugin loader) while enabling AutoBuild v0.1 (Is it up to date?)
org.jruby.exceptions.RaiseException: (LoadError) Could not find 'parslet' (>= 0) among 5 total gem(s)
Checked in 'GEM_PATH=/root/.gem/jruby/1.9:file:/ssd/var/stipedata/servers/nigel%20mct%201/stipe_user_9665513/plugins/purugin-0.8.0-bukkit-1.7.9-R0.2.jar!/META-INF/jruby.home/lib/
ruby/gems/shared:plugins/PuruginPlugin/gems', execute `gem env` for more information
at RUBY.to_specs(/ssd/var/stipedata/servers/nigel mct 1/stipe_user_9665513/plugins/purugin-0.8.0-bukkit-1.7.9-R0.2.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/dependency.rb
:315) ~[?:?]
at RUBY.to_spec(/ssd/var/stipedata/servers/nigel mct 1/stipe_user_9665513/plugins/purugin-0.8.0-bukkit-1.7.9-R0.2.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/dependency.rb:
324) ~[?:?]
at RUBY.gem(/ssd/var/stipedata/servers/nigel mct 1/stipe_user_9665513/plugins/purugin-0.8.0-bukkit-1.7.9-R0.2.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_ge
m.rb:64) ~[?:?]
at RUBY.process_gems(file:/ssd/var/stipedata/servers/nigel mct 1/stipe_user_9665513/plugins/purugin-0.8.0-bukkit-1.7.9-R0.2.jar!/purugin/plugin.rb:204) ~[?:?]
at org.jruby.RubyHash.each(org/jruby/RubyHash.java:1341) ~[purugin-0.8.0-bukkit-1.7.9-R0.2.jar:?]
at RUBY.process_gems(file:/ssd/var/stipedata/servers/nigel mct 1/stipe_user_9665513/plugins/purugin-0.8.0-bukkit-1.7.9-R0.2.jar!/purugin/plugin.rb:196) ~[?:?]
at RUBY.onEnable(file:/ssd/var/stipedata/servers/nigel mct 1/stipe_user_9665513/plugins/purugin-0.8.0-bukkit-1.7.9-R0.2.jar!/purugin/plugin.rb:139) ~[?:?]
at AutoBuildPlugin_582808228.onEnable(AutoBuildPlugin_582808228.gen:13) ~[?:?]
at RUBY.enable_plugin(file:/ssd/var/stipedata/servers/nigel mct 1/stipe_user_9665513/plugins/purugin-0.8.0-bukkit-1.7.9-R0.2.jar!/purugin/change_listener.rb:55) ~[?:?]
at RUBY.restart_plugin(file:/ssd/var/stipedata/servers/nigel mct 1/stipe_user_9665513/plugins/purugin-0.8.0-bukkit-1.7.9-R0.2.jar!/purugin/change_listener.rb:65) ~[?:?]

The failed load reports having plugins/PuruginPlugin/gems in the GEM_HOME path. I tried uploading the parslet gem to that folder... creating:

/plugins/PuruginPlugin/gems/parslet-1.8.0

This didn't help.

I tried adding ENV["GEM_HOME"] = "./gems" to the plugin before the require... no effect.

NigelThorne commented 7 years ago

Some success...

gem install -i PuruginPlugin/gems parslet

downloads the gem and puts it in the correct folder

Upload this to my server... and all is good. (well I had to adjust the gem to work on jruby... but other than that....)

NigelThorne commented 7 years ago

I see there is code to automatically install the gem if it's missing... but this isn't working. I think it's to do with 'gem' not being in the path on the hosted server I am using. So the call to system ("gem install ..." is failing.