Resolving “svn: Can’t find a temporary directory: Internal error” – SVN TMPDIR Configuration & Network Path Analysis


4 views

This SVN error typically occurs when the system cannot locate a valid temporary directory for storing working copy metadata during operations. The key diagnostic elements in this case are:

  • Available disk space (confirmed sufficient at 4% of 150GB)
  • Empty $TMPDIR environment variable response
  • Inconsistent behavior across different client machines
  • IP-based vs hostname-based server connections

First verify the temporary directory situation on both client and server:


# Check existing temp directories
ls -ld /tmp /var/tmp ~/tmp

# Test SVN with explicit temp directory
TMPDIR=/custom/tmp svn diff https://svn.example.com/repo

# Alternative test using mktemp
if ! mktemp -d; then
  echo "System temp directory creation failed"
fi

The IP vs hostname discrepancy suggests potential authentication or path resolution issues:


# Compare network paths
traceroute 192.168.1.100
traceroute svn.example.com

# Test basic connectivity
curl -I http://192.168.1.100/svn/repo
curl -I http://svn.example.com/svn/repo

Permanent fixes involve environment configuration:


# For bash users (~/.bashrc)
export TMPDIR=${TMPDIR:-/tmp}
export SVN_TMPDIR=$TMPDIR

# For systemd services (/etc/systemd/system/svnserve.service)
[Service]
Environment="TMPDIR=/var/tmp/svn"
Environment="SVN_TMPDIR=/var/tmp/svn"

To salvage the problematic working copy without full checkout:


# Backup first
rsync -a --delete working_copy/ working_copy.backup/

# Clean and reset
svn cleanup --remove-tmpfiles
svn revert -R .

For persistent issues, enable verbose logging:


SVN_DEBUG_SVN_SSH=1 svn --verbose --debug diff \
  --config-option config:tunnels:ssh=$SVN_SSH \
  --config-option servers:global:http-timeout=60

Implement these in your deployment scripts:


#!/bin/bash
# Ensure temp directory exists
SVN_TEMP_DIR="${HOME}/.svn_temp"
mkdir -p "$SVN_TEMP_DIR" && chmod 700 "$SVN_TEMP_DIR"

# Set environment for all SVN operations
export TMPDIR="$SVN_TEMP_DIR"
export SVN_TMPDIR="$SVN_TEMP_DIR"
alias svn="TMPDIR=\"$SVN_TEMP_DIR\" command svn"

When Subversion (SVN) clients fail to locate a temporary directory, it typically indicates environment variable misconfiguration. The key symptom is an empty response when running:

echo $TMPDIR

On Unix-like systems, SVN follows this directory search order:

  1. Explicit $TMPDIR environment variable
  2. /tmp
  3. /var/tmp
  4. Current working directory

To test and set the variable:

# Verify current settings
env | grep TMP

# Set temporary directory (bash/zsh)
export TMPDIR=/path/to/your/tmp
echo "export TMPDIR=/path/to/your/tmp" >> ~/.bashrc

IP-based access versus hostname resolution can trigger different environment behaviors. This manifests particularly when:

  • DNS resolution differs for IP vs hostname
  • SSH config sets different environment variables
  • Proxy settings vary between connection methods

Try these steps before abandoning your working copy:

# Reset SVN properties
svn cleanup
svn upgrade

# Recreate metadata
find . -name '.svn' -type d -exec rm -rf {} \;
svn update --force

For administrators, check these server configurations:

# Verify disk permissions
df -h
ls -ld /tmp

# Check SELinux contexts (RHEL/CentOS)
ls -Z /tmp
restorecon -Rv /tmp

Enable verbose logging to pinpoint the failure:

svn diff --verbose --config-option config:tunnels:ssh="ssh -vvv"

Look for these key indicators in output:

  • Temporary file creation attempts
  • Permission denied errors
  • Authentication context switches