Skip to content

Install utility does not compile on Windows #1174

@danieldulaney

Description

@danieldulaney

The install utility fails to build on Windows (nightly-x86_64-pc-windows-gnu 2018-03-27).

D:\git\coreutils>cargo build --no-default-features --features install
   Compiling install v0.0.1 (file:///D:/git/coreutils/src/install)
error[E0433]: failed to resolve. Use of undeclared type or module `mode`
  --> src\install\mode.rs:14:9
   |
14 |         mode::parse_numeric(0, mode_string)
   |         ^^^^ Use of undeclared type or module `mode`

error[E0433]: failed to resolve. Use of undeclared type or module `mode`
  --> src\install\mode.rs:16:9
   |
16 |         mode::parse_symbolic(0, mode_string, considering_dir)
   |         ^^^^ Use of undeclared type or module `mode`

warning: unused import: `std::fs`
 --> src\install\mode.rs:4:5
  |
4 | use std::fs;
  |     ^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

error: aborting due to 2 previous errors

It looks like the error is because install/mode.rs doesn't use uucore::mode on Windows, but doesn't have an alternate implementation of parse for Windows to use.

#[cfg(not(windows))]
use uucore::mode;
/// Takes a user-supplied string and tries to parse to u16 mode bitmask.
pub fn parse(mode_string: &str, considering_dir: bool) -> Result<u32, String> {
let numbers: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
// Passing 000 as the existing permissions seems to mirror GNU behaviour.
if mode_string.contains(numbers) {
mode::parse_numeric(0, mode_string)
} else {
mode::parse_symbolic(0, mode_string, considering_dir)
}
}

Does it make sense to break up parse into Windows and non-Windows variants the same way chmod is broken up? Or maybe something has to change at the caller to make sure Windows code doesn't rely on parse?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions