paint-brush
How to Set Up Ruby On Rails on Windows 10 by@simandebvu
3,721 reads
3,721 reads

How to Set Up Ruby On Rails on Windows 10

by Shingirayi Innocent MandebvuDecember 6th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

How to Set Up Ruby On Ruby on Windows: How to install Ruby and Rails on Windows. This article will show the two ways you can install Ruby on windows. Ruby and rails can be installed on Windows using the WSL (Windows Subsystem for Linux) or using the Ruby Installer. Ruby can be set up in the same directory as the default directory for the bash shell so that its easier to navigate to in windows. I propose the C Drive! I'm naming my code folder to Github.

Company Mentioned

Mention Thumbnail
featured image - How to Set Up Ruby On Rails on Windows 10
Shingirayi Innocent Mandebvu HackerNoon profile picture
Once upon a time, installing Ruby on Windows came with a myriad of problems (at least my search history can attest to that), but things have come a long way.
It's not as bad anymore...
Today, there’s no reason someone couldn’t write Ruby code on Windows. Different toolchains or not. Since most of the web is Linux based, it is a very good practice to pitch the development environment to be as close as possible to the production environment. Fortunately for us, Microsoft gave us the gift of WSL (Windows Subsystem for Linux). This article will show the two ways you can install Ruby and Rails on Windows.

OPTION 01: Installing on windows

is a great executable for windows that will get you up and running with Ruby on Windows. Just head over to their website and the version with devkit. It works its magic by using the MSYS2 system for providing Unix-like libraries on Windows as well as MinGW (Minimal Gnu for Windows), which is a large library of Unix-like packages that work on Windows. Proceed to press Enter to install the devkit.


OPTION 02: Installing on Windows (WSL)

After enabling Ubuntu (WSL). (Need help? ). You can open Bash and then, for starters - update out bash to the latest version

sudo apt update && sudo apt dist-upgrade && sudo apt autoremove && sudo apt clean

After that - you can proceed to install ruby with

sudo apt-get update && sudo apt-get install ruby-full


This will install Ruby on your environment and as in windows only install - we will need to install the devkit with this command

sudo apt install build-essential patch ruby-dev zlib1g-dev liblzma-dev libsqlite3-dev nodejs

After the ruby install you can proceed to install the rails gem

gem install rails

With that, you will be done! And you will then proceed to set up your environment with WSL. WSL (by default) does not have an actual directory that you can easily reach out to- for that we have to change the default directory for the bash shell so that its easier to navigate to in windows. I propose the C Drive! I'm naming my code folder to Github. ;)

cd ~

edit .bashrc

That will open the .bashrc file. Scroll down and change

cd ~
to
cd /mnt/c/<your-dir-name>


Replace <your-dr-name> with the relevant folder name.

After this, you can proceed to install postgresql open the bash and type the following

sudo sh -c "echo 'deb //apt.postgresql.org/pub/repos/apt/ focal-pgdg main' > /etc/apt/sources.list.d/pgdg.list"

wget --quiet -O -
//apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -

sudo apt-get update

sudo apt-get install postgresql-common

sudo apt-get install postgresql-9.5 libpq-dev

service postgresql start

After postgresql starts, we can now proceed to create our user

sudo -u postgres createuser yourusernamehere -s

sudo -u postgres psql

## When psql runs, type '\password yourusernamehere' then enter password when prompted.
postgres=# \password yourusernamehere
## Ctl+z to exit psql.

yourusernamehere - will be your desired postgresql username eg - johnnydoe

With that your installation will be ready and you will be able to create your rails apps and have fun!
바카라사이트 바카라사이트 온라인바카라