drone icon indicating copy to clipboard operation
drone copied to clipboard

Drone CLI fails to install on Windows

Open bugadani opened this issue 4 years ago • 4 comments

Looks like src/env.rs contains some unix-specific code which makes it impossible to install drone on Windows. Would it be possible to replace it with a platform-independent implementation?

Compilation log:

   Compiling drone v0.11.1
error[E0433]: failed to resolve: could not find `unix` in `os`
 --> C:\Users\bugad\.cargo\registry\src\github.com-1ecc6299db9ec823\drone-0.11.1\src\env.rs:5:20
  |
5 | use std::{env, os::unix::process::CommandExt, process::Command};
  |                    ^^^^ could not find `unix` in `os`

error[E0432]: unresolved import `signal_hook::iterator`
  --> C:\Users\bugad\.cargo\registry\src\github.com-1ecc6299db9ec823\drone-0.11.1\src\probe\bmp.rs:13:18
   |
13 | use signal_hook::iterator::Signals;
   |                  ^^^^^^^^ could not find `iterator` in `signal_hook`

error[E0432]: unresolved import `signal_hook::iterator`
  --> C:\Users\bugad\.cargo\registry\src\github.com-1ecc6299db9ec823\drone-0.11.1\src\probe\openocd.rs:14:18
   |
14 | use signal_hook::iterator::Signals;
   |                  ^^^^^^^^ could not find `iterator` in `signal_hook`

error[E0432]: unresolved import `signal_hook::iterator`
  --> C:\Users\bugad\.cargo\registry\src\github.com-1ecc6299db9ec823\drone-0.11.1\src\probe\mod.rs:14:18
   |
14 | use signal_hook::iterator::Signals;
   |                  ^^^^^^^^ could not find `iterator` in `signal_hook`

error[E0433]: failed to resolve: could not find `unix` in `os`
  --> C:\Users\bugad\.cargo\registry\src\github.com-1ecc6299db9ec823\drone-0.11.1\src\utils.rs:12:9
   |
12 |     os::unix::{ffi::OsStrExt, io::AsRawFd, process::CommandExt},
   |         ^^^^ could not find `unix` in `os`

error[E0432]: unresolved imports `signal_hook::iterator`, `signal_hook::SIGQUIT`
 --> C:\Users\bugad\.cargo\registry\src\github.com-1ecc6299db9ec823\drone-0.11.1\src\utils.rs:5:19
  |
5 | use signal_hook::{iterator::Signals, SIGINT, SIGQUIT, SIGTERM};
  |                   ^^^^^^^^                   ^^^^^^^ no `SIGQUIT` in the root
  |                   |
  |                   could not find `iterator` in `signal_hook`

error[E0425]: cannot find function `mkfifo` in crate `libc`
   --> C:\Users\bugad\.cargo\registry\src\github.com-1ecc6299db9ec823\drone-0.11.1\src\utils.rs:115:23
    |
115 |     if unsafe { libc::mkfifo(c_pipe.as_ptr(), 0o644) } == -1 {
    |                       ^^^^^^ not found in `libc`

error[E0425]: cannot find function `fcntl` in crate `libc`
   --> C:\Users\bugad\.cargo\registry\src\github.com-1ecc6299db9ec823\drone-0.11.1\src\utils.rs:124:20
    |
124 |     unsafe { libc::fcntl(fifo.as_raw_fd(), libc::F_SETFL, libc::O_NONBLOCK) };
    |                    ^^^^^ not found in `libc`

error[E0425]: cannot find value `F_SETFL` in crate `libc`
   --> C:\Users\bugad\.cargo\registry\src\github.com-1ecc6299db9ec823\drone-0.11.1\src\utils.rs:124:50
    |
124 |     unsafe { libc::fcntl(fifo.as_raw_fd(), libc::F_SETFL, libc::O_NONBLOCK) };
    |                                                  ^^^^^^^ not found in `libc`

error[E0425]: cannot find value `O_NONBLOCK` in crate `libc`
   --> C:\Users\bugad\.cargo\registry\src\github.com-1ecc6299db9ec823\drone-0.11.1\src\utils.rs:124:65
    |
124 |     unsafe { libc::fcntl(fifo.as_raw_fd(), libc::F_SETFL, libc::O_NONBLOCK) };
    |                                                                 ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `setpgid` in crate `libc`
   --> C:\Users\bugad\.cargo\registry\src\github.com-1ecc6299db9ec823\drone-0.11.1\src\utils.rs:140:19
    |
140 |             libc::setpgid(0, 0);
    |                   ^^^^^^^ help: a function with a similar name exists: `getpid`

error[E0599]: no method named `exec` found for type `std::process::Command` in the current scope
  --> C:\Users\bugad\.cargo\registry\src\github.com-1ecc6299db9ec823\drone-0.11.1\src\env.rs:21:33
   |
21 |             Err(anyhow!(command.exec()))
   |                                 ^^^^ method not found in `std::process::Command`

error[E0599]: no method named `as_bytes` found for type `&std::ffi::OsStr` in the current scope
   --> C:\Users\bugad\.cargo\registry\src\github.com-1ecc6299db9ec823\drone-0.11.1\src\utils.rs:114:48
    |
114 |     let c_pipe = CString::new(pipe.as_os_str().as_bytes())?;
    |                                                ^^^^^^^^ method not found in `&std::ffi::OsStr`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use clap::osstringext::OsStrExt3;`

error[E0599]: no method named `as_raw_fd` found for type `std::fs::File` in the current scope
   --> C:\Users\bugad\.cargo\registry\src\github.com-1ecc6299db9ec823\drone-0.11.1\src\utils.rs:124:31
    |
124 |     unsafe { libc::fcntl(fifo.as_raw_fd(), libc::F_SETFL, libc::O_NONBLOCK) };
    |                               ^^^^^^^^^ method not found in `std::fs::File`

error[E0599]: no method named `pre_exec` found for type `&mut std::process::Command` in the current scope
   --> C:\Users\bugad\.cargo\registry\src\github.com-1ecc6299db9ec823\drone-0.11.1\src\utils.rs:139:17
    |
139 |         openocd.pre_exec(|| {
    |                 ^^^^^^^^ method not found in `&mut std::process::Command`

error: aborting due to 15 previous errors

bugadani avatar Apr 03 '20 13:04 bugadani

Would it be possible to replace it with a platform-independent implementation?

I think it's possible, but not trivial. Drone CLI uses pipes, signals, and other unix stuff to glue different external commands together. For example when you run drone probe itm with an OpenOCD probe, it spawns OpenOCD GDB server that connects to your probe, GDB client that connects to the GDB server and sends commands to enable ITM on the chip, itmsink utility that consumes the output of the pipe created by OpenOCD. And all of this should correctly handle Ctrl-C as if it's a single drone command.

valff avatar Apr 12 '20 06:04 valff

I'm trying out drone and hit the same issue. I think it is a really nice project, but being unix only is a really big limitation. Rust has a ton of platform independent libraries to handle this stuff.

If I have time I will give this a shot

chemicstry avatar Sep 03 '20 21:09 chemicstry

Thank you for your comment. We will much appreciate contributions to make drone CLI tools available for non-unix operating systems.

alfredch avatar Sep 03 '20 22:09 alfredch

@chemicstry Have you considered using WSL? I am working from Windows this way, and it works just fine!

rmja avatar Jan 23 '21 14:01 rmja