Ruby on rails problem with mysql2 when creating linux service - ruby

I have installed ruby2.7. When i try to run my code from command line using. But when i create a service by creating a file /lib/systemd/system/abc.service. when i start this service using command systemctl start abc it gives me an error.
Oct 19 05:21:31 localhost fever-log: /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- mysql2 (LoadError)
I am stuck with this error why its giving error when i try to run the same code from service.

Related

`require': libruby.so.1.8: cannot open shared object file: No such file or directory - /app/path/vendor/local/libxml-ruby-2.4.0/lib/libxml_ruby.so

we are trying to upgrade ruby version of our rails application, currently, it's running in ruby 1.8.7 as a initial step trying to upgrade 1.9.2
when we trying to run ./bundle exec rails s we are getting below error
vendor/local/polyglot-0.3.3/lib/polyglot.rb:63:in `require': libruby.so.1.8: cannot open shared object file: No such file or directory - /home/sakthi/Sakthi/trunk_upgrade_v1/vendor/local/libxml-ruby-2.4.0/lib/libxml_ruby.so
but I can see llibxml_ruby.so file that path

FCGI Ruby Gem not found when using apache

I am using Apache with FastCGI to run a ruby application. I have installed the apache fcgi module and also the Ruby fcgi gem.
When I run the fcgi script 'search.fcgi' like so
ruby search.fcgi
It runs successfully. However when starting Apache I get the following error in my log file when it tries to run the same script:
/usr/local/rvm/rubies/ruby-2.1.8/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- fcgi (LoadError)
from /usr/local/rvm/rubies/ruby-2.1.8/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/user/fcgi/search.fcgi:13:in `<main>'
Line 13 in search.fcgi is simply
require 'fcgi'
It appears as though when running through Apache it is unable to detect the installed gem. I have loaded irb and and run require 'fcgi' which returns true.
Am I missing something here? Some path or config item I need to set?
My problem was caused by the fact that Ruby was installed using RVM. There was some issue with the script from apache accessing some parts of the RVM instillation. The solution was to remove the RVM ruby install and reinstall ruby from source.

LoadError when executing ruby code in /etc/rc.d/rc.local

I use CentOS 6.6. I want to execute a Ruby code on startup, so I added the following command to execute the code to /etc/rc.d/rc.local.
ruby /ruby/send_mail.rb
In send_mail.rb, there is require 'mail', but error occurred like the following.
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- mail (LoadError)
from /usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /ruby/send_mail:23:in `<main>'
(I got this error by using ruby /ruby/send_mail.rb &> error_output)
I did gem install mail. And "send_mail.rb" works properly when I run this manually. Would you tell me what I should do?
Try running ruby using the RVM wrappers, as described here:
/usr/local/rvm/wrappers/ruby-2.2.2/ruby /ruby/send_mail.rb

`require': no such file to load -- rubygems (LoadError)

I am trying to create aws pipeline on vm for which i am using ruby1..3 and rubygems 2.0.3.While trying to create pipeline I am getting following error.
./aws/core/client.rb:14:in `require': no such file to load -- rubygems (LoadError)
Please help me with this problem....
It seems like you are having problems with your ruby/gem installation.
Maybe you have 2 ruby version installed simultaneously on the same machine?
Although not exactly the same question, but it seems that you can try the solutions described in this stackoverflow thread.

Changing where passenger looks for RubyGems

I've installed the Passenger Preference Pane on OSX but whenever I try to run an app I get a 500 Internal Error. Looking at the log gives me the following error:
/usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/utils.rb:25:in `require': no such file to load -- rubygems (LoadError)
from /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/utils.rb:25
from /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.5/bin/passenger-spawn-server:53:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.5/bin/passenger-spawn-server:53
[ pid=403 file=ext/apache2/Hooks.cpp:725 time=2009-11-15 23:33:38.110 ]:
Unexpected error in mod_passenger: Cannot spawn application '/Users/waynemolina/Projects/sandbox/rack-hello-world': The spawn server has exited unexpectedly.
Backtrace:
in 'virtual boost::shared_ptr Passenger::ApplicationPoolServer::Client::get(const Passenger::PoolOptions&)' (ApplicationPoolServer.h:471)
in 'int Hooks::handleRequest(request_rec*)' (Hooks.cpp:521)
Since rubygems works everywhere else, I can only assume this error is because Passenger is looking in the wrong place for Rubygems. I installed Rubygems manually and it's located in /usr/local/bin/gem according to which gem. However, whereis gem returns /usr/bin/gem instead. I'm more than a little confused on what steps I need to take to fix this short of just reinstalling OSX and upgrading the built-in RubyGems install instead of installing it myself.

Resources