nushell: nu-0.59.1 build failure

Describe the bug

nu-0.59.1 from commit 9db356e174288e74f7b5374d679b72907731eb70 fails to build on NetBSD.

First attempt to build fails since NetBSD libc doesn’t support trash-support

I’ve disabled this feature at build time and have the following features enabled, “plugin”, “which”, “zip-support”.

But, I’m hitting the following build error,

Compiling nu-command v0.59.1 (/usr/pkgsrc/wip/nushell/work/nushell-9db356e174288e74f7b5374d679b72907731eb70/crates/nu-command)
error[E0425]: cannot find function `collect_proc` in crate `nu_system`
  --> crates/nu-command/src/system/ps.rs:74:28
   |
74 |     for proc in nu_system::collect_proc(Duration::from_millis(100), false) {
   |                            ^^^^^^^^^^^^ not found in `nu_system`

For more information about this error, try `rustc --explain E0425`.
error: could not compile `nu-command` due to previous error
*** Error code 101

Stop.

How to reproduce

Build nu from git-HEAD

Expected behavior

Build finishes successfully.

Screenshots

No response

Configuration

No response

Additional context

OS: NetBSD-current (9.99.94) Rust: 1.59.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 47 (31 by maintainers)

Most upvoted comments

The first thing that comes to mind for me is to lay out a barebones implementation of ProcessInfo, where we can make use of a handy macro that Rust provides called todo!(). This satisfies the compiler’s needs to a certain degree, so that it doesn’t scream back saying the method doesn’t exist. We’ll do this for every function, until we can begin the real work and actually implement the functionalities that ProcessInfo exposes.

I’ll begin by setting up my NetBSD environment, after which I’ll fork the repository and make a draft PR.

@0323pin We plan on releasing 0.68.0 on Sept 6

This was unexpected … yes, looking at the changes, it should have fixed it. I’ll try a build when I find the time and report back. Let’s keep this open until then. Thanks for reaching out.

@fdncred Thanks.

@0323pin if you look at this function, you can see what each platform (Mac, linux, windows) is returning by looking at the cols.push() lines. https://github.com/nushell/nushell/blob/8a9cc33aacf978d95617f79252025a7204d0109d/crates/nu-command/src/system/ps.rs#L69-L149

I could help you achieve that, but I’ll have to setup a new NetBSD environment from scratch, which could take me a while due to my terrible internet connection. Would you like me to do that?

It looks like the easiest solution from here may be to change run_ps() to something like this below, where it checks to see if the process_info is empty, which it should be if it’s coming from other.rs. At least it’s something to play around with.

fn run_ps(engine_state: &EngineState, call: &Call) -> Result<PipelineData, ShellError> {
    let mut output = vec![];
    let span = call.head;
    let long = call.has_flag("long");

    let process_info = nu_system::collect_proc(Duration::from_millis(100), false);
    if !process_info.is_empty() {
        for proc in process_info {
            let mut cols = vec![];
            let mut vals = vec![];

            cols.push("pid".to_string());
            vals.push(Value::Int {
                val: proc.pid() as i64,
                span,
            });

            cols.push("name".to_string());
            vals.push(Value::String {
                val: proc.name(),
                span,
            });

            #[cfg(not(windows))]
            {
                // Hide status on Windows until we can find a good way to support it
                cols.push("status".to_string());
                vals.push(Value::String {
                    val: proc.status(),
                    span,
                });
            }

            cols.push("cpu".to_string());
            vals.push(Value::Float {
                val: proc.cpu_usage(),
                span,
            });

            cols.push("mem".to_string());
            vals.push(Value::Filesize {
                val: proc.mem_size() as i64,
                span,
            });

            cols.push("virtual".to_string());
            vals.push(Value::Filesize {
                val: proc.virtual_size() as i64,
                span,
            });

            if long {
                cols.push("command".to_string());
                vals.push(Value::String {
                    val: proc.command(),
                    span,
                });
                #[cfg(windows)]
                {
                    cols.push("cwd".to_string());
                    vals.push(Value::String {
                        val: proc.cwd(),
                        span,
                    });
                    cols.push("environment".to_string());
                    vals.push(Value::List {
                        vals: proc
                            .environ()
                            .iter()
                            .map(|x| Value::string(x.to_string(), span))
                            .collect(),
                        span,
                    });
                }
            }

            output.push(Value::Record { cols, vals, span });
        }
    }

    Ok(output
        .into_iter()
        .into_pipeline_data(engine_state.ctrlc.clone()))
}

others.rs needs to be here /crates/nu-system/src/others.rs and the lib.rs that needs changing is /crates/nu-system/src/lib.rs