How to Download & Install CUCUMBER in Windows

โšก Smart Summary

Cucumber installation on Windows needs four pieces in order: Ruby with its development kit, the Cucumber gem itself, an editor such as RubyMine, and a browser driver library. Each one installs in minutes.

  • ๐Ÿ”˜ Ruby first: Cucumber is a Ruby gem, so the Ruby+Devkit installer from RubyInstaller must be in place before anything else.
  • โ˜‘๏ธ One command: The command gem install cucumber pulls the gem and its dependencies straight from RubyGems at the command line.
  • โœ… Verify immediately: Running cucumber –version confirms the gem resolved and that the executable is on the system PATH.
  • ๐Ÿงช Editor optional: RubyMine gives syntax highlighting and step navigation, but any editor that saves plain text will run a feature file.
  • ๐Ÿ› ๏ธ Browser driver: Watir wraps Selenium and drives the browser; the modern gem name is watir, not the retired watir-webdriver.
  • ๐Ÿ“Š Fixed layout: Feature files live under features, step definitions under features/step_definitions, or Cucumber cannot match a step.

Download and install Cucumber on Windows with Ruby, RubyMine and Watir

Cucumber installation can look tiresome, but it is relatively easy once the pieces are taken in the right order. Here is the roadmap of components that need to be installed to make Cucumber work.

Prerequisites for Installing Cucumber on Windows

Cucumber is distributed as a Ruby gem, so nothing works until Ruby is present. Confirm the following before you download anything:

  • Windows 10 or later, 64-bit. RubyInstaller no longer recommends the 32-bit build unless you depend on 32-bit native DLLs or COM objects.
  • Administrator rights. The installer writes to Program Files and edits the PATH environment variable.
  • An internet connection. Both gem install commands below fetch packages from RubyGems.
  • Around 1 GB of free disk space for Ruby plus the MSYS2 development kit, and more again if you add RubyMine.
  • A browser to automate. Watir drives Chrome, Edge or Firefox through Selenium, so at least one must be installed.

Two commands are worth remembering for later: ruby -v prints the Ruby version, and gem -v prints the RubyGems version. If either fails, the PATH was not updated and the installer should be run again rather than debugged.

Install Ruby and DevKit

Start with the Ruby+Devkit package, which bundles the compiler toolchain that gems with C extensions need.

Step 1) Go to https://rubyinstaller.org/downloads/ and pick an installer. The download page is shown below.

RubyInstaller downloads page listing the Ruby and Ruby+Devkit installers

โš ๏ธ Version note: the separate DevKit archive the original walkthrough refers to has been replaced by the MSYS2 toolchain, which the Ruby+Devkit installer bundles as a selectable component. RubyInstaller currently recommends the Ruby+Devkit 4.0.X (x64) build for new users, and the kit is updated later with ridk install rather than by re-running dk.rb. The steps below are otherwise unchanged.

Step 2) Open the downloaded file. On the first screen:

  1. Accept the license
  2. Click the Next button

Ruby installer license agreement screen with the Next button

Step 3) On the next screen:

  1. Select your installation directory
  2. Select all options
  3. Click Install

Choosing the Ruby installation directory and selecting all installer options

Step 4) On the following screen, click Next.

Ruby installer component selection screen before the copy begins

Step 5) Wait for the installation to complete.

Ruby installation progress while files are copied to disk

Step 6) Click Finish.

Final Ruby installer screen with the Finish button

Step 7) Once the installation is complete, run Ruby from the Windows Start menu.

Windows Start menu entry that opens the command prompt with Ruby

Step 8) You will see a Ruby command prompt similar to the Windows cmd window.

Ruby command prompt window ready to accept gem commands

Install Cucumber

With Ruby on the PATH, the gem itself is a single command.

Step 1) Type gem install cucumber in the Ruby command prompt. This command downloads and installs Cucumber at the command line itself.

gem install cucumber typed into the Ruby command prompt

After a few seconds the Cucumber installation procedure starts and reports each dependency it fetches.

Cucumber gem installation output listing the dependencies being installed

Step 2) To verify whether Cucumber installed successfully, type cucumber –version. Note the two hyphens โ€” a single hyphen is not a valid long option.

cucumber --version command printing the installed Cucumber version

Install IDE RubyMine

An editor is not strictly required, but RubyMine understands Gherkin and can jump from a step to its definition. Follow the steps below to install it.

RubyMine setup wizard welcome screen

Step 1) Click Next to continue with the RubyMine installation.

RubyMine installer first page with the Next button

Step 2) Choose the install location.

Selecting the RubyMine installation folder

Step 3) Set the installation options.

RubyMine installation options such as shortcuts and file associations

Step 4) Choose the Start menu folder.

Choosing the Start menu folder for the RubyMine shortcut

Step 5) Click Install.

RubyMine installer ready to copy files after clicking Install

Step 6) Click Finish.

RubyMine setup completed screen with the Finish button

Step 7) Select Do not import settings.

Import settings dialog on the first RubyMine launch

Step 8) Click Evaluate.

RubyMine licence activation window with the Evaluate option

Step 9) Accept the license.

Accepting the RubyMine licence agreement

Step 10) Choose Skip Remaining and Set Defaults.

RubyMine initial customisation screen with Skip Remaining and Set Defaults

Step 11) Open the editor.

RubyMine welcome screen with the Open option

Step 12) Create a new project.

New project dialog in RubyMine

โš ๏ธ Version note: RubyMine is a paid JetBrains product with a time-limited evaluation, which is what the Evaluate button in Step 8 starts. A free alternative is Visual Studio Code with a Ruby and a Cucumber (Gherkin) extension; the rest of this walkthrough works the same way in either editor.

Install watir-webdriver

Cucumber only runs the steps. Something else has to open the browser, and that job belongs to Watir, a Ruby wrapper around Selenium. If you prefer to drive the browser directly, the same project can call a plain WebDriver script.

Step 1) Click on Start Command Prompt With Ruby and run the install command gem install watir-webdriver.

gem install watir-webdriver running in the Ruby command prompt

Step 2) The watir-webdriver gem installs successfully.

Console output confirming the watir-webdriver gem installed

โš ๏ธ Deprecation note: the watir-webdriver gem was folded into the main watir gem at Watir 6.0, and its own repository now only points users at the replacement. On a new machine run gem install watir instead. The historical command above is kept because it is what the screenshots show.

Cucumber Project Folder Structure

Cucumber discovers files by convention, not by configuration, so the layout matters more than it first appears. A minimal project looks like this:

Path Holds
features/ Every .feature file, written in Gherkin. Cucumber searches here by default.
features/step_definitions/ The Ruby files whose blocks match each Given, When and Then line.
features/support/ Setup code loaded before any step runs, such as env.rb, which is where the browser is usually opened and closed.

Two rules save a great deal of confusion later. Cucumber ignores the keyword when it matches a step, so Given I have variable a and Then I have variable a collide with the same definition. And the step text in the feature file must match the regular expression in the step file exactly, including punctuation.

First Cucumber Script

The example below multiplies two numbers, which is enough to prove that the feature file, the step file and the gem are all talking to each other.

Step 1) Open the RubyMine editor from the Windows Start menu.

Opening RubyMine from the Windows Start menu

The RubyMine dashboard appears as shown below.

RubyMine dashboard shown after the editor opens

Step 2) Create a new project in the RubyMine editor.

Starting a new project from the RubyMine dashboard

Give the project a name and a location, then confirm.

Entering the project name and location in the new project dialog

Step 3) Create a file directory.

Creating a new directory inside the RubyMine project

The new directory appears in the project tree.

Project tree showing the newly created features directory

Step 4) Create and save a file in yourfolder/features/ with the name yourfilename.feature.

Creating the feature file inside the features directory

Confirm the file name so it ends in the .feature extension.

Naming the new file with the .feature extension

Step 5) To execute our scenario, save the following commands in the feature file.

Feature file open in the RubyMine editor ready for the scenario

Code:

Feature: Multiplication 
I multiply two numbers 
	Scenario: multiply a and b 
		Given I have variable a 
		And I have variable b 
		When I multiplication a and b 
		Then I display the Result

