This will take about 45 minutes. Show We will be setting up a Ruby on Rails development environment on Windows 10. The reason we're going to be using Bash on Ubuntu on Windows because it allows you to run Linux on your Windows machine. Most Ruby on Rails tutorials and dependencies work best on Linux, so this allows you to get the best of both worlds. A Windows machine for your day to day work, and a Linux subsystem for Ruby on Rails development. This only works on 64-bit installations of Windows. This is also in beta, so this won't be nearly as robust as running a Linux virtual machine, but it can definitely do the basics well enough. Windows 10 allows you to run various Linux operating systems inside of Windows similar to a virtual machine, but natively implemented. We'll use this to install Ruby and run our Rails apps. Open Powershell as Administrator and run:
Next install Ubuntu from the Microsoft Store. Now open Ubuntu in the Start menu or by running
Congrats! You've now got a Ubuntu terminal on Windows. You'll use this to run your Rails server and other processes for development. Choose the version of Ruby you want to install: The first step is to install some dependencies for Ruby.
Next we're going to be installing Ruby with a version manager called Rbenv. Installing with To install Ruby and set the default version, we'll run the following commands: Confirm the default Ruby version matches the version you just installed.
The last step is to install Bundler
rbenv users need to run We'll be using Git for our version control system so we're going to set it up to match our Github account. If you don't already have a Github account, make sure to register. It will come in handy for the future. Replace my name and email address in the following steps with the ones you used for your Github account.
The next step is to take the newly generated SSH key and add it to your Github account. You want to copy and paste the output of the following command and paste it here.
Once you've done this, you can check and see if it worked:
You should get a message like this:
Choose the version of Rails you want to install: Since Rails ships with so many dependencies these days, we're going to need to install a Javascript runtime like NodeJS and a package manager called Yarn. To install NodeJS and Yarn, we're going to add it using the official repository:
And now, without further adieu:
If you're using rbenv, you'll need to run the following command to make the rails executable available:
Now that you've installed Rails, you can run the
If you get a different result for some reason, it means your environment may not be setup properly. Rails ships with sqlite3 as the default database. Chances are you won't want to use it because it's stored as a simple file on disk. You'll probably want something more robust like MySQL or PostgreSQL. There is a lot of documentation on both, so you can just pick one that seems like you'll be more comfortable with. If you're new to Ruby on Rails or databases in general, I strongly recommend setting up PostgreSQL. If you're coming from PHP, you may already be familiar with MySQL. You can install MySQL server and client from the packages in the Ubuntu repository. As part of the installation process, you'll set the password for the root user. This information will go into your Rails app's
Installing the When you're finished, you can skip to the Final Steps. The easiest way to setup PostgreSQL is to install it on Windows using one of the Windows installers. You'll be able to run it in Windows and connect to it through Linux. Download PostgreSQL for Windows and install it. Pay attention to the username and password you setup during installation of Postgres as you will use this to configure your Rails applications later to login to Postgres when your Rails app runs. You'll also need to install the development headers on Ubuntu so you can install the pg gem.
The best place to develop Rails apps on the Windows Subsystem for Linux is to navigate to `/mnt/c`. This is actually the C: drive on Windows and it lets you use Sublime, Atom, VS Code, etc on Windows to edit your Rails application. And now for the moment of truth. Let's create your first Rails application:
You can now visit http://localhost:3000 to view your new website! Now that you've got your machine setup, it's time to start building some Rails applications! If
you received an error that said To edit your code in Windows: open up Sublime, Atom, VS Code, or whatever editor your prefer and point them to your folders in When you create a new Rails app, you might run into the following error: parent directory is world writable but not sticky. If you run into this issue, you can run That's it! Let us know in the comments below if you run into any issues or have any other protips to share!. How to install Ruby Gems on Windows 10?Installing RubyGems on Windows:. Step 1: At first search, ruby download in your browser.. Step 2: Then Click on the Rubyinstaller for windows.. Step 3: Then click on the Download Button.. Step 4: Then according to your operating system download your suitable one. ... . Step 5: Then click on the downloaded file.. How to install Ruby in Visual Studio Code in Windows?Steps to configure VSCode for Ruby. Step 1: Install Ruby.. Step 2: Install VSCode.. Step 3: Open VSCode, then open the extensions window, type “ruby” in the search bar, then you will see all the ruby plugins there. ... . VSCode Ruby: Syntax highlighting, snippet, and language configuration support for Ruby.. How to add Ruby to path Windows?Click Control Panel | System Properties | Environment Variables. Under System Variables, select Path and click EDIT. Add your Ruby directory to the end of the Variable Value list and click OK.
|