nuta / nsh

A command-line shell like fish, but POSIX compatible.
906 stars 34 forks source link

multiple errors while with installing with cargo install #49

Open amethystgosling opened 9 months ago

amethystgosling commented 9 months ago
error[E0432]: unresolved imports `nix::unistd::fork`, `nix::unistd::setpgid`, `nix::unistd::ForkResult`, `nix::unistd::Pid`
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nsh-0.4.2/src/eval.rs:13:26
    |
13  | use nix::unistd::{close, fork, pipe, setpgid, ForkResult, Pid};
    |                          ^^^^        ^^^^^^^  ^^^^^^^^^^  ^^^ no `Pid` in `unistd`
    |                          |           |        |
    |                          |           |        no `ForkResult` in `unistd`
    |                          |           no `setpgid` in `unistd`
    |                          no `fork` in `unistd`
    |
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:291:15
    |
291 | pub unsafe fn fork() -> Result<ForkResult> {
    |               ^^^^
    = note: the item is gated behind the `process` feature
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:331:8
    |
331 | pub fn setpgid(pid: Pid, pgid: Pid) -> Result<()> {
    |        ^^^^^^^
    = note: the item is gated behind the `process` feature
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:227:10
    |
227 | pub enum ForkResult {
    |          ^^^^^^^^^^
    = note: the item is gated behind the `process` feature
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:183:12
    |
183 | pub struct Pid(pid_t);
    |            ^^^
    = note: the item is gated behind the `process` feature

error[E0432]: unresolved imports `nix::sys::signal::kill`, `nix::sys::signal::sigaction`, `nix::sys::signal::SaFlags`, `nix::sys::signal::SigAction`, `nix::sys::signal::SigHandler`, `nix::sys::signal::SigSet`, `nix::sys::signal::Signal`
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nsh-0.4.2/src/process.rs:10:24
    |
10  | use nix::sys::signal::{kill, sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal};
    |                        ^^^^  ^^^^^^^^^  ^^^^^^^  ^^^^^^^^^  ^^^^^^^^^^  ^^^^^^  ^^^^^^ no `Signal` in `sys::signal`
    |                        |     |          |        |          |           |
    |                        |     |          |        |          |           no `SigSet` in `sys::signal`
    |                        |     |          |        |          no `SigHandler` in `sys::signal`
    |                        |     |          |        no `SigAction` in `sys::signal`
    |                        |     |          no `SaFlags` in `sys::signal`
    |                        |     no `sigaction` in `sys::signal`
    |                        no `kill` in `sys::signal`
    |
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/sys/signal.rs:974:8
    |
974 | pub fn kill<T: Into<Option<Signal>>>(pid: Pid, signal: T) -> Result<()> {
    |        ^^^^
    = note: the item is gated behind the `signal` feature
    = help: consider importing this struct instead:
            libc::sigaction
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/sys/signal.rs:810:15
    |
810 | pub unsafe fn sigaction(signal: Signal, sigaction: &SigAction) -> Result<SigAction> {
    |               ^^^^^^^^^
    = note: the item is gated behind the `signal` feature
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/sys/signal.rs:679:12
    |
679 | pub struct SigAction {
    |            ^^^^^^^^^
    = note: the item is gated behind the `signal` feature
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/sys/signal.rs:663:10
    |
663 | pub enum SigHandler {
    |          ^^^^^^^^^^
    = note: the item is gated behind the `signal` feature
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/sys/signal.rs:490:12
    |
490 | pub struct SigSet {
    |            ^^^^^^
    = note: the item is gated behind the `signal` feature
    = help: consider importing this variant instead:
            signal_hook::iterator::backend::PollResult::Signal

error[E0433]: failed to resolve: could not find `termios` in `sys`
  --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nsh-0.4.2/src/process.rs:11:15
   |
11 | use nix::sys::termios::{tcgetattr, tcsetattr, SetArg::TCSADRAIN, Termios};
   |               ^^^^^^^ could not find `termios` in `sys`

error[E0432]: unresolved import `nix::sys::termios`
  --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nsh-0.4.2/src/process.rs:11:15
   |
11 | use nix::sys::termios::{tcgetattr, tcsetattr, SetArg::TCSADRAIN, Termios};
   |               ^^^^^^^ could not find `termios` in `sys`

error[E0432]: unresolved import `nix::sys::wait`
  --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nsh-0.4.2/src/process.rs:12:15
   |
12 | use nix::sys::wait::{waitpid, WaitPidFlag, WaitStatus};
   |               ^^^^ could not find `wait` in `sys`

error[E0432]: unresolved imports `nix::unistd::dup2`, `nix::unistd::execv`, `nix::unistd::fork`, `nix::unistd::getpid`, `nix::unistd::setpgid`, `nix::unistd::tcsetpgrp`, `nix::unistd::ForkResult`, `nix::unistd::Pid`
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nsh-0.4.2/src/process.rs:13:26
    |
13  | use nix::unistd::{close, dup2, execv, fork, getpid, setpgid, tcsetpgrp, ForkResult, Pid};
    |                          ^^^^  ^^^^^  ^^^^  ^^^^^^  ^^^^^^^  ^^^^^^^^^  ^^^^^^^^^^  ^^^ no `Pid` in `unistd`
    |                          |     |      |     |       |        |          |
    |                          |     |      |     |       |        |          no `ForkResult` in `unistd`
    |                          |     |      |     |       |        no `tcsetpgrp` in `unistd`
    |                          |     |      |     |       no `setpgid` in `unistd`
    |                          |     |      |     no `getpid` in `unistd`
    |                          |     |      no `fork` in `unistd`
    |                          |     no `execv` in `unistd`
    |                          no `dup2` in `unistd`
    |
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:440:8
    |
440 | pub fn dup2(oldfd: RawFd, newfd: RawFd) -> Result<RawFd> {
    |        ^^^^
    = note: the item is gated behind the `fs` feature
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:824:8
    |
824 | pub fn execv<S: AsRef<CStr>>(path: &CStr, argv: &[S]) -> Result<Infallible> {
    |        ^^^^^
    = note: the item is gated behind the `process` feature
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:291:15
    |
291 | pub unsafe fn fork() -> Result<ForkResult> {
    |               ^^^^
    = note: the item is gated behind the `process` feature
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:307:8
    |
307 | pub fn getpid() -> Pid {
    |        ^^^^^^
    = note: the item is gated behind the `process` feature
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:331:8
    |
331 | pub fn setpgid(pid: Pid, pgid: Pid) -> Result<()> {
    |        ^^^^^^^
    = note: the item is gated behind the `process` feature
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:379:8
    |
379 | pub fn tcsetpgrp(fd: c_int, pgrp: Pid) -> Result<()> {
    |        ^^^^^^^^^
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:227:10
    |
227 | pub enum ForkResult {
    |          ^^^^^^^^^^
    = note: the item is gated behind the `process` feature
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:183:12
    |
183 | pub struct Pid(pid_t);
    |            ^^^
    = note: the item is gated behind the `process` feature

error[E0432]: unresolved import `nix::sys::termios`
 --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nsh-0.4.2/src/shell.rs:8:15
  |
8 | use nix::sys::termios::{tcgetattr, Termios};
  |               ^^^^^^^ could not find `termios` in `sys`

error[E0432]: unresolved imports `nix::unistd::getpid`, `nix::unistd::Pid`
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nsh-0.4.2/src/shell.rs:9:19
    |
9   | use nix::unistd::{getpid, Pid};
    |                   ^^^^^^  ^^^ no `Pid` in `unistd`
    |                   |
    |                   no `getpid` in `unistd`
    |
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:307:8
    |
307 | pub fn getpid() -> Pid {
    |        ^^^^^^
    = note: the item is gated behind the `process` feature
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:183:12
    |
183 | pub struct Pid(pid_t);
    |            ^^^
    = note: the item is gated behind the `process` feature

error[E0432]: unresolved imports `nix::sys::signal::sigaction`, `nix::sys::signal::SaFlags`, `nix::sys::signal::SigAction`, `nix::sys::signal::SigHandler`, `nix::sys::signal::SigSet`, `nix::sys::signal::Signal`
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nsh-0.4.2/src/main.rs:48:24
    |
48  | use nix::sys::signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal};
    |                        ^^^^^^^^^  ^^^^^^^  ^^^^^^^^^  ^^^^^^^^^^  ^^^^^^  ^^^^^^ no `Signal` in `sys::signal`
    |                        |          |        |          |           |
    |                        |          |        |          |           no `SigSet` in `sys::signal`
    |                        |          |        |          no `SigHandler` in `sys::signal`
    |                        |          |        no `SigAction` in `sys::signal`
    |                        |          no `SaFlags` in `sys::signal`
    |                        no `sigaction` in `sys::signal`
    |
    = help: consider importing this struct instead:
            libc::sigaction
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/sys/signal.rs:810:15
    |
810 | pub unsafe fn sigaction(signal: Signal, sigaction: &SigAction) -> Result<SigAction> {
    |               ^^^^^^^^^
    = note: the item is gated behind the `signal` feature
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/sys/signal.rs:679:12
    |
679 | pub struct SigAction {
    |            ^^^^^^^^^
    = note: the item is gated behind the `signal` feature
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/sys/signal.rs:663:10
    |
663 | pub enum SigHandler {
    |          ^^^^^^^^^^
    = note: the item is gated behind the `signal` feature
note: found an item that was configured out
   --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/sys/signal.rs:490:12
    |
490 | pub struct SigSet {
    |            ^^^^^^
    = note: the item is gated behind the `signal` feature
    = help: consider importing this variant instead:
            signal_hook::iterator::backend::PollResult::Signal

error[E0425]: cannot find function `isatty` in module `nix::unistd`
    --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nsh-0.4.2/src/macros.rs:4:22
     |
4    |         nix::unistd::isatty(std::io::stdout().as_raw_fd()).unwrap_or(false)
     |                      ^^^^^^ not found in `nix::unistd`
     |
note: found an item that was configured out
    --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:1264:8
     |
1264 | pub fn isatty(fd: RawFd) -> Result<bool> {
     |        ^^^^^^
     = note: the item is gated behind the `fs` feature
help: consider importing this function
     |
1    + use libc::isatty;
     |
help: if you import `isatty`, refer to it directly
     |
4    -         nix::unistd::isatty(std::io::stdout().as_raw_fd()).unwrap_or(false)
4    +         isatty(std::io::stdout().as_raw_fd()).unwrap_or(false)
     |

error[E0425]: cannot find function `gethostname` in module `unistd`
    --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nsh-0.4.2/src/prompt.rs:131:33
     |
131  |     let hostname_cstr = unistd::gethostname(&mut hostname_buf).expect("failed to get hostname");
     |                                 ^^^^^^^^^^^ not found in `unistd`
     |
note: found an item that was configured out
    --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:1056:8
     |
1056 | pub fn gethostname() -> Result<OsString> {
     |        ^^^^^^^^^^^
     = note: the item is gated behind the `hostname` feature
help: consider importing one of these items
     |
1    + use crate::prompt::libc::gethostname;
     |
1    + use libc::gethostname;
     |
help: if you import `gethostname`, refer to it directly
     |
131  -     let hostname_cstr = unistd::gethostname(&mut hostname_buf).expect("failed to get hostname");
131  +     let hostname_cstr = gethostname(&mut hostname_buf).expect("failed to get hostname");
     |

error[E0425]: cannot find function `fsync` in module `unistd`
    --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nsh-0.4.2/src/utils.rs:57:17
     |
57   |         unistd::fsync(self.fd).ok();
     |                 ^^^^^ not found in `unistd`
     |
note: found an item that was configured out
    --> /home/danish/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.27.1/src/unistd.rs:1410:8
     |
1410 | pub fn fsync(fd: RawFd) -> Result<()> {
     |        ^^^^^
     = note: the item is gated behind the `fs` feature
help: consider importing this function
     |
1    + use libc::fsync;
     |
help: if you import `fsync`, refer to it directly
     |
57   -         unistd::fsync(self.fd).ok();
57   +         fsync(self.fd).ok();
     |

PS: Please keep in mind that I know I am not a dev, I just a noob EndeavourOS (ArchLinux) user who just wants to use this shell so clear instructions on how to get logs or more/better error messages would be appreciated. Because of that I might have included something other than the error messages in the code. Sorry for that if I did.

xeoslaenor commented 9 months ago

Hello, I get the same error here and could not try nsh so

xeoslaenor commented 9 months ago

It seems that nix 0.26.4 is the last to have these functions inside I have 0.27.1 version of nix on my system

Probably this change : https://github.com/nix-rust/nix/pull/2091/commits All features are now disabled by default and should be explicitly enabled

SteveLauC commented 6 months ago

Hi @xeoslaenor @amethylghostling, Nix maintainer here, Nix has introduced feature gates in a specific version in the past, so to use these functions, one has to turn on the corresponding feature, e.g., for fork(), the feature is process.

nsh does not handle this, so you have to fork it and enable the feature yourself.