[jrubyscripting] Set .bundle directory to $USERDATA/cache/automation/ruby/.bundle#19604
[jrubyscripting] Set .bundle directory to $USERDATA/cache/automation/ruby/.bundle#19604jimtng wants to merge 5 commits intoopenhab:mainfrom
Conversation
…ruby/.bundle BUNDLE_USER_HOME=$USERDATA/cache/automation/ruby/.bundle Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
jimtng
left a comment
There was a problem hiding this comment.
If there's a need to use and retain the .bundle/config file, we can add a separate path in the future.
jimtng
left a comment
There was a problem hiding this comment.
We could:
- Make it configurable?
- Put it as a sibling of the .gem directory instead of the userdata/cache ?
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
|
Added BUNDLE_USER_CONFIG - updated the OP |
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
|
Hmm, the .bundle directory is still initially created inside ~openhab/ |
This is caused by the gemfile / inline bundler. It doesn't honour BUNDLE_USER_HOME nor BUNDLE_APP_CONFIG env vars. |
|
I haven't found a way to make the inline bundler to use the custom .bundle directory. I have tried setting BUNDLE_USER_HOME and BUNDLE_APP_CONFIG as system property but that didn't work either. I haven't delved deep enough in the inline bundler code to figure out how to monkey patch it either. |
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
|
Overriding If this approach is chosen, we'll need to add the same line in the helper library, so that when user used the inline bundler, it won't end up in ~/.bundle again. |
...main/java/org/openhab/automation/jrubyscripting/internal/JRubyScriptEngineConfiguration.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
This PR configures Ruby Bundler's user home and config directories to use openHAB-specific paths instead of the default system locations. This ensures Bundler's cache and configuration files are stored in a controlled location within the openHAB data structure.
- Introduces
BUNDLE_USER_HOMEconstant pointing to the cache directory - Extracts directory creation logic into a reusable
ensureDirectoryExistsmethod - Sets
BUNDLE_USER_HOMEandBUNDLE_USER_CONFIGenvironment variables for Ruby scripts - Applies the Bundler user home override in all gem management operations
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...main/java/org/openhab/automation/jrubyscripting/internal/JRubyScriptEngineConfiguration.java
Outdated
Show resolved
Hide resolved
...main/java/org/openhab/automation/jrubyscripting/internal/JRubyScriptEngineConfiguration.java
Show resolved
Hide resolved
|
Moving the comment here for easier future reference: it seems that ENV inside Gem / Bundler have been reset (sanitized?), so our custom BUNDLE_USER_HOME is no longer there. Whilst we can return a static string here, we won't be able to do the same trick in the helper library. Setting this aside, it seems that the ENV sanitization is the cause of the fallback into user_home in the first place. So if we can figure out why the ENV gets sanitized and maybe prevent it, then we won't even need to touch/tinker with user_home.
|
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
|
Overriding by prepending seems to do the trick here. We can do the same in the helper library - but only when |
set
BUNDLE_USER_HOME=$USERDATA/cache/automation/ruby/.bundleset
BUNDLE_USER_CONFIG=<Gemfile's directory>/.bundle/config(by default$CONF/automation/ruby/.bundle/config)Resolve #19489