On running aerc mbox:~/mbox
we expect aerc
to open the local mail
box which it doesn't and gives the error:
`mbox: open : no such file or directory`
aerc -v
: aerc 0.18.2 (go1.23.1 arm64 darwin 2024-09-10)
I would like to work on this issue, any guidance will be helpful, on a side note I never worked with go.
~Syed Fasiuddin, Oct 12 2024:
I would like to work on this issue, any guidance will be helpful, on a side note I never worked with go.
You could start by running strace to see which file path is causing the ENOENT error.
strace -f -e trace=file -s 65535 aerc mbox:...
I was just about to send a fix to the mailing list when I saw that you would want to work on this issue yourself.
Here is some guidance:
- the url.Parse command will parse the source string into different variables depending on the scheme prefix, i.e either 'mbox:' or 'mbox://'
- url.Parse("mbox://~/mbox") will parse the path into url.Host and url.Path (this is currently expected to work correctly); however, when using url.Parse("mbox:~/mbox", without the '//') it will parse the path into url.Opaque.
- a robust fix would make both schemes work
On Sat Oct 12, 2024 at 8:07 PM IST, ~konimarti wrote:
- the url.Parse command will parse the source string into different variables depending on the scheme prefix, i.e either 'mbox:' or 'mbox://'
- url.Parse("mbox://~/mbox") will parse the path into url.Host and url.Path (this is currently expected to work correctly); however, when using url.Parse("mbox:~/mbox", without the '//') it will parse the path into url.Opaque.
Yes!! I just found out what was happening and was composing the email about it and your email arrived.
Essentially this
if
block here is not being executed asu.Host
is not~
but instead is just nothing. But If I doaerc mbox:/Users/user/mbox
though it works fine asu.Path
contains this absolute path and theelse
block manages to set correct value fordir
.File: worker/mbox/worker.go
var dir string if u.Host == "~" { home, err := os.UserHomeDir() if err != nil { reterr = err break } dir = filepath.Join(home, u.Path) } else { dir = filepath.Join(u.Host, u.Path) }
- a robust fix would make both schemes work How can I solve this?
A possible approach could be:
- extract the url.Parse logic into a separate function that returns the path to the file (you can add test for this function)
- if the returned path starts with '~', expand it
The body of the extracted function could look like this:
{ var path string u, err := url.Parse(s) if err != nil { return path, err } if u.Host == "" { path = u.Path } else { path = filepath.Join(u.Host, u.Path) } if path == "" { path = u.Opaque } return path, err }
Syed Fasiuddin referenced this ticket in commit d13361b.