Skip to content

HBASE-30070 Replace deprecated JRuby LoadService#findFileForLoad with $LOAD_PATH.resolve_feature_path#8052

Open
jinhyukify wants to merge 1 commit intoapache:masterfrom
jinhyukify:HBASE-30070
Open

HBASE-30070 Replace deprecated JRuby LoadService#findFileForLoad with $LOAD_PATH.resolve_feature_path#8052
jinhyukify wants to merge 1 commit intoapache:masterfrom
jinhyukify:HBASE-30070

Conversation

@jinhyukify
Copy link
Copy Markdown
Contributor

@junegunn
Copy link
Copy Markdown
Member

Interesting, I'm not sure how many users rely on loading a script file this way, but we should definitely update the code.

Here's my understanding of the issue.

In previous versions, the SCRIPTFILE argument of hbase shell was not limited to the actual file path. It also resolved relative paths against $LOAD_PATH, so users could set the RUBYLIB environment variable to add custom directories and load scripts from them.

mkdir -p scripts
echo "list; exit" > scripts/list.rb

RUBYLIB=scripts bin/hbase shell -n list.rb

However, this no longer works on the latest master:

ERROR NoMethodError: undefined method `findFileForLoad' for #<Java::OrgJrubyRuntimeLoad::LoadService:0x48788853>
Did you mean?  findFileInClasspath

I can confirm the patch fixes the problem.


That said, I'm not sure loading script files from arbitrary $LOAD_PATH entries is what we intended or is desirable. It seems to pose a security risk similar to why adding . to $PATH is discouraged.

Script resolution from $LOAD_PATH was never documented, so we can consider restricting this to actual file paths.

And by default, the shell doesn't add extra directories to $LOAD_PATH.

bin/hbase shell
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: https://hbase.apache.org/docs/shell
Version 4.0.0-alpha-1-SNAPSHOT, r859dc18330c15f15ad1b4f791bf0871793eeb228, Sun Apr  5 09:36:47 KST 2026
Took 0.0009 seconds
hbase:001:0> $LOAD_PATH
=>
[#<Pathname:/Users/ad02514045/github/hbase/bin/../hbase-shell/src/main/ruby>,
 "uri:classloader:/META-INF/jruby.home/lib/ruby/3.1/site_ruby",
 "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib"]

The patch is fine and is good to merge, but I think this is a good chance to discuss the concern.

@junegunn
Copy link
Copy Markdown
Member

@NihalJain Hi, could you take a look at this? We still have some code that was removed in JRuby 9.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants