Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fails to write files that are relative symlinks that don't resolve from cwd #10732

Closed
nekopsykose opened this issue May 11, 2024 · 5 comments · Fixed by #10790
Closed

fails to write files that are relative symlinks that don't resolve from cwd #10732

nekopsykose opened this issue May 11, 2024 · 5 comments · Fixed by #10790
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@nekopsykose
Copy link
Contributor

nekopsykose commented May 11, 2024

Summary

probably since 6d363a9 but i didn't bisect (i remember updating around those commits and just didn't report it until now)

Reproduction Steps

I tried this:

$ mkdir a
$ echo 123 > a/b
$ mkdir b
$ ln -s ../a/b b/c
$ hx b/c

I expected this to happen:

it can write to the file at symlink target fine.

Instead, this happened:

No such file or directory (os error 2)

Helix log

-vv --log /tmp/x.log
2024-05-11T20:15:42.746 globset [DEBUG] glob converted to regex: Glob { glob: "*/Dockerfile.*", re: "(?-u)^.*/Dockerfile\\..*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('D'), Literal('o'), Literal('c'), Literal('k'), Literal('e'), Literal('r'), Literal('f'), Literal('i'), Literal('l'), Literal('e'), Literal('.'), ZeroOrMore]) }
2024-05-11T20:15:42.746 globset [DEBUG] glob converted to regex: Glob { glob: "*/dockerfile.*", re: "(?-u)^.*/dockerfile\\..*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('d'), Literal('o'), Literal('c'), Literal('k'), Literal('e'), Literal('r'), Literal('f'), Literal('i'), Literal('l'), Literal('e'), Literal('.'), ZeroOrMore]) }
2024-05-11T20:15:42.746 globset [DEBUG] glob converted to regex: Glob { glob: "*/Containerfile.*", re: "(?-u)^.*/Containerfile\\..*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('C'), Literal('o'), Literal('n'), Literal('t'), Literal('a'), Literal('i'), Literal('n'), Literal('e'), Literal('r'), Literal('f'), Literal('i'), Literal('l'), Literal('e'), Literal('.'), ZeroOrMore]) }
2024-05-11T20:15:42.746 globset [DEBUG] glob converted to regex: Glob { glob: "*/containerfile.*", re: "(?-u)^.*/containerfile\\..*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('c'), Literal('o'), Literal('n'), Literal('t'), Literal('a'), Literal('i'), Literal('n'), Literal('e'), Literal('r'), Literal('f'), Literal('i'), Literal('l'), Literal('e'), Literal('.'), ZeroOrMore]) }
2024-05-11T20:15:42.746 globset [DEBUG] glob converted to regex: Glob { glob: "*/.*ignore", re: "(?-u)^.*/\\..*ignore$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('.'), ZeroOrMore, Literal('i'), Literal('g'), Literal('n'), Literal('o'), Literal('r'), Literal('e')]) }
2024-05-11T20:15:42.746 globset [DEBUG] glob converted to regex: Glob { glob: "*/BUILD.*", re: "(?-u)^.*/BUILD\\..*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('B'), Literal('U'), Literal('I'), Literal('L'), Literal('D'), Literal('.'), ZeroOrMore]) }
2024-05-11T20:15:42.746 globset [DEBUG] glob converted to regex: Glob { glob: "*/.env.*", re: "(?-u)^.*/\\.env\\..*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('.'), Literal('e'), Literal('n'), Literal('v'), Literal('.'), ZeroOrMore]) }
2024-05-11T20:15:42.746 globset [DEBUG] glob converted to regex: Glob { glob: "*/.envrc.*", re: "(?-u)^.*/\\.envrc\\..*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('.'), Literal('e'), Literal('n'), Literal('v'), Literal('r'), Literal('c'), Literal('.'), ZeroOrMore]) }
2024-05-11T20:15:42.746 globset [DEBUG] glob converted to regex: Glob { glob: "*/conf/*/*.{inc,conf}", re: "(?-u)^.*/conf/.*/.*\\.(?:conf|inc)$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('c'), Literal('o'), Literal('n'), Literal('f'), Literal('/'), ZeroOrMore, Literal('/'), ZeroOrMore, Literal('.'), Alternates([Tokens([Literal('c'), Literal('o'), Literal('n'), Literal('f')]), Tokens([Literal('i'), Literal('n'), Literal('c')])])]) }
2024-05-11T20:15:42.746 globset [DEBUG] glob converted to regex: Glob { glob: "*/Jenkinsfile.*", re: "(?-u)^.*/Jenkinsfile\\..*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('J'), Literal('e'), Literal('n'), Literal('k'), Literal('i'), Literal('n'), Literal('s'), Literal('f'), Literal('i'), Literal('l'), Literal('e'), Literal('.'), ZeroOrMore]) }
2024-05-11T20:15:42.746 globset [DEBUG] built glob set; 1 literals, 0 basenames, 0 extensions, 0 prefixes, 103 suffixes, 8 required extensions, 10 regexes
2024-05-11T20:15:42.749 helix_view::clipboard [DEBUG] Using wl-copy+wl-paste to interact with the system and selection (primary) clipboard
2024-05-11T20:15:42.749 helix_vcs [DEBUG] Error {
    context: "failed to open git repo",
    source: Discover(
        NoGitRepository {
            path: "/tmp/mytemp.ktkpQT/b",
        },
    ),
}
2024-05-11T20:15:42.749 helix_vcs [DEBUG] failed to open diff base for /tmp/mytemp.ktkpQT/b/c
2024-05-11T20:15:42.749 helix_vcs [DEBUG] Error {
    context: "failed to open git repo",
    source: Discover(
        NoGitRepository {
            path: "/tmp/mytemp.ktkpQT/b",
        },
    ),
}
2024-05-11T20:15:42.749 helix_vcs [DEBUG] failed to obtain current head name for /tmp/mytemp.ktkpQT/b/c
2024-05-11T20:15:42.749 helix_view::editor [DEBUG] editor status: Loaded 1 file.
2024-05-11T20:15:42.749 helix_tui::backend::crossterm [DEBUG] The keyboard enhancement protocol is supported in this terminal (checked in 35.768µs)
2024-05-11T20:15:42.749 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-05-11T20:15:42.749 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-05-11T20:15:42.950 helix_term::application [DEBUG] received editor event: IdleTimer
2024-05-11T20:15:43.086 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-05-11T20:15:43.086 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-05-11T20:15:43.190 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-05-11T20:15:43.190 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-05-11T20:15:43.230 helix_view::document [DEBUG] submitting save of doc 'Some("/tmp/mytemp.ktkpQT/b/c")'
2024-05-11T20:15:43.230 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-05-11T20:15:43.230 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-05-11T20:15:43.230 helix_term::application [DEBUG] received editor event: DocumentSaved(Err(No such file or directory (os error 2)))
2024-05-11T20:15:43.230 helix_view::editor [DEBUG] editor error: No such file or directory (os error 2)
2024-05-11T20:15:43.230 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-05-11T20:15:43.230 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-05-11T20:15:43.287 helix_term::application [DEBUG] received editor event: IdleTimer
2024-05-11T20:15:43.446 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-05-11T20:15:43.446 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-05-11T20:15:43.566 helix_term::commands::typed [DEBUG] quitting...
2024-05-11T20:15:43.566 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-05-11T20:15:43.566 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-05-11T20:15:43.606 helix_term::commands::typed [DEBUG] quitting...
2024-05-11T20:15:43.606 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-05-11T20:15:43.606 helix_term::job [DEBUG] waiting on jobs...
2024-05-11T20:15:43.606 helix_term::job [DEBUG] waiting on jobs...

Platform

Linux

Terminal Emulator

foot 1.1.2

Installation Method

source

Helix Version

24.03-171-g00e9e5ea

@nekopsykose nekopsykose added the C-bug Category: This is a bug label May 11, 2024
@nekopsykose
Copy link
Contributor Author

nekopsykose commented May 11, 2024

note that using a non-.. symlink from cwd (i.e. ln -s a/b c and editing ./c) works. looking at strace:

383   access("../a/b", W_OK)            = -1 ENOENT (No such file or directory)
401   rename("../a/b", "../a/b8HFAhn.bck" <unfinished ...>
401   <... rename resumed>)             = -1 ENOENT (No such file or directory)

it seems that it tries reading the .. out of cwd, which doesn't exist as it(the symlink) has to be relative to the directory it is actually in and not the helix cwd

@nekopsykose nekopsykose changed the title fails to write files that are symlinks to .. fails to write files that are relative symlinks that don't resolve from cwd May 11, 2024
@nekopsykose
Copy link
Contributor Author

that's a more accurate title since indeed it's just a cwd issue and not ..

$ mkdir -p a/b
$ echo 123 > a/b/c
$ ln -s b/c a/x
$ e a/x # doesn't work

@kirawi
Copy link
Member

kirawi commented May 11, 2024

Maybe #10728 fixes this?

@pascalkuthe
Copy link
Member

No that's unrelated, you will need to check if the path returned by readlink is relative and if it is join it on the parent directory of the destination path

@kirawi kirawi added E-easy Call for participation: Experience needed to fix: Easy / not much A-helix-term Area: Helix term improvements E-good-first-issue Call for participation: Issues suitable for new contributors labels May 13, 2024
@kirawi kirawi removed E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors labels May 18, 2024
@nekopsykose
Copy link
Contributor Author

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants