Dec 5, 2021
11
2
3
Belgium
cPanel Access Level
Website Owner
I am unable to require Ruby gems on my server. My hosting provider also has no idea as to why this happens.

Here's a minimal example:
Code:
$ ruby -r 'sinatra' my_script.rb
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- sinatra (LoadError)
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
I have tried adding the following in my bashrc:

Code:
export GEM_PATH=$GEM_PATH:/home/k16461ks/ruby/gems/gems/:/opt/cpanel/ea-ruby27/root/usr/share/gems/gems/
With no succes.

Is there anything I am missing?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
14,425
2,259
363
cPanel Access Level
Root Administrator
Hey there! When setting up a Ruby application on a cPanel server using the following guide:


I don't see the "/usr/share/rubygems" path created on the server. Can you let me know more details about how you setup the application?
 
Dec 5, 2021
11
2
3
Belgium
cPanel Access Level
Website Owner
Hey there! When setting up a Ruby application on a cPanel server using the following guide:


I don't see the "/usr/share/rubygems" path created on the server. Can you let me know more details about how you setup the application?
Yes.

- I added `source /opt/cpanel/ea-ruby27/enable` to the bashrc like described in the link you send.
- I created the application's directory path
- I added two files in the directory:
app.rb:
Code:
require 'rubygems'
require 'sinatra'

class MailingManager < Sinatra::Base
  get '/' do
    'Hello world'
  end
end
config.ru:
Code:
require_relative "app.rb"

run MailingManager
- I then went to the Applicaton Manager, selected the correct path and deployed the app.
- I saw the following in the error log:
Code:
[ E 2022-12-29 18:29:42.9915 21334/T23 age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /home/k16461ks/mailinglijsten/project_src: The application encountered the following error: cannot load such file -- sinatra (LoadError)
[ E 2022-12-29 18:29:42.9915 21334/T23 age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /home/k16461ks/mailinglijsten/project_src: The application encountered the following error: cannot load such file -- rack (LoadError)
- I then went to the terminal and tried ruby -r 'sinatra' my_script.rb as described above.

The gems are installed according to the Ruby Gems screen in CPanel:
- 1672493042610.png