getredash/redash · error · IOError
Script '{}' not found in script directory
Error message
Script '{}' not found in script directory What it means
Raised by query_to_script_path (redash/query_runner/script.py:11) as IOError when the scripts directory is a fixed configured path (not '*') and the first token of the query does not correspond to an existing file under that directory. The runner maps the first whitespace-delimited word of the query to a script filename, so any name not present on disk fails here before execution.
Source
Thrown at redash/query_runner/script.py:11
import os
import subprocess
from redash.query_runner import BaseQueryRunner, register
def query_to_script_path(path, query):
if path != "*":
script = os.path.join(path, query.split(" ")[0])
if not os.path.exists(script):
raise IOError("Script '{}' not found in script directory".format(query))
return os.path.join(path, query).split(" ")
return query
def run_script(script, shell):
output = subprocess.check_output(script, shell=shell)
if output is None:
return None, "Error reading output"
output = output.strip()
if not output:
return None, "Empty output from script"
return output, None
View on GitHub (pinned to ca79fe988d)
Solutions
- List the configured scripts directory on the Redash server and confirm the exact filename of the first query token (case-sensitive)
- Fix the saved query's first word to match the script filename, or restore/redeploy the missing script
- Verify the Scripts directory setting on the data source matches where scripts actually live
Example fix
# before # query: my_scritp.py arg1 (typo) # after # query: my_script.py arg1
Defensive patterns
Strategy: validation
Validate before calling
import os
first = query.split(' ')[0]
script_path = os.path.join(scripts_dir, first)
if not os.path.exists(script_path):
return None, "Script '{}' not found in {}".format(first, scripts_dir) Try / catch
try:
run_query(q, user)
except IOError as e:
return error_response(404, str(e)) Prevention
- Pin the scripts directory in config management and deploy scripts there atomically
- Name saved queries after exact script filenames; add a CI check that referenced scripts exist
- Expose a listing endpoint or README of available scripts for query authors
When it happens
Trigger: Running a Script data source query whose first word names a script that was renamed, deleted, never deployed, or contains a typo; also when the Redash server's configured scripts directory differs from where the script was placed.
Common situations: Scripts deployed to /opt/redash/scripts locally but the configured path points elsewhere; script renamed without updating saved queries; leading whitespace/formatting making the first token something unexpected.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Scripts can only be run from the configured scripts director
- Invalid JWT token
- Error during query execution. Reason: {error}
- Failed running query [%s].
- Username and Password required
AI-assisted analysis of getredash/redash@ca79fe988d (2026-08-28).
Data as JSON: /api/errors/558021604bb89a08.
Report an issue: GitHub.