dua-cli: Build fails on Windows due to termion errors

error[E0433]: failed to resolve: maybe a missing `extern crate sys;`?
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\lib.rs:24:9
   |
24 | pub use sys::size::terminal_size;
   |         ^^^ maybe a missing `extern crate sys;`?

error[E0433]: failed to resolve: maybe a missing `extern crate sys;`?
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\lib.rs:25:9
   |
25 | pub use sys::tty::{is_tty, get_tty};
   |         ^^^ maybe a missing `extern crate sys;`?

error[E0433]: failed to resolve: maybe a missing `extern crate sys;`?
 --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\async.rs:5:5
  |
5 | use sys::tty::get_tty;
  |     ^^^ maybe a missing `extern crate sys;`?

error[E0433]: failed to resolve: maybe a missing `extern crate sys;`?
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:29:5
   |
29 | use sys::attr::{get_terminal_attr, raw_terminal_attr, set_terminal_attr};
   |     ^^^ maybe a missing `extern crate sys;`?

error[E0432]: unresolved import `sys`
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:28:5
   |
28 | use sys::Termios;
   |     ^^^ maybe a missing `extern crate sys;`?

error[E0425]: cannot find function `get_tty` in this scope
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\async.rs:14:36
   |
14 |     thread::spawn(move || for i in get_tty().unwrap().bytes() {
   |                                    ^^^^^^^ not found in this scope

error[E0425]: cannot find function `get_tty` in this scope
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\async.rs:43:36
   |
43 |     thread::spawn(move || for i in get_tty().unwrap().bytes() {
   |                                    ^^^^^^^ not found in this scope

error[E0425]: cannot find function `set_terminal_attr` in this scope
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:45:9
   |
45 |         set_terminal_attr(&self.prev_ios).unwrap();
   |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `get_terminal_attr` in this scope
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:90:23
   |
90 |         let mut ios = get_terminal_attr()?;
   |                       ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `raw_terminal_attr` in this scope
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:93:9
   |
93 |         raw_terminal_attr(&mut ios);
   |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `set_terminal_attr` in this scope
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:95:9
   |
95 |         set_terminal_attr(&ios)?;
   |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `set_terminal_attr` in this scope
   --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:106:9
    |
106 |         set_terminal_attr(&self.prev_ios)?;
    |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `get_terminal_attr` in this scope
   --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:111:23
    |
111 |         let mut ios = get_terminal_attr()?;
    |                       ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `raw_terminal_attr` in this scope
   --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:112:9
    |
112 |         raw_terminal_attr(&mut ios);
    |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `set_terminal_attr` in this scope
   --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:113:9
    |
113 |         set_terminal_attr(&ios)?;
    |         ^^^^^^^^^^^^^^^^^ not found in this scope

error: aborting due to 15 previous errors

Some errors occurred: E0425, E0432, E0433.
For more information about an error, try `rustc --explain E0425`.
error: Could not compile `termion`.
warning: build failed, waiting for other jobs to finish...

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 29 (14 by maintainers)

Commits related to this issue

Most upvoted comments

@Byron-TW I successfully built dua-cli v2.2.0 on Windows 10 using stable rustc 1.42.0 and the windows-support branch of termion.

In order to do this I added the following before the [dependencies] in Cargo.toml:

[patch.crates-io]
termion = { git = "https://gitlab.redox-os.org/Jezza/termion.git", branch = "windows-support" }

Building later versions is only possible with rustc nightly. A workaround to build using rustc stable was discussed in the vector project.

Building version 2.6.0 fails due to src/crossdev.rs not providing the necessary functions for Windows.

It is recommended to execute dua-cli in a modern Terminal, like Alacritty (which is written in Rust).

I have just released [`dua 2.9](https://github.com/Byron/dua-cli/releases/tag/v2.9.0) which should bring full windows support powered by `crossterm`.

Could you have a look and let me know how it works? I would love to close this issue 😃.

It looks like switching to crossterm as TUI backend and adjusting input handling in DUA is the way to go. Unless Termion will one day be ported to Windows.

As a possible solution, I replaced termion with crossterm for a TUI application and it now works on Windows.

Thanks for pushing forward on windows support @Byron! 🎉

I haven’t fully tested it, but it’s now compiling and seems, on first blush, to be working correctly.

As noted, dua i shows size as 0 for subdirectories (and all files within those directories are shown as 0 size). At the same time though, a simple dua does seem to show the correct size for files and subdirectories. I’ll follow-up on #53 to see if I can help track down the problem.

I created a PR (#60) that fixes a couple of compiler warnings and adds the usually expected wildcard support (for windows).

There is a test error which appears to be some single byte size differences in EntryData …

>cargo +nightly test
   Compiling dua-cli v2.9.0 (C:\Users\Roy\OneDrive\Projects\rust\dua-cli)
    Finished test [unoptimized + debuginfo] target(s) in 2.77s
     Running target\debug\deps\dua-cbadb0c3e39d4e6a.exe

running 1 test
test inodefilter::tests::it_filters_inodes ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target\debug\deps\dua-b1160d1b01703dd0.exe

running 5 tests
test interactive::app_test::unit::it_can_handle_ending_traversal_without_reaching_the_top ... ignored
test interactive::app::common::tests::fit_string_inputs ... ok
test interactive::app_test::journeys_with_writes::basic_user_journey_with_deletion ... ok
test interactive::app_test::journeys_readonly::simple_user_journey_read_only ... ok
test interactive::app_test::unit::it_can_handle_ending_traversal_reaching_top_but_skipping_levels ... FAILED

failures:

---- interactive::app_test::unit::it_can_handle_ending_traversal_reaching_top_but_skipping_levels stdout ----
thread 'interactive::app_test::unit::it_can_handle_ending_traversal_reaching_top_but_skipping_levels' panicked at 'assertion failed: `(left == right)`: filesystem graph is stable and matches the directory structure

Diff < left / right > :
<"StableGraph { Ty: \"Directed\", node_count: 15, edge_count: 14, edges: (0, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (6, 7), (6, 8), (6, 9), (6, 10), (10, 11), (6, 12), (12, 13), (1, 14), node weights: {0: EntryData { name: \"\", size: 1259069, metadata_io_error: false }, 1: EntryData { name: \"tests/fixtures\\\\sample-01\", size: 1259069, metadata_io_error: false }, 2: EntryData { name: \".hidden.666\", size: 666, metadata_io_error: false }, 3: EntryData { name: \"a\", size: 256, metadata_io_error: false }, 4: EntryData { name: \"b.empty\", size: 0, metadata_io_error: false }, 5: EntryData { name: \"c.lnk\", size: 0, metadata_io_error: false }, 6: EntryData { name: \"dir\", size: 1258024, metadata_io_error: false }, 7: EntryData { name: \"1000bytes\", size: 1000, metadata_io_error: false }, 8: EntryData { name: \"dir-a.1mb\", size: 1000000, metadata_io_error: false }, 9: EntryData { name: \"dir-a.kb\", size: 1024, metadata_io_error: false }, 10: EntryData { name: \"empty-dir\", size: 0, metadata_io_error: false }, 11: EntryData { name: \".gitkeep\", size: 0, metadata_io_error: false }, 12: EntryData { name: \"sub\", size: 256000, metadata_io_error: false }, 13: EntryData { name: \"dir-sub-a.256kb\", size: 256000, metadata_io_error: false }, 14: EntryData { name: \"z123.b\", size: 123, metadata_io_error: false }}, free_node: NodeIndex(4294967295), free_edge: EdgeIndex(4294967295) }"
>"StableGraph { Ty: \"Directed\", node_count: 15, edge_count: 14, edges: (0, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (6, 7), (6, 8), (6, 9), (6, 10), (10, 11), (6, 12), (12, 13), (1, 14), node weights: {0: EntryData { name: \"\", size: 1259070, metadata_io_error: false }, 1: EntryData { name: \"tests/fixtures\\\\sample-01\", size: 1259070, metadata_io_error: false }, 2: EntryData { name: \".hidden.666\", size: 666, metadata_io_error: false }, 3: EntryData { name: \"a\", size: 256, metadata_io_error: false }, 4: EntryData { name: \"b.empty\", size: 0, metadata_io_error: false }, 5: EntryData { name: \"c.lnk\", size: 1, metadata_io_error: false }, 6: EntryData { name: \"dir\", size: 1258024, metadata_io_error: false }, 7: EntryData { name: \"1000bytes\", size: 1000, metadata_io_error: false }, 8: EntryData { name: \"dir-a.1mb\", size: 1000000, metadata_io_error: false }, 9: EntryData { name: \"dir-a.kb\", size: 1024, metadata_io_error: false }, 10: EntryData { name: \"empty-dir\", size: 0, metadata_io_error: false }, 11: EntryData { name: \".gitkeep\", size: 0, metadata_io_error: false }, 12: EntryData { name: \"sub\", size: 256000, metadata_io_error: false }, 13: EntryData { name: \"dir-sub-a.256kb\", size: 256000, metadata_io_error: false }, 14: EntryData { name: \"z123.b\", size: 123, metadata_io_error: false }}, free_node: NodeIndex(4294967295), free_edge: EdgeIndex(4294967295) }"

', src\interactive\app_test\unit.rs:12:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    interactive::app_test::unit::it_can_handle_ending_traversal_reaching_top_but_skipping_levels

@Byron-TW https://gitlab.redox-os.org/redox-os/termion/issues/139 this lib doesn’t support windows … Supports Redox, Mac OS X, BSD, and Linux (or, in general, ANSI terminals). aha~