Files cannot be deleted because they’re locked by another process.
Symptoms
Errno::EACCES: Permission denied
Solution
Excavate handles this automatically with retries:
# Excavate retries up to 5 times with 0.2s delaysExcavate::Archive.new('archive.zip').filesdo|path|# Files are cleaned up even if lockedend
If still failing:
# Wait and retry manuallydefsafe_delete(path)5.timesdobeginFileUtils.rm_rf(path)returntruerescueErrno::EACCESsleep0.5endendfalseend
Long Paths
Problem
Windows has a 260 character path limit.
Symptoms
Filename too long
Solution
Use shorter target paths:
# Use short temp pathtarget=Dir.mktmpdir('e-')# Short prefix# Instead of long nested path# target = 'C:/Users/username/Documents/projects/output'
Path Separators
Problem
Mixed path separators cause issues.
Solution
Excavate handles this, but be consistent:
# Use forward slashes (Ruby handles conversion)target='C:/temp/output'# Or use File.jointarget=File.join('C:','temp','output')
macOS
Permission Denied
Problem
Cannot write to system directories.
Solution
Use user-writable locations:
# Use user directorytarget=File.expand_path('~/Downloads/output')# Or temp directorytarget=Dir.mktmpdir
Quarantine
Problem
Downloaded files may be quarantined.
Solution
Remove quarantine attribute:
xattr -d com.apple.quarantine archive.zip
Linux
No Special Issues
Linux generally works without platform-specific issues.
Container Environments
In Docker or other containers:
Ensure sufficient disk space
Check /tmp is writable
Verify file permissions
Cross-Platform Tips
Use Pathname
require'pathname'# Works on all platformstarget=Pathname.new('/path/to/output')archive=Excavate::Archive.new(Pathname.new('/path/to/archive.zip'))archive.extract(target)
defwritable?(path)File.writable?(File.dirname(path))endunlesswritable?(target)raise"Cannot write to target directory"end
Character Encoding
Problem
Non-ASCII characters in filenames cause issues.
Solution
# Handle encoding issuesarchive.filesdo|path|begin# Try to read with UTF-8content=File.read(path,encoding: 'UTF-8')rescueEncoding::InvalidByteSequenceError# Fall back to binarycontent=File.binread(path)endend
Case Sensitivity
Problem
File systems differ in case sensitivity.
Linux: Case-sensitive
macOS: Case-insensitive (usually)
Windows: Case-insensitive
Solution
Use consistent case:
# Use downcase for comparisonifpath.downcase.end_with?('.txt')# ...end