Skip to content

Conversation

@mafredri
Copy link
Member

@mafredri mafredri commented Dec 9, 2025

When a workspace agent has a configured directory, SSH sessions and rsync land there, but SFTP/SCP land in $HOME. This means rsync file.txt coder:. and scp file.txt coder:. put the file in different places, which is confusing.

The SFTP handler was hardcoded to use the home directory instead of checking the configured working directory like SSH does. Now it checks the config first and falls back to home only if unset.

Previously, SFTP connections always landed in the user's home directory,
ignoring the agent's configured working directory. This was inconsistent
with SSH sessions and rsync, which respected the configured directory.

Now SFTP connections use the same logic: check the configured working
directory first, falling back to home directory only when not set.
@mafredri
Copy link
Member Author

mafredri commented Dec 9, 2025

We could consider tagging this change breaking.

Copy link
Contributor

I agree it's inconsistent, but I do worry about this being a breaking change.

We had to modify Mutagen for Coder Desktop to fix it's assumption that ssh always lands in the home directory on Coder. I think we also fixed Mutagen so that we explicitly set the directory on scp, but it's an indication of how deeply entrenched the assumption that scp is relative to the home directory is in practice.

The RFC says it is "usually" the home directory, but leaves room for it to be something else.

If we merge this we could find that scripts that scp stuff to Coder workspaces start breaking for our customers.

Is there some particularly compelling reason we need this?

@mafredri
Copy link
Member Author

I agree it's inconsistent, but I do worry about this being a breaking change.

That's fair. If we do it, we should flag it with ! and call it out clearly in the changelog so nobody gets blindsided.

We had to modify Mutagen for Coder Desktop to fix it's assumption that ssh always lands in the home directory on Coder. I think we also fixed Mutagen so that we explicitly set the directory on scp, but it's an indication of how deeply entrenched the assumption that scp is relative to the home directory is in practice.

To me this actually argues in favor of fixing this. Tooling shouldn't need to patch around our quirks. If people integrating with Coder end up hitting the same gotcha over and over, that's a sign the behavior is surprising and worth correcting.

The RFC says it is "usually" the home directory, but leaves room for it to be something else.

Since it's not guaranteed, it leaves room for us to make the behavior match the rest of our SSH flow. That feels like supporting evidence, not a blocker.

If we merge this we could find that scripts that scp stuff to Coder workspaces start breaking for our customers.

This is a real risk. The question is how common the pattern actually is.

For breakage to happen, all of these have to line up:

  1. The template author changed coder_agent.directory from the default
  2. The user is scripting or automating against the workspace
  3. They prefer scp over something like rsync
  4. Their scp usage relies on relative remote paths

It's possible, but the overlap seems small.

Is there some particularly compelling reason we need this?

Consistency and meeting expectations. We understand the system better than most users, yet we trip over this internally (mutagen, I in everyday use, etc.). Customers won't have that context. If two similar commands land files in different places depending on the tool, that's a problem.

The SSH directory change was added in 8701e00, but when sftp was fixed, that behavior was overlooked (173b7a2).

Copy link
Contributor

For me the Mutagen thing is an argument to drop the whole coder_agent.directory feature, and always use the home directory for everything. It's a "foot gun" that IMO doesn't really add much value.

But, I do take your point that if we take as given that feature won't be going away, having consistency between shells and SFTP is better than inconsistency.

You can mark me down as in favor of making the breaking change, but we absolutely need to call it out in the release notes. cc @david-fraley

@spikecurtis spikecurtis changed the title fix(agent/agentssh): use configured directory for SFTP connections !fix(agent/agentssh): use configured directory for SFTP connections Dec 12, 2025
@spikecurtis spikecurtis changed the title !fix(agent/agentssh): use configured directory for SFTP connections fix(agent/agentssh)<breaking>!: use configured directory for SFTP connections Dec 12, 2025
@github-actions github-actions bot added the release/breaking This label is applied to PRs to detect breaking changes as part of the release process label Dec 12, 2025
@spikecurtis spikecurtis changed the title fix(agent/agentssh)<breaking>!: use configured directory for SFTP connections fix(agent/agentssh)!: use configured directory for SFTP connections Dec 12, 2025
@mafredri
Copy link
Member Author

For me the Mutagen thing is an argument to drop the whole coder_agent.directory feature, and always use the home directory for everything. It's a "foot gun" that IMO doesn't really add much value.

I very much agree 👍🏻. I don't see us removing the feature, but we could perhaps discourage its use in the terraform documentation (or note that it introduces non-standard behavior).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release/breaking This label is applied to PRs to detect breaking changes as part of the release process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants