OSC / ondemand

Supercomputing. Seamlessly. Open, Interactive HPC Via the Web
https://openondemand.org/
MIT License
287 stars 106 forks source link

globally installed gems are not accessible in OOD #3452

Open johrstrom opened 7 months ago

johrstrom commented 7 months ago

From discourse: https://discourse.openondemand.org/t/dynamic-custom-dashboard-widgets/3340/15

We had a user who simply wanted to use the sqlite3 gem in a custom dashboard widget. Only to find out, OOD will not load system installed gems.

This is the current workaround, to modify the $LOAD_PATH.

<%-
  $LOAD_PATH.unshift('/usr/local/share/gems/gems/sqlite3-1.7.3-x86_64-linux/lib')
  require 'sqlite3'
-%>

It seems like we should be able to find/use gems in system installed locations like /usr/local/share/gems.

treydock commented 7 months ago

This can open up issues if that gem was built with different version of Ruby. That location also looks custom.

$ sudo dnf provides /usr/local/share/gems/gems/sqlite3-1.7.3-x86_64-linux/lib
Updating Subscription Management repositories.
Last metadata expiration check: 0:43:19 ago on Thu 28 Mar 2024 11:15:04 AM EDT.
Error: No Matches found

Doing this shows paths not under /usr/local:

$ sudo dnf repoquery -l rubygem-sqlite3
<SNIP>
/usr/share/gems/gems/sqlite3-1.4.2/lib/sqlite3.rb
<SNIP>

This path is custom which is why it wasn't loaded. We should limit how much we support custom things as that can open up maintenance issues.

johrstrom commented 7 months ago

Yea the EL module system doesn't work well for us here. The ruby we use comes from a module, but there aren't rubygem-* variants for all the modules - they all rely on the base version (from epel i think?) which on EL is like 2.5.

This can open up issues if that gem was built with different version of Ruby. That location also looks custom.

That's where gem install sqlite3 put it when running as root.

treydock commented 7 months ago

I took fresh OnDemand install for 3.1 and seeing issues, not sure if related.

[root@ca7cd0983147 /]# scl enable ondemand -- gem install sqlite3 --no-doc
[root@ca7cd0983147 /]# scl enable ondemand -- gem which sqlite3
/usr/local/share/gems/gems/sqlite3-1.7.3-aarch64-linux/lib/sqlite3.rb
[root@ca7cd0983147 /]# scl enable ondemand -- gem list | grep sqlite3
sqlite3 (1.7.3 aarch64-linux)
[root@ca7cd0983147 /]# scl enable ondemand -- irb
irb(main):001:0> require 'sqlite3'
<internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
    from <internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from /usr/local/share/gems/gems/sqlite3-1.7.3-aarch64-linux/lib/sqlite3.rb:6:in `rescue in <top (required)>'
    from /usr/local/share/gems/gems/sqlite3-1.7.3-aarch64-linux/lib/sqlite3.rb:2:in `<top (required)>'
    from <internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:160:in `require'
    from <internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:160:in `rescue in require'
    from <internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:149:in `require'
    from (irb):1:in `<main>'
    from /usr/share/gems/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
    from /usr/bin/irb:25:in `load'
    from /usr/bin/irb:25:in `<main>'
<internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require': /lib64/libm.so.6: version `GLIBC_2.29' not found (required by /usr/local/share/gems/gems/sqlite3-1.7.3-aarch64-linux/lib/sqlite3/3.1/sqlite3_native.so) - /usr/local/share/gems/gems/sqlite3-1.7.3-aarch64-linux/lib/sqlite3/3.1/sqlite3_native.so (LoadError)

I was able to install sqlite and load it but sqlite3 throws errors related to glibc. However this works:

[root@ca7cd0983147 /]# scl enable ondemand -- gem install sqlite3 --no-doc --platform ruby
[root@ca7cd0983147 /]# scl enable ondemand -- irb
irb(main):001:0> require 'sqlite3'
=> true

Not sure if this is because I'm testing on ARM64 Mac.