Closed moderation closed 11 months ago
https://github.com/jiacai2050/zigcli/blob/f1561defb0c05c3e94529bc478e53b0e9c7dbc6a/src/tree.zig#L219
You can replace L219 with following code to debug which file cause the trouble:
@@ -216,7 +216,10 @@ fn walk(
.directory => {
_ = try writer.write("\n");
ret.directories += 1;
- var sub_iter_dir = try iter_dir.dir.openIterableDir(entry.name, .{});
+ var sub_iter_dir = iter_dir.dir.openIterableDir(entry.name, .{}) catch |e| {
+ std.debug.print("e: {any}, name:{s}\n", .{ e, entry.name });
+ return e;
+ };
defer sub_iter_dir.close();
Not seeing any difference in output. Do I need to change how I invoke?
diff --git a/src/tree.zig b/src/tree.zig
index b408387..5859ec0 100644
--- a/src/tree.zig
+++ b/src/tree.zig
@@ -216,7 +216,10 @@ fn walk(
.directory => {
_ = try writer.write("\n");
ret.directories += 1;
- var sub_iter_dir = try iter_dir.dir.openIterableDir(entry.name, .{});
+ var sub_iter_dir = iter_dir.dir.openIterableDir(entry.name, .{}) catch |e| {
+ std.debug.print("e: {any}, name:{s}\n", .{ e, entry.name });
+ return e;
+ };
defer sub_iter_dir.close();
const new_prefix =
├──tree-sitter-python
│ ├──Cargo.toml
│ ├──LICENSE
│ ├──README.md
│ ├──binding.gyp
│ ├──grammar.js
│ ├──package.json
│ ├──bindings
│ │ ├──node
│ │ │ ├──binding.cc
│ │ │ └──index.js
│ │ └──rust
│ │ ├──README.md
│ │ ├──build.rs
│ │ └──lib.rs
│ ├──examples
│ │ ├──compound-statement-without-trailing-newline.py
│ │ ├──crlf-line-endings.py
│ │ ├──mixed-spaces-tabs.py
│ │ ├──multiple-newlines.py
│ │ ├──python2-grammar-crlf.py
│ │ ├──python2-grammar.py
│ │ ├──python3-grammar-crlf.py
│ │ ├──python3-grammar.py
│ │ ├──python3.8_grammar.py
│ │ ├──error: FileNotFound
I guess we can apply same changes to all io operations, the following two are most important.
I found the not-found file, when we first clone the repo, node_modules is not installed, so I guess Linux's tree just ignore this error...
~/difftastic/vendored_parsers/tree-sitter-qmljs/queries
(master)$ ll
total 8.0K
lrwxr-xr-x 1 jiacai 61 Oct 12 07:34 highlights-javascript.scm -> ../node_modules/tree-sitter-javascript/queries/highlights.scm
lrwxr-xr-x 1 jiacai 61 Oct 12 07:34 highlights-typescript.scm -> ../node_modules/tree-sitter-typescript/queries/highlights.scm
-rw-r--r-- 1 jiacai 1000 Oct 12 07:34 highlights.scm
-rw-r--r-- 1 jiacai 148 Oct 12 07:34 locals.scm
~/difftastic/vendored_parsers/tree-sitter-qmljs/queries
(master)$ ls ../node_modules/tree-sitter-javascript/queries/highlights.scm
ls: cannot access '../node_modules/tree-sitter-javascript/queries/highlights.scm': No such file or directory
Yes - that is the issue. It would be good to implement the pattern matching options in Linux tree
so you could exclude node_modules
and bypass the error. Or just keep going without returning an error to match Linux tree
-P pattern List only those files that match the pattern given.
-I pattern Do not list files that match the given pattern.
Fixed in main, please try again.
PS: it turns out that
readLink
won't return the not-found error.
This works. Thanks!
Describe this problem
When running tree on large directories I'm occasionally getting
error: FileNotFound
errors. Not sure what triggers but am including output from standard Linuxtree
and thezigcli
tree
. This is being run on the https://github.com/Wilfred/difftastic/tree/master/vendored_parsers/vendordifftastic_vendor_tree_linux.txt difftastic_vendor_tree_zigcli.txt
Is there a way to run with debug output logging to try and find the issue? Thanks for a great tool.
Version