How to upgrade ruby version in Amazon Linux system? - ruby

I have developed ruby application using padrino ruby framework.
And I would like to deploy it on Amazon.
I used this image.
Amazon Linux AMI 2017.09.1 (HVM), SSD Volume Type
And image description was:
"The Amazon Linux AMI is an EBS-backed, AWS-supported image. The default image includes AWS command line tools, Python, Ruby, Perl, and Java. The repositories include Docker, PHP, MySQL, PostgreSQL, and other packages."
After launching instance, I tested ruby version and it was ruby 2.0.0p648 (2015-12-16) [x86_64-linux] but I need ruby2.4 to deploy padrino framework.
I tried to update ruby version with no success for whole day.
console says current version is latest version and there is no ruby2.4
How to solve this?(I updated gem version to 2.7.2)

If you are running Amazon Linux 2, later versions of popular software packages (including Ruby) are installed using the Extras Library. To see the latest available version:
$ amazon-linux-extras list
You'll need sudo privileges to install:
$ sudo amazon-linux-extras install ruby2.6

To install ruby 2.4 do this, sudo yum install -y ruby24.
And to make 2.4 the default version (the old version will still be there) do this, sudo alternatives --set ruby /usr/bin/ruby2.4.

Related

Why does the gem mysql2 fails to install when i try to install a version 0.3.x but successfully installs the version 0.4.x and above?

I am new to ruby on rails and am trying to run an older project using gem mysql2 0.3.21. I cant change the gem version. I have already used "sudo apt-get install libmysqlclient-dev" command and the error is still there.
Also when i use the command "sudo apt install libmariadb-dev" the bundle is installed but the rake db:create gives error.
The ruby mysql client is infamously known to be very picky on which dynamic libraries you have installed in your system. So if your local mysql (even just the shared client dev package) is not 100% compatible with the expectations of the gem version, you will not be able to compile it.
I have personally had to switch between 0.3.15 and 0.3.21 because the mysql version in ubuntu (my machine) was only compatible with gem 0.3.21 and above (being MySQL 5.7), while the one on MacOS (the rest of the team) only with 0.3.15 (it was MySQL 5.5).
To make your gem compile you need to have MySQL 5.7 dev packages, and not 8.0+. Once it's compiled, you can switch back to the current version (or even better, start the compatible version in a docker container).

Configuring OpenLiteSpeed for Ruby & Rails

On Ubuntu 18.04 using the instructions here I've installed OpenLiteSpeed via the CyberPanel install, and then installed Ruby using the following commands in the terminal/console:
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
apt install rbenv libreadline-dev ruby-dev -y
export TMPDIR=/mytmp/
rbenv install 2.5.0
rbenv global 2.5.0
gem install rack -v 1.6.11
gem install ruby-lsapi
But now I'm confused about the paths and where to "setup context". The instructions above show the default ruby location different to the instructions for Litespeed and different to where I've found ruby on the server and the ENV values. The locations on the server for 'ruby' are:
/root/.rbenv/versions/2.5.0/bin/ruby
/root/.rbenv/shims/ruby
/etc/apparmor.d/abstractions/ruby
The command gem env shows the following:
Installation directory: /var/lib/gems/2.5.0
User installation directory: /root/.gem/ruby/2.5.0
Ruby executable: /usr/bin/ruby2.5
Executable directory: /usr/local/bin/
In the OpenLiteSpeed admin panel under Server Configuration > App Server I've found Rack/Rails Default Settings. What should I add here for Ruby Path and what other configuration would I need to do please?
I have limited knowledge of Ubuntu/Linux and OpenLiteSpeed, and almost zero knowledge about Ruby.
EDIT: I'm installing Ruby only because I want to install and test ShareTribe which requires Ruby.
EDIT: I've removed Ruby 2.5 and installed 2.6 with the following commands:
sudo apt-get purge ruby
wget http://ftp.ruby-lang.org/pub/ruby/2.6/ruby-2.6.6.tar.gz
tar -xzvf ruby-2.6.6.tar.gz
cd ruby-2.6.6/
./configure
make ...SLOW
sudo make install
All looked good so far, but then the next command gem install bundler gave the error /usr/bin/gem: no such file or directory. So another path error.
From the docs you've linked to it seems you have a few issues, some are not related at all to ruby. However it seems that the documentation for using Ruby on Rails in OpenLiteSpeed are instructing you to use a older version of Ruby than what is required in the documentation for ShareTribe requirements which seem to require you use Heroku for hosting your application. There may be ways to get all of this work on other platforms, but you are traversing the waters of DevOps Hell in which case you may want to post some questions on https://devops.stackexchange.com/
From what I can see you'll need to follow instructions to install ruby 2.65 in place of 2.5.0 but you may want to check with OpenLiteSpeed support to make sure it is supported.
As for SharTribe you'll also want to find out if they will support running on your Digital Ocean droplet.

Fluentd influxdb installation Error?

I want to install influxdb plugin but I get thid error.
ERROR: Error installing fluent-plugin-influxdb:
influxdb requires Ruby version >= 2.2.0.
I uninstalled my ruby and installed different versions from 2.0.0, 2.2.0, 2.3, 2.4
but the error still exist. would you please help me how to solve this.
Thank you.
First of all I installed latest version of ruby from hereruby ftp
Then I installed influxdb client
apt-get install influxdb-dev influxdb-client.
After all downlad the latest version of fluend-plugin-influxdb from git hub of plugin
then I installed the plug in
/opt/td-agent/embedded/bin/gem install fluent-plugin-influxdb
td-agent (Treasure Data's packaged version of Fluentd) includes its own version of ruby within the /opt/td-agent/embedded/ directory and has links to ensure that it does not collide with other installations of ruby on the same box.
You can update to the latest version of td-agent, or if you need a specific version of Ruby then you should
Install Ruby version
Follow gem install instructions here: https://docs.fluentd.org/v0.12/articles/install-by-gem

I cannot update Ruby on Homebrew from 2.0.0 to 2.3.1

I am trying to upgrade Ruby because I need to setup a Jekyll template, and I need to latest version to do it. Since I have a Mac running Sierra, I already have Ruby preinstalled as well as the Homebrew installation. When I install it using brew install ruby, it works, but when I check the version, it is still at 2.0.0 instead of 2.3.1 where it should be. Homebrew says I have 2.3.1, but the CLI says I have 2.0.0. I tried to use brew link --override ruby to make it work, but it said everything was working and it got me nowhere.
Use rbenv and plugin ruby-build. It will keep several versions of ruby on the one machine.
After install go to directory with your code, run rbenv install 2.3.1 and create file .ruby-version containing 2.3.1. All scripts running from this directory will use ruby 2.3.1.
Or you will able to set ruby version for all running scripts - rbenv global 2.3.1

Trouble running RubyGems on Redhat 5.5

Am trying to install Ruby and RubyGems on a RedHat 5.5 machine. I'd got them by running the following two commands:
sudo yum install ruby
sudo yum install rubygems
Got both installed. However when i try to run gem, i got the following error:
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
require': undefined methodend_with?' for "no such file to load --
Win32API":String (NoMethodError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/config_file.rb:55
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in
gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:inrequire'
from /usr/lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:8
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in
gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:inrequire'
from /usr/bin/gem:9
Doesn't matter what kind of command i run, it throws that. (I tried gem -v, gem update)
The version of Ruby seems to be 1.8 but i have problem determining the RubyGems version. I'd vi into rubygems.rb and at the top it stats the version as 1.5.
Try to fix by running the downgrade command as proposed here, but it throws the same error as well.
Any help on fixing this issue? Just want to get this running so that i can run a RoR apps..
RedHat 5 ships with Ruby 1.8.5 and an equally old rubygems. Both, the rubygems and the ruby version is WAY too old to be supported by anything outside the base packages of the OS anymore. Even in the OS packages, they probably won't change anything on their own due to the age of their whole system.
If you really want/have to use Ruby on Red Hat 5, you probably need to get another source for it that the RPMs provided by the OS, e.g. rbenv / ruby-build or ruby-install or even rvm. You should use a newer Ruby version, i.e. a 2.1 or 2.2 version. All Ruby versions < 2.0 are unsupported by the language developers by now.
Alternatively, you should try to use a newer version of RedHat, i.e. RedHat 7 which doesn't need to support to 8 year old software...
Suspicious here is that yum installed ruby 1.8 which is pretty outdated version, it seems you have two versions of ruby on your system now and gem tries to use the old one.
Check the version of the package installed recently and try to force rubygems to use the new version(by removing the old ruby or linking to the path returned by which ruby)

Resources