Comments (14)
Oooh!
[kondo/src/main.rs:37] dirs.into_iter().map(|d| path_canonicalise(&cd, d)).collect() = Ok(
[
"/home/matthias",
],
)
[kondo/src/main.rs:64] p.ok() = Some(
Project {
project_type: Node,
path: "/home/matthias",
},
)
[kondo/src/main.rs:67] &project = Project {
project_type: Node,
path: "/home/matthias",
}
[kondo/src/main.rs:86] project_artifact_bytes == 0 = true
Projects cleaned: 0, Bytes deleted: 0.0B
So I guess what happens is, kondo searches for a directory, and checks if it is some kind of project directory IF IT IS NOT it recurses into it and walks it recursively BUT IF IT IS, it is marked for cache-scrubbing or something.
I assume in my case, I have something in my $HOME root that makes kondo think "this is a node project!" so it tries to delete whatever node uses as target-dir equivalent (compared to rust), fails and then gives up, because it only had that one "project" to check?
The solution might be still recurse into project directories and look for further project dirs, even after we deleted whatever cache there was in..?
from kondo.
@tbillington I used kondo .
as the command. And my current directory was /home/user/dev
.
from kondo.
So I have not tried this, but you can probably also confuse kondo by adding something like a Cargo.toml
into your home and then running kondo ~
which might also prevent it from recursing?
from kondo.
That doesn't sound good! Which OS are you on?
Also, does it find the project when you supply a path of a project as an argument?
from kondo.
If you'd like to have a crack at debugging it, you can put this statement in between these two lines then run from root of kondo
cargo run -- ~
(or whichever path to test)
println!("{}", entry.path().to_string_lossy());
https://github.com/tbillington/kondo/blob/master/kondo-lib/src/lib.rs#L221-L222
from kondo.
kondo .
[kondo-lib/src/lib.rs:223] entry.path() = "/home/matthias"
[kondo-lib/src/lib.rs:224] entry.path().read_dir() = Ok(
ReadDir(
"/home/matthias",
),
)
Projects cleaned: 0, Bytes deleted: 0.0B
I can also see that the for dir_entry in rd.filter_map(|rd| rd.ok()).map(|de| de.file_name()) {
loop loops through all entries at home directory root level.
I'm on majaro linux.
When I use "kondo ." from a different directory, or "kondo some/directory/" from withing my home directory root, it works fine.
from kondo.
It does not work in NixOS as well. However, I am actually not inside home but a subdirectory: /home/user/dev/
. Output is only Projects cleaned: 0, Bytes deleted: 0.0B
. 0.4.0 ..
from kondo.
Hmm, are you supplying the path, or relying on kondo detecting the current dir? If you don't supply the path it will fall back to std::env::current_dir
https://doc.rust-lang.org/stable/std/env/fn.set_current_dir.html#platform-specific-behavior
Line 32 in 72f9b5c
from kondo.
Hmmm, potentially some combo with current env..
If it's not an absolute path according to std it will join it with what std detects as the current env...
Line 358 in 72f9b5c
If you have the rust toolchain could you please modify prepare_dictionaries
like this and see what it says? Apologies I don't have your system/OS combo to test with.
fn prepare_directories(dirs: Vec<PathBuf>) -> Result<Vec<PathBuf>, Box<dyn Error>> {
let cd = dbg!(current_dir()?);
if dirs.is_empty() {
return Ok(vec![cd]);
}
dirs.into_iter()
.map(|d| dbg!(path_canonicalise(&cd, d)))
.collect()
}
from kondo.
Hmm, I can see that in both case, kondo
and kondo .
inside $HOME, prepare_directories
returns the same path /home/matthias
~/vcs/github/kondo/target/debug/kondo
[kondo/src/main.rs:34] Ok(vec![cd]) = Ok(
[
"/home/matthias",
],
)
Projects cleaned: 0, Bytes deleted: 0.0B
~/vcs/github/kondo/target/debug/kondo .
[kondo/src/main.rs:37] dirs.into_iter().map(|d| path_canonicalise(&cd, d)).collect() = Ok(
[
"/home/matthias",
],
)
Projects cleaned: 0, Bytes deleted: 0.0B
from kondo.
Mmh, it seems that in both cases, project_artifact_bytes
is actually zero, so we enter the "continue" and don't do any cleaning at all
[kondo/src/main.rs:85] project_artifact_bytes == 0 = true
from kondo.
Thank you for digging into this @matthiaskrgr . I think you've stumbled onto this issue: #29 and #32.
As you've discovered, kondo bails when it detects a directory as a project, and won't recurse further.
In a much earlier version the behaviour was the opposite. However, certain types of projects, like node
will recursively have projects within them that look like normal projects, which caused an explosion of output and made the tool unusable.
There is a middle ground where you recurse directories that aren't marked as artifact directories, however I just haven't spent the time to sit down and refactor the walking logic to support that yet.
Do you have any thoughts on how you'd prefer it act in this situation?
from kondo.
I guess we could treat directories that we get passed explicitly such as .
, ~
, some/path/
special and still walk them recursively BUT also print a warning at the same time that this was found to be a project directory:
Warning: recursing int rust project dir '.' because it was passed explicitly
from kondo.
@matthiaskrgr I think that would be too opinionated. I commonly run kondo while in a project directory I want to clean/check, or pass the project dir to kondo like kondo my_proj
.
from kondo.
Related Issues (20)
- Add flag to only clean projects last mofied more than X days/weeks HOT 1
- compare to similar projects HOT 5
- Add progress indicator HOT 3
- Keep looking inside project HOT 5
- .gitignore HOT 1
- App paniked on "Select Directory" button press HOT 7
- kondo-ui hung and crashed on macOS (after working well for a while) HOT 4
- Directories you can delete for Python projects HOT 2
- is it possible to run kondo recursively? HOT 3
- Option for non-interactive mode HOT 2
- Binary .exe under Windows 11 does not start HOT 2
- Following symlinks is a questionable default HOT 4
- Only delete old project (skip active project) HOT 7
- Os error NotFound when trying to ignore certain directories with `ls --ignore=...` HOT 4
- Make a new release HOT 6
- Could not compile kondo-ui HOT 1
- kondo doesn't build on FreeBSD HOT 1
- Add .angular folder HOT 1
- No icons in UI (actually, just one). Font needed? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kondo.