To run Ruby code on your local machine, you need a Ruby interpreter. On Windows, RubyInstaller makes this easy. On macOS/Linux, managing versions with rbenv or RVM is a cleaner approach.
ruby
# Check Ruby version
ruby -v
# Create a file named hello.rb
puts "Ruby is ready!"
# Run the file
ruby hello.rbruby -v checks whether Ruby is installed. If a version number shows up, Ruby is ready to go. .rb — write your Ruby code in a file with this extension, then run it from the terminal.
You should see
ruby 3.x.x Ruby is ready!Info
Keeping spaces out of file names causes fewer errors for beginners. For example, write hello.rb, calculator.rb, and so on.