Step 6) Now run the first feature file.

Click on Start Command Prompt With Ruby and run the cucumber command from the project folder.

Launching the Ruby command prompt to run the feature file

The console reports the result as shown below.

Console output from the first Cucumber run of the feature file

Step 7) Create the step definition file for the feature file.

Create a new folder in the RubyMine editor.

Creating a new folder in the RubyMine project for step definitions

Naming the new step definitions folder

Step 8) Save the file in yourfolder/features/step_definititons with the name test_step.rb.

Saving a new Ruby file inside the step definitions folder

Entering test_step.rb as the step definition file name

Step 9) Write the following code into the step file.

Step definition file open in the editor before the code is added

Code:

Given(/^I have variable a$/) do
@a = 50
end

And(/^I have variable b$/) do
@b = 70
end

When(/^I multiplication a and b$/) do 
@mul = @a * @b
end

Then(/^I display the Result$/) do 
puts "Multiplication of #{@a} and #{@b} is #{@mul}"
end

Step 10) Now run the feature file again.

Running the feature file a second time after the steps are defined

The result is printed in the console, and each step is reported as passed.

Cucumber console output after the feature file runs with defined steps

Common Cucumber Installation Errors and How to Fix Them

Most failures at this stage come from the environment rather than from Cucumber. These are the ones worth recognising on sight.

Message Cause Fix
‘cucumber’ is not recognized as an internal or external command The Ruby bin directory is not on the PATH, or you are in a plain cmd window. Open Start Command Prompt With Ruby, or reinstall Ruby with the PATH option selected.
SSL_connect returned=1 errno=0 state=error: certificate verify failed RubyGems cannot validate the certificate chain, usually behind a corporate proxy. Update RubyGems with gem update –system, or configure the proxy with the –http-proxy switch.
ERROR: Failed to build gem native extension The MSYS2 development kit is missing. Run ridk install and choose the MSYS2 and MINGW toolchain options.
invalid option: -version A single hyphen was used for a long option. Type cucumber –version with two hyphens.
Undefined step, with a suggested snippet printed below it Cucumber found the feature file but no matching definition. Paste the suggested snippet into a file under features/step_definitions and fill in the body.
cannot load such file — watir The gem installed for a different Ruby version than the one running. Check ruby -v and gem list watir in the same prompt, then reinstall the gem there.

Once the multiplication scenario reports a pass, the installation is finished and the same project can grow into a full automation testing suite, whether it is used for functional testing or nightly regression testing.

FAQs

No. Cucumber-JVM covers Java, Kotlin and Scala, Cucumber.js covers JavaScript, and ports exist for several other languages. The Ruby version described here is the original implementation, and Gherkin syntax is identical across all of them.

Any editor works, because a feature file is plain text. RubyMine adds Gherkin autocompletion and jump-to-definition, while Visual Studio Code offers similar behaviour free through a Ruby extension and a Cucumber extension.

Yes, for any suite more than one person runs. A Gemfile with an explicit cucumber version and a committed Gemfile.lock means every machine and every CI agent resolves the same gem, which removes an entire class of works-on-my-machine failures.

Not at all. Watir is a convenience wrapper over Selenium, so you can require the selenium-webdriver gem directly in your step definitions instead. Watir simply gives shorter element syntax for Ruby projects.

Cucumber already prints a snippet for every undefined step, and AI assistants extend that by filling in the body from the surrounding page objects. Treat the output as a first draft, because generated selectors are frequently wrong.

It does. Copilot recognises Feature, Scenario, Given, When and Then, and will suggest further scenarios in the same style. It is weakest at judging which scenarios genuinely add coverage rather than repeating an existing one.

Patch upgrades within one branch, such as 3.4.0 to 3.4.3, can reuse the same directory and keep existing gems. A move between stable branches needs a fresh target directory, because gems with C extensions are not compatible across them.

Three cover most needs: –dry-run checks that every step has a definition without executing anything, –tags runs a labelled subset of scenarios, and –format sets the reporter, for example pretty output locally and JSON or HTML for a build server.

Summarize this post with: