Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

jrubyscripting addon error when the bundle is updated #531

Closed
jimtng opened this issue Feb 27, 2022 · 4 comments
Closed

jrubyscripting addon error when the bundle is updated #531

jimtng opened this issue Feb 27, 2022 · 4 comments

Comments

@jimtng
Copy link
Collaborator

jimtng commented Feb 27, 2022

Whenever I overwrite the bundle's jar file with a newer version, openhab would reload the bundle, but when it reached the Gem.install part of the code, it would throw an BootstrapMethodError. After this, I'd need to restart openhab to recover. This error doesn't happen during the normal startup.

What's strange is if I call Gem.install after require 'openhab', it would work fine. Move it just right before require 'openhab' and the same error will happen.

In fact this is what I found: if I go and edit openhab.rb (inside the gem_home/gems directory) and just have an empty file, this will still work:

require 'openhab' # this is located in the gem_home/gems/openhab-scripting-xxx but it is an empty file
Gem.install('openhab-scripting')

If I removed the require 'openhab', Gem.install will throw that BootstrapMethodError.

I can replace require 'openhab' with require 'httparty' (provided that httparty gem is installed on the system), and it would still work fine.

What I noticed is that require-ing something that's a part of the gem library would alter the LOAD_PATH, i.e. jruby will add the gem's lib directory into the LOAD_PATH. This is a standard behaviour from rubygems. I just can't figure out why after requiring something that lives inside gem_home, Gem.install would work.

It's a bit more complicated though. If I call Gem.install('a new gem that hasnt been installed') then it would fail regardless, but only after a bundle update. It would succeed on a fresh openhab restart.

@jimtng
Copy link
Collaborator Author

jimtng commented Feb 27, 2022

I've opened an issue with jruby here jruby/jruby#7120

@jimtng
Copy link
Collaborator Author

jimtng commented May 15, 2022

It seems that this issue does not occur on java17

@jimtng
Copy link
Collaborator Author

jimtng commented Jul 12, 2022

I'm closing this because it appears to be a jruby / jdk issue, and a fix/solution is found which will hopefully be included in jruby 9.3.7.0

@boc-tothefuture
Copy link
Owner

Great work tracking this down and bringing it to closure in jruby.

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

No branches or pull requests

2 participants