最近メインPCをWindows11にしました。ナナオです。

cargoなどの初期セットアップがだいぶ終わって作業しやすくなってきましたが、lsの高速版であるexaを入れようとしたら詰まったので備忘録を残しておこうと思います。

exaのインストール

Windows以外であれば以下のコマンドでインストールは終わります。

cargo install exa

ただし、exaはまだ正式にWindows版をリリースしていないため、同じ事をwindowsでやるとエラーになります。

(以下は実際のエラー)

> cargo install exa
    Updating crates.io index
  Downloaded exa v0.10.1
  Downloaded 1 crate (136.6 KB) in 1.23s
  Installing exa v0.10.1
    Updating crates.io index
  Downloaded number_prefix v0.4.0
  Downloaded users v0.11.0
  Downloaded term_size v0.3.2
  Downloaded byteorder v1.5.0
  Downloaded ansi_term v0.12.1
  Downloaded scoped_threadpool v0.1.9
  Downloaded jobserver v0.1.27
  Downloaded libgit2-sys v0.12.26+1.3.0
  Downloaded natord v1.0.9
  Downloaded term_grid v0.1.7
  Downloaded zoneinfo_compiled v0.5.1
  Downloaded locale v0.2.2
  Downloaded pad v0.1.6
  Downloaded datetime v0.5.2
  Downloaded git2 v0.13.25
  Downloaded 15 crates (1.9 MB) in 1.29s (largest was `libgit2-sys` at 1.5 MB)
   Compiling libc v0.2.149
   Compiling winapi v0.3.9
   Compiling jobserver v0.1.27
   Compiling pkg-config v0.3.27
   Compiling vcpkg v0.2.15
   Compiling tinyvec_macros v0.1.1
   Compiling unicode-width v0.1.11
   Compiling unicode-bidi v0.3.13
   Compiling percent-encoding v2.3.0
   Compiling log v0.4.20
   Compiling bitflags v1.3.2
   Compiling byteorder v1.5.0
   Compiling glob v0.3.1
   Compiling num_cpus v1.16.0
   Compiling number_prefix v0.4.0
   Compiling natord v1.0.9
   Compiling scoped_threadpool v0.1.9
   Compiling lazy_static v1.4.0
   Compiling tinyvec v1.6.0
   Compiling pad v0.1.6
   Compiling term_grid v0.1.7
   Compiling form_urlencoded v1.2.0
   Compiling cc v1.0.83
   Compiling locale v0.2.2
   Compiling users v0.11.0
error[E0433]: failed to resolve: could not find `unix` in `os`
  --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:36:14
   |
36 | use std::os::unix::ffi::OsStrExt;
   |              ^^^^ could not find `unix` in `os`

error[E0432]: unresolved imports `libc::uid_t`, `libc::gid_t`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\lib.rs:128:16
    |
128 | pub use libc::{uid_t, gid_t};
    |                ^^^^^  ^^^^^ no `gid_t` in the root
    |                |
    |                no `uid_t` in the root

error[E0432]: unresolved imports `libc::uid_t`, `libc::gid_t`
  --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:45:20
   |
45 | use libc::{c_char, uid_t, gid_t, c_int};
   |                    ^^^^^  ^^^^^ no `gid_t` in the root
   |                    |
   |                    no `uid_t` in the root
   |
   = help: consider importing this unresolved item through its public re-export instead:
           uid_t
   = help: consider importing this unresolved item through its public re-export instead:
           gid_t

error[E0432]: unresolved import `libc::passwd`
  --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:46:5
   |
46 | use libc::passwd as c_passwd;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^ no `passwd` in the root

error[E0432]: unresolved import `libc::group`
  --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:47:5
   |
47 | use libc::group as c_group;
   |     ^^^^^^^^^^^^^^^^^^^^^^ no `group` in the root

error[E0432]: unresolved imports `libc::uid_t`, `libc::gid_t`
  --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\cache.rs:87:12
   |
87 | use libc::{uid_t, gid_t};
   |            ^^^^^  ^^^^^ no `gid_t` in the root
   |            |
   |            no `uid_t` in the root
   |
   = help: consider importing this unresolved item through its public re-export instead:
           uid_t
   = help: consider importing this unresolved item through its public re-export instead:
           gid_t

error[E0432]: unresolved imports `libc::uid_t`, `libc::gid_t`
  --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\mock.rs:63:16
   |
63 | pub use libc::{uid_t, gid_t};
   |                ^^^^^  ^^^^^ no `gid_t` in the root
   |                |
   |                no `uid_t` in the root
   |
   = help: consider importing this unresolved item through its public re-export instead:
           uid_t
   = help: consider importing this unresolved item through its public re-export instead:
           gid_t

error[E0432]: unresolved imports `libc::uid_t`, `libc::gid_t`
 --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\switch.rs:4:12
  |
4 | use libc::{uid_t, gid_t, c_int};
  |            ^^^^^  ^^^^^ no `gid_t` in the root
  |            |
  |            no `uid_t` in the root
  |
  = help: consider importing this unresolved item through its public re-export instead:
          uid_t
  = help: consider importing this unresolved item through its public re-export instead:
          gid_t

