Build.rs panics but build is reported as successful (Nightly)


#1

Hi all

I’m writing a build.rs file and when it panics cargo still reports a successful build. Have I
done anything wrong or have I stumbled upon an issue?

My build.rs

use std::process::Command;
use std::env;

fn main() {                                                    
    let output = Command::new("pg_tmp").output().expect(       
        "failed to execute pg_tmp",                            
    );                                                         
    let key = "DATABASE_URL".to_owned();                       
    let database_url = String::from_utf8_lossy(&output.stdout);
    env::set_var(&key, database_url.as_ref());                 
    Command::new("diesel").args(&["setup"]).status().unwrap(); 
    Command::new("diesel")                                     
        .args(&["migration", "run"])                           
        .status()                                              
        .unwrap();                                             
    println!("rustc-env={}={:?}", &key, &database_url);        
}

I still get a successful build and panic when manually running the diesel migrations.

$ cargo build && cat target/debug/build/project-*/output
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running migration 20171014183009
syntax error at or near ")"
Running migration 20171014183009
syntax error at or near ")"
rustc-env=DATABASE_URL="postgresql:///test?host=%2Ftmp%2Fephemeralpg.kZPAJM"

Version info

$ cargo --version
cargo 0.23.0-nightly (e447ac7e9 2017-09-27)
$ rustc --version
rustc 1.22.0-nightly (dcbbfb6e8 2017-10-12)

#2

Where is it panicing? From the output, the last line of the script has run.

You probably want to check the contents of the status of the command.


#3

Yeah it seems like I had some old output still left, it seems to work good now.

Sorry for the noise