Build a development environment where Ruby on Rails breakpoints work on Windows

Build a development environment where Ruby on Rails breakpoints work on Windows

Development environment

Ruby installation

Install Ruby + Devkit

Download the Windows version of Ruby + Devkit and install it. Note that if you change the default installation path, you will need to change the settings separately for some gems that will be installed after this.

Install the required gems

Operate from the Visual Studio Code terminal. The terminal is opened at the bottom of the screen by selecting "New Terminal" from "Terminal" in the menu.

gem install rubocop
gem install ruby-debug-ide
gem install debase
gem install rcodetools
gem install ruby-lint
gem install reek
gem install faster
gem install debride

Visual Studio Code settings

Addition of extension

Install "Ruby" from the Visual Studio Code extension. ruby.PNG

Edit setting.json

Go to "File"-"User Settings"-"Settings" in the menu and search for "ruby". Click "Edit with setting.json" and edit setting.json as follows.

setting.json


{
    "ruby.codeCompletion": "rcodetools",
    "ruby.format": "rubocop",
    "ruby.lint": {
        "reek": true,
        "rubocop": true,
        "ruby": true,
        "fasterer": true,
        "debride": true,
        "ruby-lint": true    
    },
    "ruby.intellisense": "rubyLocate",
    "ruby.locate": {
        "exclude": "{**/@(test|spec|tmp|.*),**/@(test|spec|tmp|.*)/**,**/*_spec.rb}",
        "include": "**/*.rb"
    }
}

Edit launch.json

launch.json


{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Lical File",
            "type": "Ruby",
            "request": "launch",
            "program": "${workspaceRoot}/hoge.rb"
        }
    ]
}

At this point, you can debug the .rb file while stopping it at a breakpoint. To stop at a breakpoint, click to the left of the line number to add a red point. Then, select "Run" from the menu and then "Start Debugging". Next, set up Ruby on Rails to work.

Rails installation

Enter the following in the Visual Studio Code terminal. In the following example, PostgreSQL is specified for DB. Create a project named "test_project" and debug it with the last "rails s".

gem install bundler
install rails
rails new test_project -d postgresql
cd test_project
bundle install
rails s

If something is missing, an error will occur, so follow the steps below.

Install webpacker, Node.js, Yarn

If you read the error message and are told that webpacker is not enough, install it below.

rails webpacker install

If you're told you're missing Node.js or Yarn, download and install it.

Download Node.js Download Yarn

With the above, the local server is started by "rails s". When you open "localhost: 3000" in your browser, the Rails page is displayed.

rails.PNG

If Rails does not start because port number 3000 is duplicated with other services, you can add the port number specification to launch.json.

Recommended Posts

Build a development environment where Ruby on Rails breakpoints work on Windows
Build a Ruby on Rails development environment on AWS Cloud9
Steps to build a Ruby on Rails development environment with Vagrant
Ruby ① Build a Windows environment
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Difficulties in building a Ruby on Rails environment (Windows 10) (SQLite3)
[Ruby] Building a Ruby development environment on Ubuntu
Build a Java development environment on Mac
Build a development environment for Docker + Rails6 + Postgresql
[Personal memo] Ruby on Rails environment construction (Windows)
Template: Build a Ruby / Rails development environment with a Docker container (Ubuntu version)
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
Build a Doker-based development environment on Windows 10 Home 2020 ver. Part 1 Until WSL2-based Docker build
Build a development environment to create Ruby on Jets + React apps with Docker
Install Ubuntu 20.04 in virtual box on windows10 and build a development environment using docker
[Procedure 1 for beginners] Ruby on Rails: Construction of development environment
Ruby on Rails 6.0 environment construction memo
Build a XAMPP environment on Ubuntu
Build Unity development environment on docker
Ruby on Rails --From environment construction to simple application development on WSL2
Ruby on Rails development environment construction with Docker + VSCode (Remote Container)
Build a PureScript development environment with Docker
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
Build Java 8 development environment on AWS Cloud9
Build a Wordpress development environment with Docker
Build a JMeter environment on your Mac
Build an Ultra96v2 development environment on Docker 1
Muscle Ruby on Rails Day 1 ~ Environment Construction ~
Build a simple Docker + Django development environment
Build debug environment on container --Build local development environment for Rails tutorial with Docker-
Build a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack)
Build a development environment on AWS EC2 with CentOS7 + Nginx + pm2 + Nuxt.js
Build a Docker-based development environment on Windows 10 Home 2020 ver. Part 2 VS Code should make the Docker development environment comfortable
Build a WordPress development environment quickly with Docker
Introducing Rspec, a Ruby on Rails test framework
[Ruby on Rails] A memorandum of layout templates
Build a simple Docker Compose + Django development environment
Build a Laravel environment on an AWS instance
[Win10] Build a JSF development environment with NetBeans
(Ruby on Rails6) Creating data in a table
Build a development environment for Docker, java, vscode
Build a Java runtime environment on Sakura VPS
How to build a Pytorch environment on Ubuntu
I made a portfolio with Ruby On Rails
Build a Java development environment with VS Code
[First environment construction] I tried to create a Rails 6 + MySQL 8.0 + Docker environment on Windows 10.
Build an environment where you can try Rails Girls or el-training on Clound9
Create a Java development environment using jenv on Mac
Build Java development environment with VS Code on Mac
[Introduction] Try to create a Ruby on Rails application
[Rails] [Docker] Copy and paste is OK! How to build a Rails development environment with Docker
People who don't usually use Ruby build a Ruby environment
Build ruby debug environment with VS Code of Windows 10
Deploy to Ruby on Rails Elastic beanstalk (Environment construction)
Ruby on Rails Elementary
Ruby on Rails basics
[Environment construction Mac] Ruby on Rails (+ Webpacker handles errors)
Ruby On Rails Association
Ruby on Rails Tutorial Troublesome notes when running on Windows
A high bill from AWS during development on rails ...