error[E0432]: unresolved imports `libc::uid_t`, `libc::gid_t`
 --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\traits.rs:4:12
  |
4 | use libc::{uid_t, gid_t};
  |            ^^^^^  ^^^^^ no `gid_t` in the root
  |            |
  |            no `uid_t` in the root
  |
  = help: consider importing this unresolved item through its public re-export instead:
          uid_t
  = help: consider importing this unresolved item through its public re-export instead:
          gid_t

error[E0433]: failed to resolve: could not find `UserExtras` in `os`
  --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:78:26
   |
78 |         let extras = os::UserExtras::default();
   |                          ^^^^^^^^^^ could not find `UserExtras` in `os`

error[E0433]: failed to resolve: could not find `GroupExtras` in `os`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:192:26
    |
192 |         let extras = os::GroupExtras::default();
    |                          ^^^^^^^^^^^ could not find `GroupExtras` in `os`

error[E0433]: failed to resolve: could not find `UserExtras` in `os`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:266:28
    |
266 |         extras:        os::UserExtras::from_passwd(passwd),
    |                            ^^^^^^^^^^ could not find `UserExtras` in `os`

error[E0433]: failed to resolve: could not find `GroupExtras` in `os`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:280:23
    |
280 |         extras:   os::GroupExtras::from_struct(group),
    |                       ^^^^^^^^^^^ could not find `GroupExtras` in `os`

error[E0412]: cannot find type `UserExtras` in module `os`
    --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:57:17
     |
57   |     extras: os::UserExtras,
     |                 ^^^^^^^^^^ not found in `os`
     |
note: found an item that was configured out
    --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:1176:14
     |
1176 |     pub type UserExtras = bsd::UserExtras;
     |              ^^^^^^^^^^
note: found an item that was configured out
    --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:1180:14
     |
1180 |     pub type UserExtras = unix::UserExtras;
     |              ^^^^^^^^^^

error[E0412]: cannot find type `GroupExtras` in module `os`
    --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:171:17
     |
171  |     extras: os::GroupExtras,
     |                 ^^^^^^^^^^^ not found in `os`
     |
note: found an item that was configured out
    --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:1184:14
     |
1184 |     pub type GroupExtras = unix::GroupExtras;
     |              ^^^^^^^^^^^

error[E0425]: cannot find function `getpwuid_r` in crate `libc`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:336:19
    |
336 |             libc::getpwuid_r(uid, &mut passwd, buf.as_mut_ptr(), buf.len(), &mut result)
    |                   ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `getpwnam_r` in crate `libc`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:398:19
    |
398 |             libc::getpwnam_r(username.as_ptr(), &mut passwd, buf.as_mut_ptr(), buf.len(), &mut result)
    |                   ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `getgrgid_r` in crate `libc`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:451:19
    |
451 |             libc::getgrgid_r(gid, &mut passwd, buf.as_mut_ptr(), buf.len(), &mut result)
    |                   ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `getgrnam_r` in crate `libc`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:513:19
    |
513 |             libc::getgrnam_r(groupname.as_ptr(), &mut group, buf.as_mut_ptr(), buf.len(), &mut result)
    |                   ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `getuid` in crate `libc`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:556:20
    |
556 |     unsafe { libc::getuid() }
    |                    ^^^^^^ help: a function with a similar name exists: `getpid`
    |
   ::: C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\libc-0.2.149\src\windows\mod.rs:491:5
    |
491 |     pub fn getpid() -> ::c_int;
    |     -------------------------- similarly named function `getpid` defined here

error[E0425]: cannot find function `geteuid` in crate `libc`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:603:20
    |
603 |     unsafe { libc::geteuid() }
    |                    ^^^^^^^ help: a function with a similar name exists: `getpid`
    |
   ::: C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\libc-0.2.149\src\windows\mod.rs:491:5
    |
491 |     pub fn getpid() -> ::c_int;
    |     -------------------------- similarly named function `getpid` defined here

error[E0425]: cannot find function `getgid` in crate `libc`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:647:20
    |
647 |     unsafe { libc::getgid() }
    |                    ^^^^^^ help: a function with a similar name exists: `getpid`
    |
   ::: C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\libc-0.2.149\src\windows\mod.rs:491:5
    |
491 |     pub fn getpid() -> ::c_int;
    |     -------------------------- similarly named function `getpid` defined here

error[E0425]: cannot find function `getegid` in crate `libc`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:691:20
    |
691 |     unsafe { libc::getegid() }
    |                    ^^^^^^^ help: a function with a similar name exists: `getpid`
    |
   ::: C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\libc-0.2.149\src\windows\mod.rs:491:5
    |
491 |     pub fn getpid() -> ::c_int;
    |     -------------------------- similarly named function `getpid` defined here

error[E0425]: cannot find function `getgroups` in crate `libc`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:745:15
    |
