windmill-labs/windmill · error

`require 'windmill/inline'` is not detected - please add `re

Error message

`require 'windmill/inline'` is not detected - please add `require 'windmill/inline'` in order to use inline gemfile.
                Your Gemfile syntax will be compatible with bundler/inline.

What it means

When a Ruby script uses bundler/inline Gemfile syntax (`gemfile do ... end`), Windmill requires the script to first `require 'windmill/inline'` so the inline `gem` method is available at run time. `parse_ruby_requirements` regex-checks for that require line and raises this error when it is missing, telling the user exactly what to add.

Source

Thrown at backend/parsers/windmill-parser-ruby/src/lib.rs:88

        if x.kind() == "call" {
            for (i, n) in x.children(&mut x.walk()).enumerate() {
                if i == 0
                    && n.kind() == "identifier"
                    && !n
                        .utf8_text(code.as_bytes())
                        .map(|ident| ident == "gemfile")
                        .unwrap_or_default()
                {
                    continue 'top_level;
                } else if n.kind() == "do_block" {
                    let req = n.utf8_text(code.as_bytes())?.to_owned();

                    lazy_static::lazy_static! {
                        static ref WINDMILL_RE: Regex = Regex::new(r"(?m)^\s*require\s*'windmill/inline'").unwrap();
                    }

                    if WINDMILL_RE.find(&code).is_none() {
                        return Err(anyhow!(
                            "`require 'windmill/inline'` is not detected - please add `require 'windmill/inline'` in order to use inline gemfile.
                Your Gemfile syntax will be compatible with bundler/inline."
                        )
                        .into());
                    }

                    return req
                        // gemfile do_block comes with 'do' and 'end'
                        // we want to omit these by taking slice
                        .get(2..(req.len() - 3))
                        .map(str::to_owned)
                        .ok_or(anyhow!("Invalid gemfile do block"));
                }
            }
        }
    }
    Ok(String::new())
}

View on GitHub (pinned to e474e8803c)

Solutions

  1. Add `require 'windmill/inline'` on its own line (single quotes) at the top of the script before the gemfile block
  2. Note the regex only matches single quotes — use `require 'windmill/inline'`, not `require "windmill/inline"`
  3. If you don't need inline gems, remove the `gemfile do ... end` block and declare dependencies in additionalImports/requirements instead

Example fix

// before
require 'bundler/inline'
gemfile do
  gem 'httparty'
end
// after
require 'bundler/inline'
require 'windmill/inline'
gemfile do
  gem 'httparty'
end
Defensive patterns

Strategy: validation

Validate before calling

// # Ruby-side pre-check you can run before deploying the script:
// has_gemfile = code =~ /^\s*gemfile\s+do/
// has_require  = code =~ /^\s*require\s+'windmill\/inline'/
// if has_gemfile && !has_require
//   raise "add require 'windmill/inline' (single quotes) before the gemfile block"
// end

Try / catch

match parse_ruby_requirements(code) {
    Ok(gemfile) => gemfile,
    Err(e) if e.to_string().contains("windmill/inline") => {
        // actionable user error: surface verbatim, it already contains the fix
        return Err(e);
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: A Ruby script containing `gemfile do ... end` (detected via `require 'bundler/inline'` or gemfile block) but whose source lacks a line matching /^\s*require\s*'windmill\/inline'/.

Common situations: Scripts copied from plain bundler examples that only `require 'bundler/inline'`; users writing `require "windmill/inline"` with double quotes (the regex only matches single quotes); leading whitespace is OK, but `require 'windmill/inline'` placed after the gemfile block or inside a conditional string may still match as long as it is at line start (with optional whitespace) somewhere in the file.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/9b29cd0e721b09c9. Report an issue: GitHub.