{"record":{"id":"394b16ca5325821e","repo":"presidentbeef/brakeman","slug":"please-supply-the-path-to-a-rails-application-loo","errorCode":null,"errorMessage":"Please supply the path to a Rails application (looking in #{@app_tree.root}).\n  Use `--force` to run a scan anyway.","messagePattern":"Please supply the path to a Rails application \\(looking in #(.+?)\\)\\.\n  Use `--force` to run a scan anyway\\.","errorType":"exception","errorClass":"Brakeman::NoApplication","httpStatus":null,"severity":"error","filePath":"lib/brakeman/scanner.rb","lineNumber":30,"sourceCode":"  $stderr.puts e.message\n  $stderr.puts \"Please install the appropriate dependency.\"\n  exit(-1)\nend\n\n#Scans the Rails application.\nclass Brakeman::Scanner\n  attr_reader :options\n\n  #Pass in path to the root of the Rails application\n  def initialize options, processor = nil\n    @options = options\n    @app_tree = Brakeman::AppTree.from_options(options)\n\n    if (!@app_tree.root || !@app_tree.exists?(\"app\")) && !options[:force_scan]\n      message = \"Please supply the path to a Rails application (looking in #{@app_tree.root}).\\n\" <<\n                \"  Use `--force` to run a scan anyway.\"\n\n      raise Brakeman::NoApplication, message\n    end\n\n    @processor = processor || Brakeman::Processor.new(@app_tree, options)\n  end\n\n  #Returns the Tracker generated from the scan\n  def tracker\n    @processor.tracked_events\n  end\n\n  def file_cache\n    tracker.file_cache\n  end\n\n  def process_step(description, &)\n    Brakeman.process_step(description, &)\n  end\n","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/presidentbeef/brakeman/blob/649e678d0a46bda0e7c35874fa7af5d16e19b4f1/lib/brakeman/scanner.rb#L12-L48","documentation":"At startup, `Brakeman::Scanner` builds an `AppTree` from the given path and requires the target to look like a Rails application: a root that contains an `app/` directory. If no usable root is found or `app/` is missing, and `--force` was not passed, it raises `Brakeman::NoApplication` with this guidance message instead of scanning something that would yield meaningless results.","triggerScenarios":"Running `brakeman` in a directory that is not a Rails app root: the repo root of a monorepo where the Rails app lives in a subdirectory; a subfolder of the app (e.g. `app/` or `config/` itself); passing a wrong path argument; a project using a nonstandard layout without an `app/` directory.","commonSituations":"Monorepos where CI's default working directory is the repository root, not the Rails app; scanning Rails engines or gems that only contain `lib/`; directory structures with `app` renamed or mounted elsewhere; typos in the path argument in CI job definitions.","solutions":["Point Brakeman at the actual Rails root: `brakeman ~/work/monorepo/services/web` or cd into the app directory first.","If the target genuinely has no `app/` but you still want a scan (e.g. an engine or plain Ruby with ERB templates), opt in explicitly with `--force`.","In CI, set the job's working directory (e.g. `defaults.run.working-directory` in GitHub Actions) to the Rails app path so bare `brakeman` invocations resolve correctly."],"exampleFix":"# before (run from monorepo root, Rails app is nested)\nbrakeman   # => Brakeman::NoApplication: Please supply the path to a Rails application...\n\n# after (scan the actual Rails root)\nbrakeman services/web\n# or force a scan of a non-standard tree\nbrakeman --force","handlingStrategy":"validation","validationCode":"# Ruby, check Rails-app shape before scanning\npath = ENV['RAILS_ROOT'] || Dir.pwd\nunless File.directory?(File.join(path, 'app'))\n  abort \"#{path} is not a Rails app root (no app/ directory). Pass the Rails root or use --force.\"\nend\nBrakeman.run :app_path => path","typeGuard":null,"tryCatchPattern":"begin\n  Brakeman.run :app_path => path\nrescue Brakeman::NoApplication\n  # Non-standard layout: opt in to a forced scan\n  Brakeman.run :app_path => path, :force_scan => true\nend","preventionTips":["Invoke brakeman from the Rails app root, and in CI set the job's working directory to that root (monorepos especially).","For engines or app-less trees, make `--force` an explicit, documented decision rather than a reflex.","Gate wrapper scripts with a File.directory?(File.join(path, 'app')) check to fail fast with a clearer message."],"tags":["brakeman","rails","app-detection","scan-setup","cli","monorepo"],"backgroundTag":"rails-app-not-detected","analyzedSha":"649e678d0a46bda0e7c35874fa7af5d16e19b4f1","analyzedAt":"2026-08-21T18:43:10.938Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}