gtk-rs/gir

gir fails to compile on Windows

filnet opened this issue · 3 comments

Fails with :

$ cargo build
   Compiling gir v0.0.1 (C:\msys64\home\Philippe\rust\gstreamer-rs\gir)
error[E0433]: failed to resolve: could not find `unix` in `os`
 --> src\git.rs:3:14
  |
3 | use std::os::unix::prelude::OsStringExt;
  |              ^^^^ could not find `unix` in `os`

error[E0599]: no function or associated item named `from_vec` found for struct `OsString` in the current scope
  --> src\git.rs:70:30
   |
70 |     let toplevel = OsString::from_vec(output.stdout);
   |                              ^^^^^^^^ function or associated item not found in `OsString`

Interested into sending a fix? It should be pretty easy to do. :)

Not that simple...

Use of *::unix::* was introduced here 958e1b7.

It uses OsStringExt::from_vec() to parse the output of a git command and turn it into an OsString (and later to a PathBuff).
Relevant line is let toplevel = OsString::from_vec(output.stdout);.

On Windows, it is another story : https://users.rust-lang.org/t/is-there-a-way-to-convert-vec-u8-to-osstring/49970
The usual mess...

Turning that one line into let toplevel = String::from_utf8(output.stdout).ok()?; works on my PC but will probably fail on more exotic Windows setups (?).