745 |         libc::getgroups(1024, buff.as_mut_ptr())
    |               ^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `buff` in this scope
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:783:21
    |
783 |     let mut count = buff.len() as c_int;
    |                     ^^^^ not found in this scope

error[E0425]: cannot find value `res` in this scope
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:799:8
    |
799 |     if res < 0 {
    |        ^^^ not found in this scope

error[E0425]: cannot find value `buff` in this scope
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:803:9
    |
803 |         buff.dedup();
    |         ^^^^ not found in this scope

error[E0425]: cannot find value `buff` in this scope
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:804:9
    |
804 |         buff.into_iter()
    |         ^^^^ not found in this scope

error[E0425]: cannot find function `setpwent` in crate `libc`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:858:11
    |
858 |     libc::setpwent();
    |           ^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `endpwent` in crate `libc`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:873:24
    |
873 |         unsafe { libc::endpwent() };
    |                        ^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `getpwent` in crate `libc`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:890:37
    |
890 |         let result = unsafe { libc::getpwent() };
    |                                     ^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `setuid` in crate `libc`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\switch.rs:41:26
    |
41  |     match unsafe { libc::setuid(uid) } {
    |                          ^^^^^^ help: a function with a similar name exists: `getpid`
    |
   ::: C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\libc-0.2.149\src\windows\mod.rs:491:5
    |
491 |     pub fn getpid() -> ::c_int;
    |     -------------------------- similarly named function `getpid` defined here

error[E0425]: cannot find function `setgid` in crate `libc`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\switch.rs:72:26
    |
72  |     match unsafe { libc::setgid(gid) } {
    |                          ^^^^^^ help: a function with a similar name exists: `getpid`
    |
   ::: C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\libc-0.2.149\src\windows\mod.rs:491:5
    |
491 |     pub fn getpid() -> ::c_int;
    |     -------------------------- similarly named function `getpid` defined here

error[E0425]: cannot find function `seteuid` in crate `libc`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\switch.rs:103:26
    |
103 |     match unsafe { libc::seteuid(uid) } {
    |                          ^^^^^^^ not found in `libc`

error[E0425]: cannot find function `setegid` in crate `libc`
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\switch.rs:134:26
    |
134 |     match unsafe { libc::setegid(gid) } {
    |                          ^^^^^^^ not found in `libc`

error[E0599]: no function or associated item named `from_bytes` found for struct `OsStr` in the current scope
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:252:20
    |
252 |     T::from(OsStr::from_bytes(CStr::from_ptr(p).to_bytes()))
    |                    ^^^^^^^^^^ function or associated item not found in `OsStr`

error[E0599]: no method named `as_bytes` found for reference `&OsStr` in the current scope
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:380:57
    |
380 |     let username = match CString::new(username.as_ref().as_bytes()) {
    |                                                         ^^^^^^^^ method not found in `&OsStr`

   Compiling unicode-normalization v0.1.22
error[E0599]: no method named `as_bytes` found for reference `&OsStr` in the current scope
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:495:59
    |
495 |     let groupname = match CString::new(groupname.as_ref().as_bytes()) {
    |                                                           ^^^^^^^^ method not found in `&OsStr`

error[E0599]: no method named `as_bytes` found for reference `&OsStr` in the current scope
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\base.rs:782:47
    |
782 |     let name = CString::new(username.as_ref().as_bytes()).unwrap();
    |                                               ^^^^^^^^ method not found in `&OsStr`

error[E0282]: type annotations needed
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\cache.rs:207:43
    |
207 |             Occupied(e) => return e.get().as_ref().map(Arc::clone),
    |                                           ^^^^^^ cannot infer type for type parameter `V`

error[E0282]: type annotations needed
   --> C:\Users\Nanao\.cargo\registry\src\index.crates.io-6f17d22bba15001f\users-0.11.0\src\cache.rs:288:43
    |
288 |             Occupied(e) => return e.get().as_ref().map(Arc::clone),
    |                                           ^^^^^^ cannot infer type for type parameter `V`

Some errors have detailed explanations: E0282, E0412, E0425, E0432, E0433, E0599.
For more information about an error, try `rustc --explain E0282`.
error: could not compile `users` (lib) due to 41 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `exa v0.10.1`, intermediate artifacts can be found at `C:\Users\Nanao\AppData\Local\Temp\cargo-installiJkMjV`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

C:\Users\Nanao\Project\study\proc-macro-workshop\builder>cargo install libc
    Updating crates.io index
error: there is nothing to install in `libc v0.2.149`, because it has no binaries
`cargo install` is only for installing programs, and can't be used with libraries.
To use a library crate, add it as a dependency to a Cargo project with `cargo add`.

とまあこんな感じなので、バックドア的な方法でインストールしてあげる必要があります。

以下のようにgitリポジトリを直接指定上げることでとりあえずインストールができます。

cargo install --git https://github.com/zkat/exa

はい、これで使えるようになりました。

> exa
study  tools

まとめ

今はWindows版の正式リリースを待つばかりです。。

参考