doomemacs / doomemacs/core

(Documentation error) Upload (ssh-deploy) relative path gets broken following the example in the document

Open
#7,271 0 comments 0 reactions 0 assignees View on GitHub
is:bug needs-triage
Dominant language
Emacs Lisp
Stars
22.7k
Forks
3.1k
Avg merge
10h 46m
Merged PRs (30d)
4

Description

### I confirm that...

- [X] I have searched the [issue tracker](https://github.com/doomemacs/doomemacs/issues), [documentation](https://docs.doomemacs.org), [FAQ](https://docs.doomemacs.org/-/faq), [Discourse](https://discourse.doomemacs.org), and [Google](https://google.com), in case this issue has already been reported/resolved.

- [X] I have read "[How to Debug Issues](https://doomemacs.org/d/how2debug)", and will use it to provide as much information about this issue as possible.

- [X] The issue can be reproduced on the **latest** available commit of Doom.

- [X] The issue can be reproduced on a stable release of Emacs, such as 27 or 28. *(Doom does not support development builds like 29+ or any version ending in .50 or .9x)*

### Expected behavior

The expanded path should be relative to the remote root path, but it may lose root path following the example in the document. It's not a software bug, but just document bug.

Here is the expected documentation and what happens. Notice the "/" suffix in the local root.

```
((nil . ((ssh-deploy-root-local . "/local/path/to/example-project/") ;; Notice the "/" suffix
(ssh-deploy-root-remote . "/ssh:user@server:/remote/example-project/")
```

With "/" suffix like the the above example, relative path is obtained properly without "/" prefix.

```
(ssh-deploy--get-relative-path "/local/path/to/example-project/" "/local/path/to/example-project/rel/path.el")
=> "rel/path.el"
```

```
(expand-file-name "rel/path.el" "/ssh:user@server:/remote/example-project/")
=> "/ssh:user@server:/remote/example-project/rel/path.el"
```

This is the correct remote path.

The actual code in `ssh-deploy` looks like the following.
```
(expand-file-name (ssh-deploy--get-relative-path root-local path-local) root-remote)
```

### Current behavior

But the current documents demonstrates as the following. It does not have "/" suffix at the end of the local root directory and that makes a problem that it may break (ignore) remote root directory setting and write to root directory.

```
((nil . ((ssh-deploy-root-local . "/local/path/to/example-project")
(ssh-deploy-root-remote . "/ssh:user@server:/remote/example-project/")
```

Notice that "/local/path/to/example-project" does not end with "/". In that case, the relative path will have "/" prefix.

```
(ssh-deploy--get-relative-path "/local/path/to/example-project" "/local/path/to/example-project/rel/path.el")
"/rel/path.el"
```

Now expand the path and see what happens.

```
(expand-file-name "/rel/path.el" "/ssh:user@server:/remote/example-project/")
=> "/rel/path.el"
```
This is wrong. Since it has prefix "/", it ignores the relative path (remote root) in this case. So it shouldn't have the prefix.

Not putting "/" at the end can make a disaster and it can be difficult to debug.

I guess the troubleshooting section is misleading. Maybe the actual mistake was not putting "/" suffix.

### Steps to reproduce

Explained with code evaluation above.

### System Information

https://pastebin.com/MuSjKTtU

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.