pentaho/pentaho-kettle · error · RuntimeException
file to copy [
Error message
file to copy [
What it means
The copyFile() script helper throws 'file to copy [name] can not be found!' when the SOURCE file resolved via KettleVFS does not exist. The existence check happens before any copying; destination checks and overwrite logic are never reached.
Solutions
- Check fileExists(src) before calling copyFile and handle absence explicitly.
- Fix the source path (absolute path, correct casing and separators).
- Re-order the transformation/job so the source file is created before the copy runs.
- Verify any earlier 'Move/Delete' or cleanup steps are not removing the file prematurely.
Example fix
// before
copyFile('data/in.csv', 'data/backup.csv', true); // in.csv not produced yet
// after
if (fileExists('data/in.csv')) { copyFile('data/in.csv', 'data/backup.csv', true); } else { throw new Error('input missing'); } Defensive patterns
Strategy: validation
Validate before calling
if (!fileExists(src)) { throw new Error('source file missing: ' + src); }
copyFile(src, dest, true); Type guard
function isNonEmptyString(s) { return typeof s === 'string' && s.trim().length > 0; } Try / catch
try { copyFile(src, dest, true); } catch (e) { if (String(e).indexOf('can not be found') >= 0) { /* handle missing input */ } else { throw e; } } Prevention
- Check source existence before copying
- Order steps so producers run before copiers
- Use absolute, OS-correct paths
When it happens
Trigger: Calling copyFile(src, dest, overwrite) where src does not exist: wrong path, file not yet produced by an earlier step, relative path resolving against an unexpected working directory, or case mismatch on Linux.
Common situations: Copy step runs before the producing step/transform finished (ordering problem); typos in the source path; the previous run's cleanup deleted the file; expected input file missing from a watched directory.
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
- file [
- The function call copyFile throw an error :
- AbstractFileErrorHandler.Exception.CouldNotCreateFileErrorHandlerForFile
- AvroInput.Error.SchemaError
- AvroInputDialog.Error.KettleFileException
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/ce3806935dc3e198.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:2053
// Destination filename
fileDestination = KettleVFS.getInstance( bowl ).getFileObject( (String) ArgList[1] );
if ( fileSource.exists() ) {
// Source file exists...
if ( fileSource.getType() == FileType.FILE ) {
// Great..source is a file ...
boolean overwrite = false;
if ( !ArgList[1].equals( null ) ) {
overwrite = (Boolean) ArgList[2];
}
boolean destinationExists = fileDestination.exists();
// Let's copy the file...
if ( ( destinationExists && overwrite ) || !destinationExists ) {
FileUtil.copyContent( fileSource, fileDestination );
}
}
} else {
throw new RuntimeException( "file to copy [" + ArgList[0] + "] can not be found!" );
}
} catch ( IOException e ) {
throw new RuntimeException( "The function call copyFile throw an error : " + e.toString() );
} finally {
if ( fileSource != null ) {
try {
fileSource.close();
} catch ( Exception e ) {
// Ignore errors
}
}
if ( fileDestination != null ) {
try {
fileDestination.close();
} catch ( Exception e ) {
// Ignore errors
}
}View on GitHub (pinned to f3058517a1)