dgraph-io/dgraph · error
RDF or JSON file(s) location must be specified
Error message
RDF or JSON file(s) location must be specified
What it means
`dgraph live` requires a data file location via the --files (dataFiles) flag and refuses to start a load with none specified. After the schema is fetched from the Alpha, an empty opt.dataFiles triggers this plain error and aborts the run before any file scanning occurs.
Source
Thrown at dgraph/cmd/live/run.go:780
err := l.processSchemaFile(ctx, opt.schemaFile, opt.key, dg)
if err != nil {
if err == context.Canceled {
fmt.Printf("Interrupted while processing schema file %q\n", opt.schemaFile)
return nil
}
fmt.Printf("Error while processing schema file %q: %s\n", opt.schemaFile, err)
return err
}
fmt.Printf("Processed schema file %q\n\n", opt.schemaFile)
}
if l.schema, err = getSchema(ctx, dg, rootNsOperation); err != nil {
fmt.Printf("Error while loading schema from alpha %s\n", err)
return err
}
if opt.dataFiles == "" {
return errors.New("RDF or JSON file(s) location must be specified")
}
fs := filestore.NewFileStore(opt.dataFiles)
filesList := fs.FindDataFiles(opt.dataFiles, []string{".rdf", ".rdf.gz", ".json", ".json.gz"})
totalFiles := len(filesList)
if totalFiles == 0 {
return errors.Errorf("No data files found in %s", opt.dataFiles)
}
fmt.Printf("Found %d data file(s) to process\n", totalFiles)
errCh := make(chan error, totalFiles)
for _, file := range filesList {
file = strings.Trim(file, " \t")
go func(file string) {
errCh <- errors.Wrap(l.processFile(ctx, fs, file, opt.key), file)
}(file)
}View on GitHub (pinned to 759e242be6)
Solutions
- Pass the data file(s) with --files, e.g. `dgraph live --files data.rdf`
- Fix the shell variable so it expands to the actual RDF/JSON path before invoking dgraph live
- Glob multiple files: `--files "dir/*.rdf"`
Example fix
// before (no data) dgraph live --alpha alpha:9080 --schema schema.txt // after dgraph live --alpha alpha:9080 --schema schema.txt --files ./data.rdf
Defensive patterns
Strategy: validation
Validate before calling
// Validate the files argument before invoking dgraph live
if (!opts.files || opts.files.trim() === '') {
throw new Error('dgraph live requires --files pointing to RDF/JSON data');
} Type guard
function hasDataFilesArg(opts) {
return typeof opts.files === 'string' && opts.files.trim().length > 0;
} Try / catch
try {
await runLive(args);
} catch (e) {
if (String(e.message).includes('RDF or JSON file(s) location must be specified')) {
console.error('Set --files (e.g. --files data.rdf) and re-run');
} else { throw e; }
} Prevention
- Always pass --files in load scripts; fail fast on empty env variables with ${DATA:?}
- Require both --schema and --files in shared wrapper scripts
- Echo the resolved file variable before invoking the CLI
When it happens
Trigger: Running `dgraph live` without the --files flag; passing an empty string for --files (e.g. --files "" in a script where a variable failed to expand).
Common situations: Shell scripts where $DATA_FILE is unset/empty; interactive users who only passed --schema (schema alone is not enough); CI pipelines where an artifact path variable is missing.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Cannot load into namespace %#x. It does not exist.
- No data files found in %s
- Key size value is too large (x > 4096)
- Key size value must be a factor of 2
- Elliptic curve value must be one of: P224, P256, P384 or P52
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/af88080e361ab827.
Report an issue: GitHub.