Understanding SVN Path Differences: svn:// vs svn+ssh:// Protocol Behavior and Solutions


2 views

When working with Subversion repositories, I recently encountered a puzzling behavior difference between svn:// and svn+ssh:// protocols. The repository that worked perfectly with:

svn co svn://svn-user@domain.com/test-repo

Failed when using SSH:

svn co svn+ssh://svn-user@putty-session-name/test-repo
# Returns: 'No repository found...'

The key difference lies in how each protocol handles repository path resolution:

  • svn://: Uses the path relative to the SVN root directory specified in svnserve (-r /srv/svn in this case)
  • svn+ssh://: Requires the full filesystem path to the repository

The correct syntax for svn+ssh access needs to include the full repository path:

svn co svn+ssh://svn-user@putty-session-name/srv/svn/test-repo

This behavior occurs because:

  1. The svnserve daemon is configured with -r /srv/svn, making it the root for svn:// protocol
  2. SSH connections bypass svnserve and access files directly, requiring absolute paths

For consistent access, consider these alternatives:

# Alternative 1: Symlink approach
ln -s /srv/svn/test-repo /home/svn-user/test-repo
svn co svn+ssh://svn-user@putty-session-name/home/svn-user/test-repo

# Alternative 2: SSH config tweak
Host svn-server
    HostName actual.server.name
    User svn-user
    RemoteCommand cd /srv/svn && svnserve -t
  • Document protocol-specific access methods for your team
  • Standardize on either full paths or symlinks
  • Consider using svn info to verify repository URLs

When working with Subversion repositories, developers often encounter path resolution differences between the svn:// and svn+ssh:// protocols. Here's what's happening:

# This works (svn protocol):
svn co svn://svn-user@domain.com/test-repo

# This fails (ssh protocol):
svn co svn+ssh://svn-user@/test-repo
# Error: No repository found

The fundamental difference lies in how each protocol handles repository path resolution:

  • svn://: Uses the path relative to the -r parameter specified in svnserve
  • svn+ssh://: Requires the full filesystem path to the repository

Given the server configuration:

svnserve -d -r /srv/svn

The correct checkout commands would be:

# svn protocol (relative to -r path):
svn co svn://server/test-repo

# ssh protocol (absolute path required):
svn co svn+ssh://user@server/srv/svn/test-repo

For consistent behavior across protocols, consider these approaches:

# Option 1: Use consistent absolute paths
svn co svn+ssh://user@server/$(svn info svn://server/test-repo | grep '^Repository Root' | cut -d' ' -f3)/test-repo

# Option 2: Create symlinks for ssh access
ln -s /srv/svn /home/svn-user/repos
svn co svn+ssh://user@server/home/svn-user/repos/test-repo

When troubleshooting path issues:

# Check svnserve process:
ps aux | grep svnserve

# Verify repository permissions:
ls -ld /srv/svn/test-repo

# Test SSH access:
ssh user@server ls -l /srv/svn/test-repo
  • Document your protocol-specific paths in team documentation
  • Consider standardizing on one protocol for all team members
  • Use SSH config aliases to simplify long paths
# ~/.ssh/config example:
Host svn-server
  HostName server.domain.com
  User svn-user
  IdentityFile ~/.ssh/svn-key

# Usage:
svn co svn+ssh://svn-server/srv/svn/test-repo