Skip to content

Instantly share code, notes, and snippets.

@ziaulrehman40
Last active August 21, 2023 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ziaulrehman40/0e3afe55d5d1f93e5bfb02f5a117567c to your computer and use it in GitHub Desktop.
Save ziaulrehman40/0e3afe55d5d1f93e5bfb02f5a117567c to your computer and use it in GitHub Desktop.
Ubuntu setup for rails

Basic use libraries installation

sudo apt update
sudo apt install unace unrar zip unzip p7zip-full p7zip-rar sharutils gnupg2 rar uudeview mpack arj cabextract file-roller

Actual Development Setup

Essentials

sudo apt-get install curl git gitk

RVM

curl -L get.rvm.io | bash -s stable 

If it fails run these commands and try again:

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

ALTERNATIVELY, if you face unfixable issues you may follow https://github.com/rvm/ubuntu_rvm and skip this section)

  • CAREFULLY READ OUTPUT OF THIS COMMAND, THERE WILLL BE FAILURE PROBABLY, AND IT WILL TELL HOW TO FIX THIS FAILURE

  • IT WILL GIVE SOME LINE SIMILAR TO BELOW LINE, SEE PREVIOUS COMMAND OUTPUT FOR ACTUAL COMMAND gpg2 --keyserver hkp://keys.gnupg.net --recv-keys XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • AFTER FOLLOWING INSTRUCTIONS RE-RUN THE COMMAND I.E:

curl -L get.rvm.io | bash -s stable

rvm -v if it fails, try closing and re-opening terminal window

rvm list

Other dependencies

sudo apt-get install build-essential openssl libreadline6-dev 
rvm install 2.7
rvm install 3.0
(Now we will install nvm for node version managaement, it will help when you will move to different projects)
(Follow instructions here: https://github.com/nvm-sh/nvm#install--update-script )
(restart terminal)
nvm install 14
gem -v
rvm list
rvm -v
gem install bundler
gem install bundler -v 1.17
gem install rails
bundle (only if you are in a rails project directory, skip otherwise)

Postgres and PGAdmin4

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update

*For simple instalation

sudo apt install postgresql pgadmin4

For PL/Python support(skip if you don't know what that is)

Don't forget to replace 10 with 9 in following command if you need postgres 9

sudo apt-get install postgresql postgresql-10 postgresql-plpython-10 pgadmin4

Below are common steps for initial setup of DB user

sudo -u postgres psql postgres 
# \password postgres (SET PASSWORD FOR 'POSTGRES' USER)
# \q (to exit psql terminal)
exit

Redis

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install redis-server

sudo update-rc.d redis-server enable
sudo update-rc.d redis-server defaults
sudo systemctl restart redis-server.service
sudo systemctl enable redis-server.service
redis-benchmark -q -n 1000 -c 10 -P 5

GDebi, npm and linters for sublime

sudo apt-get install gdebi npm
npm install -g sass-lint eslint stylelint coffeelint htmlhint typings   (if fails, try with sudo)

Random (not needed 99.9% of times)

// IF YOU NEED, postgres backup and restore...(with roles etc) below are some commands for record. pg_dumpall -U ziap1 -h localhost > db_backupall (to backup from old system) psql -f db_backupall postgres -U postgres -h localhost (to restore on new system)

@ziaulrehman40
Copy link
Author

This gist is tested/used many times but still keep an eye for any abnormalities/errors and in addition to fixing them report them here by commenting so this guide can get better and up-to dated.

@wrnglrsh
Copy link

wrnglrsh commented May 5, 2019

A.O.A this guide line not for windows?

@AzeemWaris9
Copy link

Command: rvm install 2.6
Error: Permission Denied, There was an error(23).
Solution: sudo chown -R dev:rvm /usr/share/rvm/*

@TahaBaber-devsinc
Copy link

Command: rvm install 2.7
Error: Error running 'requirements_debian_update_system ruby-2.7.2'
Solution: rvm autolibs read-only
Note: same for 3.0

@SyedFahad1
Copy link

sudo apt install postgresql pgadmin4
this command is not working

@inaamullah770
Copy link

sudo apt install postgresql pgadmin4
this command is not working

solution:https://stackoverflow.com/questions/58239607/pgadmin-package-pgadmin4-has-no-installation-candidate

@SaadCodes
Copy link

For those who were facing issue with the postgres installation like me because of an error with the release file. (E: The repository 'http://apt.postgresql.org/pub/repos/apt ulyssa-pgdg Release' does not have a Release file.)

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
We were using this command according to the study guide provided to us. This (in my case) gets 'ulyssa' as the release file. This causes the error. You can try entering 'bionic' instead of '$(lsb_release -cs)' to resolve the error as this worked for me.

In case this does not solve your issue use the following link to select another name file:
https://apt.postgresql.org/pub/repos/apt/dists/

Hopefully this will resolve your issue. You can also use "sudo nano" command to edit the text.
Try sudo apt-get update after this and you will an error free log.

My System Details:
Operating System: Linux Mint 20.1 Cinnamon
Cinnamon Version: 4.8.6
Linux Kernel: 5.11.0-37-generic

Have a good day.

@Dev-Abdul-Hannan-Malik
Copy link

Update Guideline for MacOS

Copy link

ghost commented Mar 21, 2022

$ rm -rf ~/.rbenv
$ rvmsudo rvm cleanup all

this worked for me

@AdeelNoshahi097
Copy link

AdeelNoshahi097 commented May 24, 2022

gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.7.0 directory.
Solution:- https://gorails.com/setup/ubuntu/22.04

@mehroz-muzaffar-dev
Copy link

gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.7.0 directory.

Try Adding "sudo" before above command like as follows:
sudo gem install bundler

@hassaan1536
Copy link

Command : curl -L get.rvm.io | bash -s stable
Gave Permission Denied Error
Solution : rvm fix-permissions system; rvm fix-permissions user
Fixed For Me

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