gilcu3 / hullcaster

Terminal-based podcast manager built in Rust
GNU General Public License v3.0
8 stars 1 forks source link

Hullcaster creates empty directory "~" in current directory at start #7

Closed Elcoid closed 2 months ago

Elcoid commented 2 months ago

Hello!

I discovered this when working on https://github.com/gilcu3/hullcaster/pull/6.

Basically, when I start Hullcaster, an empty directory called ~ appears in the current directory. This happens whether I start the debug target (either by running cargo run or running target/debug/hullcaster) or the release target (by running target/release/hullcaster).

This also happens regardless of my current directory. If I go in /tmp for example and run Hullcaster (either the debug or the release target) using either its absolute or relative path, I see ~ appearing in that directory.

gilcu3 commented 2 months ago

that's quite strange, could you share what is your environment? in particular OS? I have never seen that, but I only tested on Linux.

Elcoid commented 2 months ago

I'm also on Linux. I use Artix with Runit as the init, kernel 6.6.47-1-lts, rust 1:1.80.1-1.

Elcoid commented 2 months ago

I just tested on another computer with Gentoo, kernel 6.6.47-gentoo, rust 1.79.0, and it does the same thing.

gilcu3 commented 2 months ago

I am not able to reproduce the issue on my environment, Archlinux, rust 1.80.0, kernel 6.10.2-arch.

Do you have anything special in your shell configuration? One thing I can imagine is that somehow ~ is not being expanded, and it is being used in https://github.com/gilcu3/hullcaster/blob/2004435384caace4606ee12af3c15520ae825340/src/main.rs#L188

Could you try changing that line from "~/.local/state/hullcaster" to "/tmp" or any other valid path?

Elcoid commented 2 months ago

I changed "~/.local/state/hullcaster" to "/tmp" and the log file appeared in /tmp.

I didn't notice it initially because ".local" is hidden, but with the original line, it indeed creates a folder called "~" and then ".local/state/hullcaster/log" inside it

Elcoid commented 2 months ago

Do you have anything special in your shell configuration?

I'm not sure, but I don't think this is related to the shell. It's not interpreted by the shell, it's run in a compiled binary.

In any case, what happens if you run the following?

use std::fs;

fn main() -> std::io::Result<()> {
    fs::create_dir_all("~/test-dir")?;
    Ok(())
}
gilcu3 commented 2 months ago

If that's the case I will just fix the root issue and make sure I get the HOME folder properly (that line was not meant to be in "production" anyway). I will fix ASAP.

gilcu3 commented 2 months ago

@Elcoid can you check if the issue is fixed by ac9f2d7c57e085c2cd4141dd9943e76ce9ba2700?

Elcoid commented 2 months ago

Hello @gilcu3, no, with ac9f2d7 there is still a ~ directory created in the current dir. You can probably replicate this behaviour by unsetting XDG_STATE_HOME before running hullcaster:

$ unset XDG_STATE_HOME
$ cargo run
gilcu3 commented 2 months ago

Thanks, I was able to reproduce the issue now, should be fixed by c93c2c8, can you confirm?

Elcoid commented 2 months ago

Hello, yes, now it's fixed 🙌