Skip to content

Instantly share code, notes, and snippets.

@GQuirino
Last active August 4, 2022 21:06
Show Gist options
  • Save GQuirino/85884970469d51bdbffa4a541a7f71b2 to your computer and use it in GitHub Desktop.
Save GQuirino/85884970469d51bdbffa4a541a7f71b2 to your computer and use it in GitHub Desktop.

Install Ruby < 2.4

UBUNTU

Ubuntu 20.04 no longer supports gcc-5 and libssl1.0-dev, if you try to install ruby versions prior to 2.4 you will find compilation problems as it depends on gcc5 and openssl-1.0.

Add to your /etc/apt/sources.list file

deb http://cz.archive.ubuntu.com/ubuntu bionic main universe
deb http://security.ubuntu.com/ubuntu bionic-security main

run sudo apt update

install GCC-5 and Libssl1.0-dev

https://packages.ubuntu.com/bionic/amd64/gcc-5/download

https://packages.ubuntu.com/bionic/amd64/libssl1.0-dev/download

install from .deb or sudo apt purge libssl-dev && sudo apt install libssl1.0-dev

MAC M1

https://medium.com/@agrawal.mayank1996/installing-old-ruby-versions-in-mac-m1-477a212f8bf2 (Not tested yet)

MAC INTEL

===

Rbenv

git -C ~/.rbenv/plugins/ruby-build remote add makandra https://github.com/makandra/ruby-build.git
git -C ~/.rbenv/plugins/ruby-build fetch makandra
git -C ~/.rbenv/plugins/ruby-build checkout makandra/local-openssl-for-old-rubies

CC=gcc-5 rbenv install ruby 2.2.6

Rvm

rvm install 2.2.6 --autolibs=disable --with-gcc=gcc-5 --patch https://gist.githubusercontent.com/GQuirino/244092ce9ff7449ae3d3cfbb3ff34cce.txt

ERROR MESSAGES

Gem PG

fatal error: libpq-fe.h: No such file or directory fix by running sudo apt-get install libpq-dev

ImageMagick

Can't install RMagick 2.16.0. Can't find wand/MagickWand.h

For Ubuntu you'll need to use ImageMagick 6, In ImageMagick6.x.x version we have magick, wand named folders, where in ImageMagick7.x.x version have named this MagickCore , MagickWand . So this updation is causing the problem in some gem installation like here. Which is using magick/some_header.h or wand/some_header.h (Means they are not updated with the new 7.x.x ImageMagick version).

RubyGem version

Rails 4.0 needs RubyGem version 2.0.3, Just update your system by using following command

gem update --system 2.0.3

ActiveRecord <= 4.0

Active_record <= 4.0 for postgres_adapter.rb this error might appear

PG::InvalidParameterValue: ERROR:  invalid value for parameter "client_min_messages": "panic"
HINT:  Available values: debug5, debug4, debug3, debug2, debug1, log, notice, warning, error.
: SET client_min_messages TO 'panic'

To fix that error message

  • locate the locale of gem pg: gem which pg or gem info pga
  • Navigate to the folder where gems it's intalled: cd ~/.rvm/gems/ruby-2.2.6/gems/
  • locate the file containing the following line client_min_messages, 'panic': grep -ri "client_min_messages, 'panic'" .
  • open the file with your favorite text editor: nano ./activerecord-3.2.22.5/lib/active_record/connection_adapters/postgresql_adapter.rb
  • find line containing: client_min_messages = client_min_messages, 'panic'
  • replace panic by error client_min_messages = client_min_messages, 'error'
@jpechaves
Copy link

jpechaves commented Jun 8, 2021

Manjaro - asdf

  • Install openssl-1.0: sudo pacman -S openssl-1.0
  • Run PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig RUBY_EXTRA_CONFIGURE_OPTIONS="--with-openssl-dir=/usr/lib/openssl-1.0" asdf install ruby 2.2.6

Troubleshooting

rdoc

uncommon.mk:427: recipe for target 'rdoc' failed
make: *** [rdoc] Error 137

If you encounter any error like this, disable the rdoc by exporting this value export RUBY_CONFIGURE_OPTS=--disable-install-doc and run the asdf install command above again

If the path of the install command isn't the same which yous openssl is installed, make this change too.

ImageMagick

sudo pacman -S libmagick6
If you can't install this package using pacman, it probably has been moved to the aur, so check here. After that just run one of the two commands below

PKG_CONFIG_PATH=/usr/lib/imagemagick6/pkgconfig gem install rmagick
PKG_CONFIG_PATH=/usr/lib/imagemagick6/pkgconfig bundle install

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