Install the editor and Ruby separately
Visual Studio Code is a code editor, not a Ruby runtime. Download it from Microsoft’s official site, then install a maintained Ruby for your operating system. The terminal command ruby --version should work before you try running a script in VS Code. Installing an editor extension does not install Ruby itself.
VS Code differs from a full Ruby IDE such as RubyMine: it starts with a lightweight editor and adds language features through extensions. You can learn with just Ruby and the integrated terminal; install extra tooling when it solves a real need.
Terminal — verify Ruby before editor setup
ruby --versionOpen a folder and create a Ruby file
Create a folder for your Ruby practice, then choose File > Open Folder in VS Code. In the Explorer, create hello.rb and save the line below. The .rb extension enables Ruby language recognition and syntax colouring. Colouring helps you read the code, but it does not prove the file is correct or run it.
Keep the project folder open rather than an isolated file so the integrated terminal, language tools and any later project files share the same workspace.
hello.rb
puts "Hello, Codectionary!"Add Ruby LSP for richer language help
Open the Extensions view and search for Ruby LSP by Shopify (extension identifier Shopify.ruby-lsp). Microsoft’s current Ruby guide recommends this extension. A language server provides editor features such as navigation, completion, diagnostics and formatting support. These are development aids; Ruby still executes your program.
The extension uses the Ruby available to your project and may create a .ruby-lsp directory for its own bundle. Check the Ruby LSP status item in VS Code’s status bar. A running status and the expected Ruby version indicate that the server found your environment. You do not need to install several older Ruby extensions just to follow this guide.
Run your saved file in the integrated terminal
Choose Terminal > New Terminal, verify that the terminal is in the folder containing hello.rb, then run ruby hello.rb. The command asks your installed Ruby to execute the file. The output appears in the integrated terminal below the editor; it is not the Ruby LSP status or a browser preview. Save the file before rerunning it.
On Windows, a PowerShell terminal works with RubyInstaller. On macOS or Linux, ensure the shell has initialized the Ruby version manager if you use one. An editor reopened before Ruby installation may still have an old PATH; close and reopen VS Code after installing Ruby.
VS Code integrated terminal
ruby hello.rbPause and inspect a running program
A debugger lets you pause on a line and inspect values instead of adding many temporary puts calls. VS Code’s current Ruby guidance uses Ruby LSP’s debugger integration with Ruby’s debug gem. Set a breakpoint by clicking beside a source line, then use the Run and Debug view or a supported Ruby LSP launch option. The debugger runs your code with the project’s selected Ruby and shows paused variables and a call stack.
A basic one-line greeting finishes too quickly to teach much about stepping. Try the variable or method example from the first-program guide, set a breakpoint before its puts line, and inspect name. Depending on your project setup, the debug gem may need to be available in its bundle; follow the current VS Code Ruby debugging instructions for that setup rather than assuming every script has a debugger configured automatically.
Fix common configuration problems
If ruby --version fails in the integrated terminal, check the platform installation guide and restart VS Code so it gets the updated PATH. If Ruby LSP shows an error or selects the wrong Ruby, compare the version in the terminal with the language-status item; check the project’s version-manager configuration and Ruby LSP output. Shopify’s version-manager and troubleshooting guides cover environment detection.
If code is highlighted but ruby hello.rb fails, the extension is working as an editor aid while the runtime or program still has a problem. Read the terminal error and the reported source line. If formatting or diagnostics do not appear, check whether Ruby LSP is running and whether the project’s configured tools and gems are available rather than installing an obsolete extension by default.
Syntax
ruby hello.rbExamples
Run hello.rb in VS Code
Save this file and run ruby hello.rb in the integrated terminal.
puts "Hello, Codectionary!"- The editor stores and highlights the Ruby source.
- The integrated terminal runs the installed Ruby interpreter when you enter ruby hello.rb.
- puts writes Hello, Codectionary! to the terminal; Ruby LSP assists editing but does not produce this output.
Best practices
- Install Ruby separately before configuring VS Code.
- Use the maintained Ruby LSP extension recommended by VS Code’s official Ruby guide.
- Confirm the integrated terminal and Ruby LSP selected the same intended Ruby version.
Runtime & versions
Ruby interpreter. Feature availability depends on the language and runtime version used by your project; consult the official reference below.
Ruby documentation