Thursday, 24 June 2021

RVM is not a function, selecting rubies with 'rvm use …' will not work on Ubuntu

 

  1. Open terminal
  2. Select Terminal ->  Preferences (for top right site navbar) then click
  3. Select Unnamed
  4. Select tab: Command
  5. Check box 'Run command as a login shell' ---- first check box check
  6. Restart terminal

Sum of an Array

 Given an array [1,2,34,5,6,7,8,9], sum it up using a method:

def sum(array)
  return array.inject(:+)
end

Ruby install for new system and Rbenv

 


sudo apt install curl curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update sudo apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Got this error: gpg: keyserver receive failed: Server indicated a failure

--------------------------------------------------------------------------------------------------

Then run for this command: 

curl -sSL https://get.rvm.io | bash -s stable
then got this error:

Downloading https://github.com/rvm/rvm/archive/1.29.12.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.12/1.29.12.tar.gz.asc
gpg: Signature made Saturday 16 January 2021 12:16:22 AM IST
gpg:                using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: Can't check signature: No public key
GPG signature verification failed for '/home/sadhna/.rvm/archives/rvm-1.29.12.tgz' - 'https://github.com/rvm/rvm/releases/download/1.29.12/1.29.12.tar.gz.asc'! Try to install GPG v2 and then fetch the public key:

    gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

or if it fails:

    command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
    command curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -

In case of further problems with validation please refer to https://rvm.io/rvm/security
-----------------------------------------------------------------------------------------------------------

Follow this link: https://rvm.io/rvm/security

Then run: gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Then run command: curl -sSL https://get.rvm.io | bash -s stable

Then run tow command:

command1 curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -

command2 curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -

---------------------------------------------------------------------------------------------------------------

Then rvm install: rvm install 2.6.7

So got this error: 

Error running 'requirements_debian_update_system ruby-2.6.7',

please read /home/sadhna/.rvm/log/1624518537_ruby-2.6.5/update_system.log

Requirements installation failed with status: 100.

---------------------------------------------------------------------------------------

Solve this error: 

Run this command: rvm autolibs disable

Then run rvm install : rvm install 2.6.7



Solve

  1. source ~/.rvm/scripts/rvm
  2. rvm requirements


Finally ruby install 

-------------------------------------------------------------------------

Install ruby on ubuntu 22

Ubuntu 22

https://github.com/rvm/ubuntu_rvm/issues/67
$ cd /usr/local/src/
$ sudo wget https://www.openssl.org/source/openssl-1.1.1n.tar.gz
$ sudo tar -xf openssl-1.1.1n.tar.gz
$ cd openssl-1.1.1n
$ sudo ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib
$ sudo make
$ sudo make install
$ sudo rmdir certs
$ sudo ln -sf /etc/ssl/certs/ certs
rvm install 3.1.2 --with-openssl-dir=/usr/local/ssl
Install Rbenv: https://www.swhosting.com/en/comunidad/manual/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-2204

















 

Wednesday, 23 June 2021

Create coverage file

 https://github.com/simplecov-ruby/simplecov

==================================

Add gem file:

group :development, :test do

  # Call 'byebug' anywhere in the code to stop execution and get a debugger console

  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]

  gem 'simplecov', require: false

end

then install bundle install

==================================

Add a spec/spec_helper.rb

require 'simplecov'

RSpec.configure do |config|

  SimpleCov.start 'rails'

end

==================================