Ruby 2.2.3 in 2020 - ruby

Ruby 2.2.3 has been dead for a while and yet I've been asked to look at a legacy project in order to update and fix it.
I can't get 2.2.3 to install in order to get a local env up and running on either MacOS or Ubuntu.
The error seems to be down to an openssl rubygems issue:
from rubygems.install.log
Exception `LoadError' at /Users/user/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems.rb:1222 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /Users/user/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems.rb:1231 - cannot load such file -- rubygems/defaults/ruby
/Users/user/.rvm/src/rubygems-3.0.8/lib/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- openssl (LoadError)
Does anyone have any suggestions on how proceed?

On MacOS using rbenv instead of rvm solves this issue and has allowed me to move onto another host of dependency issues.

$ brew update && brew upgrade
$ brew doctor
Solve all brew doctor warnings, then proceed further
$ brew uninstall ruby
$ brew install rbenv
$ brew install ruby-build
$ echo 'export RBENV_ROOT=/usr/local/var/rbenv' >> ~/.bash_profile
$ echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
$ rbenv install -l
$ rbenv install 2.2.3
$ rbenv global 2.2.3

Related

Updating fastlane fails: signet requires Ruby version >= 2.4.0

I'm unable to update fastlane.
When I execute fastlane update_fastlane I get the following error.
ERROR: Error installing fastlane:
signet requires Ruby version >= 2.4.0.
When I execute ruby -v I get ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]
I'm stuck at fastlane version 2.28.3. I have tried reinstalling fastlane but I still get the same error.
What can be the cause of this issue? How can I resolve this?
Use this approach.
Remove fastlane from homebrew. Open terminal and run:
brew cask uninstall fastlane
Install ruby environments. Run in terminal:
brew install rbenv ruby-build
echo "" >> ~/.bash_profile
echo 'export PATH=${HOME}/homebrew/bin:${PATH}' >> ~/.bash_profile
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
rbenv install 2.6.5
rbenv global 2.6.5
exit
Open terminal again and run:
gem install fastlane
fastlane -v
Inspiration form:
https://hackernoon.com/the-only-sane-way-to-setup-fastlane-on-a-mac-4a14cb8549c8
I was able to install following the steps provided by gdingenen: https://github.com/fastlane/fastlane/issues/15467#issuecomment-540964272
Delete the .fastlane folder from the user's home folder
rm -r -df ~/.fastlane
Install using gem
sudo gem install fastlane -NV
You just need to replace the old ruby with the lastest one.
Find the lastest one. Execute which ruby, my result is /usr/local/opt/ruby/bin/ruby.
Find the old one. It's /Users/username/.fastlane/bin/bundle/bin/ruby
Replace it. Done.

ruby, gem, rbenv command not found

I've been setting up some ruby dependencies throughout a day on my Lubuntu (18.04) in VM. I installed ruby 2.4.0 and then installed rbenv and set 2.4.0 as global version to be used (probably reverse order). Then I installed bundler and started installing dependencies for my Sinatra app. Since I needed some native extension I also installed libpq-dev via sudo apt-get install, installed pg gem and ran bundler again. And then I have
Command 'ruby' not found, but can be installed with:
sudo apt install ruby
Same with bundle or gem commands.
I can see that I have rbenv in /home/michalvantuch/.rbenv/bin/rbenv and also /home/michalvantuch/.rbenv/versions/2.4.0/.
My path:
/home/michalvantuch/.rbenv/plugins/ruby-build/bin:/home/michalvantuch/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
My bash history:
bundle install
gem install pg -v '0.21.0' --source 'https://rubygems.org/'
vi /home/michalvantuch/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/pg-0.21.0/mkmf.log
sudo apt-get install libpq-dev
gem install pg -v '0.21.0' --source 'https://rubygems.org/'
bundle install
gem list --local
cd /home/michalvantuch/.rbenv/bin/
ls -lah
C rbenv -> ../libexec/rbenv
cd rbenv -> ../libexec/rbenv
cd rbenv
cd ../libexec/
ls -lah
pwd
cd ..
I'm weary and not sure how to fix this. Did I mess up with the system privileges ?
Complete setup commands for rbenv in linux machines
Initial setup
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
~/.rbenv/bin/rbenv init
check whether eval "$(rbenv init -)" is present in ~/.bashrc. If not present run the following command
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
Then,
source ~/.bashrc
mkdir -p "$(rbenv root)"/plugins
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
source ~/.bashrc
rbenv rehash
Now, rbenv installed. Now install your ruby version ( change the version below to your version). And set that to global version. (Use latest stable version as global as it is a good practice. You can set local versions differently depending on your working project)
rbenv install 2.5.1
rbenv global 2.5.1
Finished.
So, it turns out I figured it out myself.
What I was missing (rbenv doctor helped me) was to have shims in my PATH. Adding
eval "$(rbenv init -)"
did the trick.

How do I install ruby gems on Mac

How do I install RubyGems on my Mac?
I tried to run $ gem install rubygems-update with no luck . It returns
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Any help would be great. Thanks
I would highly suggest using a package manager and a Ruby Environment Manager.
On Mac:
brew update
brew install ruby
# If you use bash
echo 'export PATH=/usr/local/Cellar/ruby/2.4.1_1/bin:$PATH' >> ~/.bash_profile
# If you use ZSH:
echo 'export PATH=/usr/local/Cellar/ruby/2.4.1_1/bin:$PATH' >> ~/.zprofile
You can do that but I suggest using an Environment Manager for Ruby.
You have rbenv and RVM.
IMO go for rbenv:
brew install rbenv ruby-build
# bash
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
# zsh
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zprofile
echo 'eval "$(rbenv init -)"' >> ~/.zprofile
# list all available versions:
rbenv install -l
# install a Ruby version:
rbenv install 2.4.1
# set ruby version for a specific dir
rbenv local 2.4.1
# set ruby version globally
rbenv global 2.4.1
rbenv rehash
gem update --system
One more variant is to use brew-gem.
https://formulae.brew.sh/formula/brew-gem
https://github.com/sportngin/brew-gem
Just copy/paste from the documentation:
brew install brew-gem
Usage
brew gem install heroku
To install a specific version: brew gem install heroku 3.8.3
To install using a brew installed ruby(/usr/local/bin/ruby): brew gem install heroku --homebrew-ruby
And with a specific version: brew gem install heroku 3.8.3 --homebrew-ruby
To upgrade: brew gem upgrade heroku
To uninstall: brew gem uninstall heroku
To check information: brew gem info heroku
Note: Installed gems are listed in brew list with prefix of gem-, like gem-heroku.
After installing cocoapods as Tulon suggested the thing which worked for me was passing the --user-install flag to the gem install command e.g
gem install rubygems-update --user-install
from https://guides.cocoapods.org/using/getting-started.html#sudo-less-installation
You may have to install manually in which case (as per the official website):
Go to the official website and download the zip file
Unzip the file in a directory.
Then go to the directory in your terminal and run: ruby setup.rb
It is showing that you don't have the permission to write something in that directory. Instead use this directory :
sudo gem install -n /usr/local/bin cocoapods
It perfectly work for me.
(I am using macOS Sierra, version 10.12.6)

Installing ruby on ubuntu on my first VPS

I'm new to ruby and ubuntu and just created my first VPS droplet for deployment of my rails app. For setting it up I followed Railscast #335, which recommended using rbenv-installer for installing Ruby.
After running:
curl https://raw.githubusercontent.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash
I get the message:
Seems you still have not added 'rbenv' to the load path:
# ~/.bash_profile:
export RBENV_ROOT="${HOME}/.rbenv"
if [ -d "${RBENV_ROOT}" ]; then
export PATH="${RBENV_ROOT}/bin:${PATH}"
eval "$(rbenv init -)"
fi
The railscast suggests adding it to ~/.bashrc using vim (who ever created this user interface??) and then excuting this file using . ~/.bashrc which I followed.
However, when running rbenv bootsrap-ubuntu-14-4 I get the message:
The program 'rbenv' is currently not installed. You can install it by typing:
apt-get install rbenv
Which I think is not the point.
Am I doing something wrong here?
The following worked for me, thanks to the tip from #kristianp:
https://www.brightbox.com/blog/2016/01/06/ruby-2-3-ubuntu-packages/
$ sudo apt-add-repository ppa:brightbox/ruby-ng
$ sudo apt-get update
Install the package:
$ sudo apt-get install ruby2.3 ruby2.3-dev
And you’re up and running:
$ ruby2.3 -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux-gnu]
Cheerio!

Command not found when starting github gollum on mac 10.7

I have tried to follow the installation instructions from:
Github Gollum
I have a fresh lion install and installed xcode command line tools. Then I did the following:
homebrew < -- ran script from website
brew doctor
brew install git
brew install rbenv
brew install ruby-build
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
rbenv install 1.9.3-p362
rbenv rehash
rbenv global 1.9.3-p362
gem install gollum
mkdir ~/gollum_test
cd ~/gollum_test
git init
gollum
I get -bash: gollum: command not found
I'm new to all the tools above, so I don't know what I've missed.
Solved, I had to run
rbenv rehash
again!

Resources