facebook/relay · error
Failed to run locate command: {}
Error message
Failed to run locate command: {} What it means
resolve_field_definition spawns the configured locate_command with project_name and entity_name as arguments. If the process cannot be spawned or awaited (binary missing, not executable, IO error), the error is wrapped with this 'Failed to run locate command: {}' message and returned as a string error.
Source
Thrown at compiler/crates/relay-bin/src/main.rs:625
}
fn resolve_field_definition(
&self,
project_name: String,
parent_type: String,
field_info: Option<FieldSchemaInfo>,
) -> Result<Option<FieldDefinitionSourceInfo>, String> {
let entity_name = match field_info {
Some(field_info) => format!("{}.{}", parent_type, field_info.name),
None => parent_type,
};
let result = Command::new(&self.locate_command)
.arg(project_name)
.arg(entity_name)
.output()
.map_err(|e| format!("Failed to run locate command: {}", e))?;
let result = String::from_utf8(result.stdout).expect("Failed to parse output");
// Parse file_path:line_number:column_number
let result_trimmed = result.trim();
let result = result_trimmed.split(':').collect::<Vec<_>>();
if result.len() != 3 {
return Err(format!(
"Result '{}' did not match expected format. Please return 'file_path:line_number:column_number'",
result_trimmed
));
}
let file_path = result[0];
let line_number = result[1].parse::<u64>().unwrap() - 1;
let column_number = result[2].parse::<u64>().unwrap_or(1_u64) - 1;
Ok(Some(FieldDefinitionSourceInfo {
file_path: file_path.to_string(),
line_number,
column_number,View on GitHub (pinned to 668b1b85e0)
Solutions
- Verify the locate command exists and runs: run it manually with the same two arguments
- Make the script executable (chmod +x) and give it a proper shebang
- Use an absolute path for the command in the relay config
- Check PATH in the environment that launches relay (IDE-integrated terminals often differ)
Example fix
// before (relay config) "locateCommand": "scripts/find-field" // after (absolute, executable) "locateCommand": "/absolute/path/to/scripts/find-field" # + chmod +x
Defensive patterns
Strategy: validation
Validate before calling
const { execFileSync } = require('child_process');
function assertLocateRunnable(cmd, ...args) {
try { execFileSync(cmd, args, { stdio: 'ignore' }); }
catch (e) {
if (e.code === 'ENOENT') throw new Error(`Locate command not found: ${cmd}`);
}
} Try / catch
try {
resolveFieldDefinition(project, entity);
} catch (e) {
if (/Failed to run locate command/.test(e.message)) {
console.error('Ensure the locate binary exists, is executable, and is on PATH.');
} else throw e;
} Prevention
- Use absolute paths for the locate command in relay config
- chmod +x and shebang-check custom scripts
- Verify PATH in IDE/CI launch environments
- Smoke-test the command with the same arguments relay passes
When it happens
Trigger: Calling the field-resolution feature when locate_command points to a non-existent binary, lacks execute permission, or the OS refuses to fork/exec.
Common situations: Configured locate tool not installed on the machine; script path relative to a different working directory; missing shebang or +x bit; PATH differences in editors/IDEs launching relay.
Related errors
- failed to execute process. Make sure you have Node installed
- Result '{}' did not match expected format. Please return 'fi
- Platform "${process.platform} (${process.arch})" not support
- Relay Environment Configuration Error (dev only): `@required
- No Relay config found from current directory. Pass --config
AI-assisted analysis of facebook/relay@668b1b85e0 (2026-09-02).
Data as JSON: /api/errors/145f879aa72bc146.
Report an issue: GitHub.