Installing Ruby 2.3 on Wsl (Windows Subsystem for Linux)

There was an error while trying to write to C:/Users/REMOTE~1/AppData/ on Bundle Install [Rails 5.1.3, Ruby 2.3.3]

After 3 days of tinkering and trying to find a solution I came up with the following.

1.) As @anothermh mentioned, it is probably best to install Ruby on Windows Subsystem for Linux Installing Ruby on WSL (Windows Subsystem for Linux) to avoid these kind of situations.

2.) For people who still want to continue using Ruby on their windows systems.

This error occurs when your bundler rubygems copy is corrupted and gets cached into your system.

I solved this by deleted the folder .bundle in C:/users/my_user/.bundle

Re-install bundler and this error goes away and your gems compile and install as usual.

How to change versions of Ruby 1.9 to Ruby 2.0 in the new Windows 10 Bash shell?

Currently, WSL is based on Ubuntu 14.04, so there are no recent Ruby versions available with the official apt repos.

You can install Ruby 2.1, 2.2 and 2.3 via Brightbox/ruby-ng ppa repository if you prefer managing packages with apt.

Quoting from the Brightbox site:

$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:brightbox/ruby-ng
$ sudo apt-get update

And then,

sudo apt-get install ruby2.1

Otherwise, rbenv is an another option to achieve that.

How to install ruby 2.4.0 in Windows 10

Windows 10 comes with a new feature called Windows Subsystem for Linux (WSL) that allows you to use Bash with the most common Linux tools included the ones you need to install a Ruby Manager Version.

For this tutorial we'll set up Ubuntu on Windows, Ruby 2.4.0, Rails 5.0.1 and PostgreSQL.

Installing Bash On Windows

  1. First enable developer mode on your machine
    https://www.youtube.com/watch?v=S6NvjvL3xaI

  2. Next install Windows Subsystem for Linux
    https://www.youtube.com/watch?v=g_5hxfFKDL8

  3. And restart your computer.

  4. After the computer reboot open a Command Prompt (CMD) and type

    > bash
  5. You will see the next message

    This will install Ubuntu on Windows, distributed by Canonical
    and licensed under its terms available here:
    https://aka.ms/uowterms
    Press "y" to continue: y
  6. Press "Y" to continue

    Downloading from the Windows Store... 100%
    Extracting filesystem, this will take a few minutes….
  7. Bash will ask you for a user, please remember this user because bash will ask you every time you need root permissions in Bash. Also when you time your password you won’t see the keystrokes, it’s normal, only keep typing and press ENTER when you finish.

    Please create a default UNIX user account. The username does not need to match your Windows username.
    For more information visit: https://aka.ms.wslusers
    Enter new UNIX username:
    Enter new UNIX password:
  8. And your Bash is ready when you see the CMD its in the
    mnt/c/Users/your_username directory.

    your_username@yourmachine:/mnt/c/Users/your_username$

Installing RVM and Ruby

  1. In your bash copy this line:

    $ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
  2. Then install gnup2

    $ sudo apt-get install gnupg2

Remember your UNIX password because every time you saw a sudo in the command you will be asked for your password.


  1. Install RVM
    $ \curl -sSL https://get.rvm.io -o rvm.sh

    $ cat rvm.sh | bash -s stable

    $ source ~/.rvm/scripts/rvm
  2. Install Ruby

    $ rvm install ruby-2.4.0

If you need to install other version of ruby run this same command like this

$ rvm install ruby-2.3.5

And select the ruby version you want to use

$ rvm --default use 2.3.5

To check if it works

$ ruby -v

Installing RubyOnRails

  1. Install the Ruby’s package manager Bundler

    $ gem install bundler 
  2. Add NodeJS

    $ curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -

    $ sudo apt-get install -y nodejs
  3. Install Rails

    $ gem install rails

Installing PostgreSQL

  1. Download PostgreSQL installer and follow the instructions of the installation
    https://www.openscg.com/bigsql/postgresql/installers.jsp/

  2. The installer will ask you for a user and a password, also keep them in a safe place because you will use it to access to PostgreSQL command line and in database.ymlin your ROR project.

  3. When the installation finish, return to bash and type the next command

    $psql -p 5432 -h localhost -U your_postgresql_username
  4. Bash will ask you the PostgreSQL password and if everything works you will have access to the Postgres shell prompt

    psql (9.5.6, server 9.6.2)
    WARNING: psql major version 9.5, server major version 9.6.
    Some psql features might not work.
    Type "help" for help.
    postgres=#
  5. Type \q to exit the Postgres shell.

Running your Rails app

  1. Open the project in your favorite editor and update the database.yml with the PostgreSQL username and password.

    development:
    database: your_app_name_development
    username: your_postgres_user
    password: your_postgres_password
    host: localhost
    port: 5432

    test:
    database: your_app_name_test
    username: your_postgres_user
    password: your_postgres_password
    host: localhost
    port: 5432
  2. In Bash go to the directory where is your rails project, for example:

    $ cd Projects/my_app

To learn more about Bash navigation visit
https://www.pluralsight.com/guides/beginner-linux-navigation-manual


  1. Create your database

    $ rake db:create
  2. Run the rails server to make sure everything is working

    $ rails s
  3. And go to your browser and visit

    $ localhost:3000

Every time you need a Bash, open a Command Prompt and type

>bash -l

For more detail of each of the commands in this tutorial, visit
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-and-set-up-a-local-programming-environment-on-windows-10

https://medium.com/@colinrubbert/installing-ruby-on-rails-in-windows-10-w-bash-postgresql-e48e55954fbf

Running rails server on bash a linux system on windows

Don't have enough reputation to post as comment but this should provide some answers: https://github.com/rails/rails/issues/26054

Seems to be a windows related issue from last month.

Haven't used ruby on rails in quite a while so I can't reproduce or test (right now) to see if this is true.

From a comment wich was helpful to others:

Go to you config/environments/development.rb and comment out the last
line, something about watching files and listen gem. can't remember
from the top of my head the exact wording, but it is the last line of
config

this is new a new method that rails uses to watch changed files, but
it doesn't work on WSL

I think guard gem will also fail because of this

Bottom line:
Using rails new --skip-spring --skip-listen gives you a working app



Related Topics



Leave a reply



Submit