Skip to content

fix: list the home directory - #106

Merged
shcheklein merged 1 commit into
mainfrom
fix/home-directory-listing
Nov 30, 2026
Merged

shcheklein merged 1 commit into
mainfrom
fix/home-directory-listing

Conversation

@shcheklein

Copy link
Copy Markdown
Collaborator

sshfs uses "" for the home directory: _strip_protocol("ssh://host") returns "", and relative paths resolve against it. But ls and info sent "" to the server unchanged, and an empty path isn't valid there. OpenSSH's sftp-server fails with ENOENT, so on main:

fs.ls("")              # FileNotFoundError
fs.info("")            # FileNotFoundError
fs.ls("ssh://host")    # FileNotFoundError
fs.find("")            # [] (fsspec's walk swallows the error)

_ls and _info now send "." for "", which servers resolve to the home directory. Listing names stay relative (a.txt), and info("") keeps the name "", so it isn't confused with the root, "/".

Checked against OpenSSH 10.0 in Docker. The test fails on main against the test server too, which rejects "" the same way.

Fixes #105.

🤖 Generated with Claude Code

sshfs uses "" for the home directory, but ls and info sent it to the
server as is, and an empty path isn't valid there: OpenSSH's
sftp-server fails with ENOENT. So ls(""), info("") and
ls("ssh://host") raised FileNotFoundError, and find("") returned
nothing. They now send ".", which servers resolve to the home
directory. Listing names stay relative, and info("") keeps the name ""
so it isn't confused with "/".

Fixes #105.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the SSH home-directory path handling change.

No open issues 🎉

What changed in this PR

Fixes #105 by allowing SSH filesystem operations to access the home directory through an empty path while keeping returned names distinct from the filesystem root.

Changes:

  • Sends "." to the SFTP server for empty paths in _ls and _info.
  • Preserves relative listing names and the empty home-directory name in metadata.
  • Adds regression coverage for empty-path and host-only URL listings, home-directory traversal, and metadata.
File Description
tests/​test_sshfs.py Adds regression tests for home-directory access and returned names.
sshfs/​spec.py Normalizes empty server paths to "." while preserving home-directory naming.

Review effort: Balanced

@shcheklein
shcheklein merged commit 66986e3 into main Nov 30, 2026
11 checks passed
@shcheklein
shcheklein deleted the fix/home-directory-listing branch November 30, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The home directory ("" or "ssh://host") can't be listed

2 participants