Repository: tailhook/vagga (language: rust)

Issue:
Rust 2018
Need for #555

As we have to refactor crate imports anyway to be able to use async feature. So which one do you prefer?

An old way:

```rust
#[cfg(feature="containers")]
use crate::builder::context::Context;
#[cfg(feature="containers")]
use crate::builder::packages;
#[cfg(feature="containers")]
use crate::builder::commands::generic::{run_command_at_env, capture_command};
use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
use crate::file_util::copy;
```

or a compact one:

```rust
#[cfg(feature="containers")]
use crate::{
    builder::context::Context,
    builder::packages,
    builder::commands::generic::{run_command_at_env, capture_command},
};
use crate::{
    build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard},
    file_util::copy,
};
```


Discussion / hints:

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index 4158f481..daa19f41 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,6 +2,7 @@
 name = "vagga"
 version = "0.8.1"
 authors = ["Paul Colomiets"]
+edition = "2021"
 
 [workspace]
 members = ["path_filter"]
diff --git a/path_filter/Cargo.toml b/path_filter/Cargo.toml
index b12ba7c0..cc595d67 100644
--- a/path_filter/Cargo.toml
+++ b/path_filter/Cargo.toml
@@ -2,6 +2,7 @@
 name = "path-filter"
 version = "0.1.0"
 license = "MIT/Apache-2.0"
+edition = "2021"
 
 [dependencies]
 globset = "0.4.1"
diff --git a/path_filter/src/lib.rs b/path_filter/src/lib.rs
index 6ac1a84a..77ec6670 100644
--- a/path_filter/src/lib.rs
+++ b/path_filter/src/lib.rs
@@ -1,13 +1,9 @@
-extern crate globset;
-extern crate regex;
-extern crate walkdir;
-#[macro_use] extern crate quick_error;
-
 use std::collections::HashSet;
 use std::path::{Path, PathBuf};
 use std::rc::Rc;
 
 use globset::{Error as GlobError, GlobBuilder, GlobSet, GlobSetBuilder};
+use quick_error::quick_error;
 use regex::{Error as RegexError, Regex};
 use walkdir::{DirEntry, Error as WalkDirError, IntoIter as WalkDirIter};
 use walkdir::{WalkDir};
diff --git a/src/build_step.rs b/src/build_step.rs
index 6b6ba3c4..8ebce9fc 100644
--- a/src/build_step.rs
+++ b/src/build_step.rs
@@ -1,11 +1,13 @@
 use std::rc::Rc;
 use std::fmt::Debug;
 
+use mopa::mopafy;
+
 // Convenient reexports
-pub use version::{Error as VersionError};
-pub use builder::{StepError, Guard};
-pub use config::Config;
-pub use digest::Digest;
+pub use crate::builder::{Guard, StepError};
+pub use crate::config::Config;
+pub use crate::digest::Digest;
+pub use crate::version::{Error as VersionError};
 
 #[derive(Clone, Debug)]
 pub struct Step(pub Rc<dyn BuildStep>);
diff --git a/src/builder/commands/alpine.rs b/src/builder/commands/alpine.rs
index ef5205e5..1fe7d096 100644
--- a/src/builder/commands/alpine.rs
+++ b/src/builder/commands/alpine.rs
@@ -4,20 +4,22 @@ use std::fmt::{Write as WriteFmt};
 use std::path::Path;
 
 use quire::validate as V;
+use regex::Regex;
 #[cfg(feature="containers")]
 use unshare::{Command, Stdio};
-use regex::Regex;
 
-#[cfg(feature="containers")] use builder::context::{Context};
-#[cfg(feature="containers")] use capsule::packages as capsule;
-#[cfg(feature="containers")] use builder::packages;
-#[cfg(feature="containers")] use file_util::Dir;
-#[cfg(feature="containers")] use process_util::{CaptureOutput, capture_output};
-#[cfg(feature="containers")] use builder::distrib::{Distribution, Named, DistroBox};
-use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
-use config::version::Version;
 #[cfg(feature="containers")]
-use builder::dns::revert_name_files;
+use crate::{
+    builder::context::Context,
+    builder::distrib::{Distribution, DistroBox, Named},
+    builder::dns::revert_name_files,
+    builder::packages,
+    capsule::packages as capsule,
+    file_util::Dir,
+    process_util::{capture_output, CaptureOutput},
+};
+use crate::build_step::{BuildStep, Config, Digest, Guard, StepError, VersionError};
+use crate::config::version::Version;
 
 
 pub static LATEST_VERSION: &'static str = "v3.15";
diff --git a/src/builder/commands/composer.rs b/src/builder/commands/composer.rs
index 3c7b90ee..d830ffc1 100644
--- a/src/builder/commands/composer.rs
+++ b/src/builder/commands/composer.rs
@@ -3,23 +3,24 @@ use std::fs::{self, File};
 use std::io::{self, Write};
 use std::os::unix;
 
-#[cfg(feature="containers")] use unshare::{Command};
-use scan_dir::{self, ScanDir};
+use quire::validate as V;
 use regex::Regex;
+use scan_dir::{self, ScanDir};
 use serde_json::{Value as Json, from_reader};
-use quire::validate as V;
+#[cfg(feature="containers")]
+use unshare::{Command};
 
-#[cfg(feature="containers")] use builder::context::{Context};
-#[cfg(feature="containers")] use builder::packages;
 #[cfg(feature="containers")]
-use builder::commands::generic::{run_command, capture_command};
-#[cfg(feature="containers")] use builder::distrib::Distribution;
-#[cfg(feature="containers")] use builder::commands::generic::{command, run};
-#[cfg(feature="containers")] use capsule::download;
-#[cfg(feature="containers")] use file_util::Dir;
-#[cfg(feature="containers")] use process_util::{CaptureOutput, capture_output};
-#[cfg(feature="containers")] use file_util;
-use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
+use crate::{
+    builder::context::Context,
+    builder::packages,
+    builder::commands::generic::{capture_command, command, run, run_command},
+    builder::distrib::Distribution,
+    capsule::download,
+    file_util::{self, Dir},
+    process_util::{capture_output, CaptureOutput},
+};
+use crate::build_step::{BuildStep, Config, Digest, Guard, StepError, VersionError};
 
 const DEFAULT_RUNTIME: &'static str = "/usr/bin/php";
 const DEFAULT_INCLUDE_PATH: &'static str = ".:/usr/local/lib/composer";
diff --git a/src/builder/commands/copy.rs b/src/builder/commands/copy.rs
index b7a1729f..cd62c60a 100644
--- a/src/builder/commands/copy.rs
+++ b/src/builder/commands/copy.rs
@@ -5,19 +5,19 @@ use std::os::unix::fs::{PermissionsExt, MetadataExt};
 use std::collections::{BTreeMap, BTreeSet, HashSet};
 
 use libc::{uid_t, gid_t};
+#[cfg(feature="containers")]
+use path_filter::{PathFilter, FilterError};
+use quick_error::ResultExt;
 use quire::ast::{Ast, Tag};
 use quire::validate as V;
 
 #[cfg(feature="containers")]
-use path_filter::{PathFilter, FilterError};
-#[cfg(feature="containers")]
-use container::root::temporary_change_root;
-#[cfg(feature="containers")]
-use file_util::ShallowCopy;
-#[cfg(feature="containers")]
-use path_util::IterSelfAndParents;
-use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
-use quick_error::ResultExt;
+use crate::{
+    container::root::temporary_change_root,
+    file_util::ShallowCopy,
+    path_util::IterSelfAndParents,
+};
+use crate::build_step::{BuildStep, Config, Digest, Guard, StepError, VersionError};
 
 
 const DEFAULT_UMASK: u32 = 0o002;
diff --git a/src/builder/commands/dirs.rs b/src/builder/commands/dirs.rs
index f690272d..b16de71f 100644
--- a/src/builder/commands/dirs.rs
+++ b/src/builder/commands/dirs.rs
@@ -1,15 +1,16 @@
 use std::io;
 use std::fs::remove_file;
 use std::collections::BTreeMap;
+use std::path::{Path, PathBuf};
 
 use quire::validate as V;
 
-use std::path::{Path, PathBuf};
-#[cfg(feature="containers")]
-use container::util::{clean_dir};
-use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
 #[cfg(feature="containers")]
-use file_util::Dir;
+use crate::{
+    container::util::clean_dir,
+    file_util::Dir,
+};
+use crate::build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
 
 
 #[derive(Debug, Serialize, Deserialize)]
diff --git a/src/builder/commands/download.rs b/src/builder/commands/download.rs
index a29585da..ba43cca0 100644
--- a/src/builder/commands/download.rs
+++ b/src/builder/commands/download.rs
@@ -3,7 +3,13 @@ use std::fs::{set_permissions, Permissions};
 use std::os::unix::fs::PermissionsExt;
 
 use quire::validate as V;
-use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
+
+#[cfg(feature="containers")]
+use crate::{
+    capsule::download::maybe_download_and_check_hashsum,
+    file_util::copy,
+};
+use crate::build_step::{BuildStep, Config, Digest, Guard, StepError, VersionError};
 
 
 #[derive(Serialize, Deserialize, Debug)]
@@ -44,9 +50,6 @@ impl BuildStep for Download {
     fn build(&self, guard: &mut Guard, build: bool)
         -> Result<(), StepError>
     {
-        use capsule::download::maybe_download_and_check_hashsum;
-        use file_util::copy;
-
         if build {
             let fpath = PathBuf::from("/vagga/root")
                 .join(self.path.strip_prefix("/").unwrap());
diff --git a/src/builder/commands/gem.rs b/src/builder/commands/gem.rs
index 877a8b21..54b272c0 100644
--- a/src/builder/commands/gem.rs
+++ b/src/builder/commands/gem.rs
@@ -6,18 +6,14 @@ use regex::Regex;
 use quire::validate as V;
 
 #[cfg(feature="containers")]
-use builder::context::Context;
-#[cfg(feature="containers")]
-use builder::packages;
-#[cfg(feature="containers")]
-use builder::commands::generic::{capture_command, run_command_at_env};
-#[cfg(feature="containers")]
-use builder::distrib::Distribution;
-#[cfg(feature="containers")]
-use builder::commands::generic::{command, run};
-#[cfg(feature="containers")]
-use process_util::{CaptureOutput, capture_output};
-use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
+use crate::{
+    build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard},
+    builder::commands::generic::{command, capture_command, run, run_command_at_env},
+    builder::context::Context,
+    builder::distrib::Distribution,
+    builder::packages,
+    process_util::{CaptureOutput, capture_output},
+};
 
 const DEFAULT_GEM_EXE: &'static str = "/usr/bin/gem";
 const BIN_DIR: &'static str = "/usr/local/bin";
diff --git a/src/builder/commands/generic.rs b/src/builder/commands/generic.rs
index aaaac068..a990f614 100644
--- a/src/builder/commands/generic.rs
+++ b/src/builder/commands/generic.rs
@@ -10,12 +10,12 @@ use std::collections::BTreeMap;
 use quire::validate as V;
 
 #[cfg(feature="containers")]
-use builder::context::Context;
-#[cfg(feature="containers")]
-use process_util::{CaptureOutput, capture_output, run_success, cmd_show};
-use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
-#[cfg(feature="containers")]
-use launcher::network::create_isolated_network;
+use crate::{
+    builder::context::Context,
+    launcher::network::create_isolated_network,
+    process_util::{capture_output, CaptureOutput, cmd_show, run_success},
+};
+use crate::build_step::{BuildStep, Config, Digest, Guard, StepError, VersionError};
 
 // Build Steps
 #[derive(Debug, Serialize, Deserialize)]
diff --git a/src/builder/commands/npm.rs b/src/builder/commands/npm.rs
index ea629626..e78542b8 100644
--- a/src/builder/commands/npm.rs
+++ b/src/builder/commands/npm.rs
@@ -4,34 +4,31 @@ use std::fs::{self, File, remove_dir};
 use std::path::{Path, PathBuf};
 use std::collections::HashSet;
 
-#[cfg(feature="containers")] use libmount::BindMount;
+use lazy_static::lazy_static;
+
+#[cfg(feature="containers")]
+use libmount::BindMount;
 use quire::validate as V;
 use regex::Regex;
-use serde_json::{Value as Json, from_reader};
 use scan_dir;
-#[cfg(feature="containers")] use unshare::{Stdio};
-
-#[cfg(feature="containers")]
-use builder::commands::generic::{command, run};
-#[cfg(feature="containers")]
-use builder::distrib::{Distribution, DistroBox};
-#[cfg(feature="containers")]
-use builder::commands::ubuntu;
-use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
-#[cfg(feature="containers")]
-use capsule::download::download_file;
-#[cfg(feature="containers")]
-use container::mount::unmount;
-#[cfg(feature="containers")]
-use container::root::temporary_change_root;
-#[cfg(feature="containers")]
-use container::util::clean_dir;
-#[cfg(feature="containers")]
-use file_util::{safe_ensure_dir, copy, force_symlink};
+use serde_json::{Value as Json, from_reader};
 #[cfg(feature="containers")]
-use builder::context::{Context};
+use unshare::Stdio;
+
 #[cfg(feature="containers")]
-use builder::packages;
+use crate::{
+    builder::commands::ubuntu,
+    builder::commands::generic::{command, run},
+    builder::context::Context,
+    builder::distrib::{DistroBox, Distribution},
+    builder::packages,
+    capsule::download::download_file,
+    container::root::temporary_change_root,
+    container::mount::unmount,
+    container::util::clean_dir,
+    file_util::{copy, force_symlink, safe_ensure_dir},
+};
+use crate::build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
 
 lazy_static! {
     static ref YARN_PATTERN: Regex = Regex::new(r#""[^"]+"|[^,]+"#).unwrap();
diff --git a/src/builder/commands/packaging.rs b/src/builder/commands/packaging.rs
index dd4e41de..b1f6e131 100644
--- a/src/builder/commands/packaging.rs
+++ b/src/builder/commands/packaging.rs
@@ -1,6 +1,6 @@
 use quire::validate as V;
 
-use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
+use crate::build_step::{BuildStep, Config, Digest, Guard, StepError, VersionError};
 
 
 // Build Steps
diff --git a/src/builder/commands/pip.rs b/src/builder/commands/pip.rs
index 39194b3b..2d56b7b4 100644
--- a/src/builder/commands/pip.rs
+++ b/src/builder/commands/pip.rs
@@ -6,18 +6,18 @@ use std::str;
 
 use failure::Error;
 use quire::validate as V;
-use capsule::download;
-use file_util::copy;
-#[cfg(feature="containers")]
-use builder::context::{Context};
-#[cfg(feature="containers")]
-use builder::packages;
+
+use crate::build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
 #[cfg(feature="containers")]
-use builder::commands::generic::{run_command_at_env, capture_command};
-#[cfg(feature="containers")] use builder::distrib::Distribution;
-#[cfg(feature="containers")] use file_util::Dir;
-#[cfg(feature="containers")] use process_util::CaptureOutput;
-use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
+use crate::{
+    builder::commands::generic::{capture_command, run_command_at_env},
+    builder::context::Context,
+    builder::distrib::Distribution,
+    builder::packages,
+    capsule::download,
+    file_util::{copy, Dir},
+    process_util::CaptureOutput,
+};
 
 const PIP_HOME: &str = "/tmp/pip-install";
 const PYTHON_PATH: &str = PIP_HOME;
diff --git a/src/builder/commands/subcontainer.rs b/src/builder/commands/subcontainer.rs
index b419049d..8b6d1123 100644
--- a/src/builder/commands/subcontainer.rs
+++ b/src/builder/commands/subcontainer.rs
@@ -8,23 +8,20 @@ use quire::validate as V;
 use libmount::{BindMount, Remount};
 use quick_error::ResultExt;
 
-use config::read_config;
-use config::containers::Container as Cont;
-#[cfg(feature="containers")] use version::short_version;
-#[cfg(feature="containers")] use container::util::{copy_dir};
-#[cfg(feature="containers")] use file_util::{Dir, ShallowCopy};
-#[cfg(feature="containers")] use path_util::IterSelfAndParents;
-use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
-
-use builder::StepError as E;
-#[cfg(feature="containers")]
-use builder::dns::revert_name_files;
-#[cfg(feature="containers")]
-use builder::commands::copy::{create_path_filter, hash_path};
-#[cfg(feature="containers")]
-use builder::commands::copy::{DEFAULT_ATIME, DEFAULT_MTIME};
 #[cfg(feature="containers")]
-use builder::commands::copy::{hash_file_content};
+use crate::{
+    builder::commands::copy::{create_path_filter, hash_file_content, hash_path},
+    builder::commands::copy::{DEFAULT_ATIME, DEFAULT_MTIME},
+    builder::dns::revert_name_files,
+    version::short_version,
+    container::util::copy_dir,
+    file_util::{Dir, ShallowCopy},
+    path_util::IterSelfAndParents,
+};
+use crate::build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
+use crate::builder::StepError as E;
+use crate::config::read_config;
+use crate::config::containers::Container as Cont;
 
 // Build Steps
 #[derive(Debug, Serialize, Deserialize)]
diff --git a/src/builder/commands/tarcmd.rs b/src/builder/commands/tarcmd.rs
index 47a07732..67a94cc2 100644
--- a/src/builder/commands/tarcmd.rs
+++ b/src/builder/commands/tarcmd.rs
@@ -6,26 +6,23 @@ use std::os::unix::fs::{PermissionsExt, symlink};
 use std::path::{Path, PathBuf};
 use std::u32;
 
-#[cfg(feature="containers")] use tar::Archive;
-#[cfg(feature="containers")] use flate2::read::GzDecoder;
-#[cfg(feature="containers")] use xz2::read::XzDecoder;
 #[cfg(feature="containers")] use bzip2::read::BzDecoder;
+#[cfg(feature="containers")] use flate2::read::GzDecoder;
 #[cfg(feature="containers")] use libmount::BindMount;
+#[cfg(feature="containers")] use tar::Archive;
+#[cfg(feature="containers")] use xz2::read::XzDecoder;
 use quire::validate as V;
 
 #[cfg(feature="containers")]
-use capsule::download::{maybe_download_and_check_hashsum};
-#[cfg(feature="containers")]
-use container::mount::{unmount};
-#[cfg(feature="containers")]
-use builder::context::Context;
-#[cfg(feature="containers")]
-use builder::commands::generic::run_command_at;
-#[cfg(feature="containers")]
-use builder::dns::revert_name_files;
-#[cfg(feature="containers")]
-use file_util::{Dir, read_visible_entries, copy_stream, set_owner_group};
-use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
+use crate::{
+    build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard},
+    builder::commands::generic::run_command_at,
+    builder::context::Context,
+    builder::dns::revert_name_files,
+    capsule::download::{maybe_download_and_check_hashsum},
+    container::mount::{unmount},
+    file_util::{Dir, read_visible_entries, copy_stream, set_owner_group},
+};
 
 
 #[derive(Serialize, Deserialize, Debug)]
diff --git a/src/builder/commands/text.rs b/src/builder/commands/text.rs
index 043a8020..7d6622b5 100644
--- a/src/builder/commands/text.rs
+++ b/src/builder/commands/text.rs
@@ -5,7 +5,8 @@ use std::collections::BTreeMap;
 use std::os::unix::fs::PermissionsExt;
 
 use quire::validate as V;
-use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
+
+use crate::build_step::{BuildStep, Config, Digest, Guard, StepError, VersionError};
 
 
 #[derive(Debug, Serialize, Deserialize)]
diff --git a/src/builder/commands/ubuntu.rs b/src/builder/commands/ubuntu.rs
index 7268f267..03d705f7 100644
--- a/src/builder/commands/ubuntu.rs
+++ b/src/builder/commands/ubuntu.rs
@@ -5,19 +5,22 @@ use std::io::{self, BufReader, Write};
 use std::path::{Path, PathBuf};
 use std::ffi::OsStr;
 
-use quire::validate as V;
-#[cfg(feature="containers")] use unshare::{Stdio};
 #[cfg(feature="containers")] use scan_dir::ScanDir;
+#[cfg(feature="containers")] use unshare::Stdio;
+use quire::validate as V;
 
-use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
-#[cfg(feature="containers")] use builder::commands::generic::{command, run, find_cmd};
-#[cfg(feature="containers")] use builder::commands::tarcmd::unpack_file;
-#[cfg(feature="containers")] use builder::context::{Context};
-#[cfg(feature="containers")] use builder::distrib::{Distribution, Named, DistroBox};
-#[cfg(feature="containers")] use builder::dns::revert_name_files;
-#[cfg(feature="containers")] use builder::packages;
-#[cfg(feature="containers")] use container::util::clean_dir;
-#[cfg(feature="containers")] use file_util::{Dir, Lock, copy, copy_utime, safe_remove};
+#[cfg(feature="containers")]
+use crate::{
+    builder::commands::generic::{command, run, find_cmd},
+    builder::commands::tarcmd::unpack_file,
+    builder::context::Context,
+    builder::distrib::{Distribution, DistroBox, Named},
+    builder::dns::revert_name_files,
+    builder::packages,
+    container::util::clean_dir,
+    file_util::{Dir, Lock, copy, copy_utime, safe_remove},
+};
+use crate::build_step::{BuildStep, Config, Digest, Guard, StepError, VersionError};
 
 #[cfg(feature="containers")]
 use self::build::*;
@@ -866,10 +869,12 @@ impl BuildStep for UbuntuRelease {
 
 #[cfg(feature="containers")]
 mod build {
-    use std::os::unix::fs::{PermissionsExt};
     use std::io::BufRead;
-    use unshare::{Command};
-    use capsule::download::download_file;
+    use std::os::unix::fs::PermissionsExt;
+
+    use unshare::Command;
+
+    use crate::capsule::download::download_file;
 
     use super::*;
 
diff --git a/src/builder/commands/unzip.rs b/src/builder/commands/unzip.rs
index 9bd7a01e..80c9b916 100644
--- a/src/builder/commands/unzip.rs
+++ b/src/builder/commands/unzip.rs
@@ -8,12 +8,12 @@ use zip::ZipArchive;
 use quire::validate as V;
 
 #[cfg(feature="containers")]
-use builder::context::Context;
-#[cfg(feature="containers")]
-use capsule::download::maybe_download_and_check_hashsum;
-use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
-#[cfg(feature="containers")]
-use file_util::{Dir, copy_stream};
+use crate::{
+    builder::context::Context,
+    capsule::download::maybe_download_and_check_hashsum,
+    file_util::{copy_stream, Dir},
+};
+use crate::build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
 
 
 #[derive(Serialize, Deserialize, Debug, Clone)]
diff --git a/src/builder/commands/vcs.rs b/src/builder/commands/vcs.rs
index b944e285..cc24f405 100644
--- a/src/builder/commands/vcs.rs
+++ b/src/builder/commands/vcs.rs
@@ -12,16 +12,14 @@ use quire::validate as V;
 use unshare::{Command, Stdio};
 
 #[cfg(feature="containers")]
-use builder::commands::subcontainer::GitSource;
-#[cfg(feature="containers")]
-use capsule::packages as capsule;
-#[cfg(feature="containers")]
-use builder::context::Context;
-#[cfg(feature="containers")]
-use builder::commands::generic::run_command_at;
-use build_step::{BuildStep, VersionError, StepError, Digest, Config, Guard};
-#[cfg(feature="containers")]
-use process_util::run_success;
+use crate::{
+    builder::context::Context,
+    builder::commands::generic::run_command_at,
+    builder::commands::subcontainer::GitSource,
+    capsule::packages as capsule,
+    process_util::run_success,
+};
+use crate::build_step::{BuildStep, Config, Digest, Guard, StepError, VersionError};
 
 
 #[derive(Serialize, Deserialize, Debug)]
diff --git a/src/builder/context.rs b/src/builder/context.rs
index c7f346e9..eef21598 100644
--- a/src/builder/context.rs
+++ b/src/builder/context.rs
@@ -7,19 +7,18 @@ use std::sync::Arc;
 
 use libmount::BindMount;
 
-use container::util::clean_dir;
-use config::Config;
-use config::Container;
-use config::Settings;
-use builder::commands::composer::ComposerConfig;
-use builder::commands::gem::GemConfig;
-use builder::commands::pip::PipConfig;
-use builder::commands::npm::NpmConfig;
-use capsule;
+use crate::config::{Config, Container, Settings};
+use crate::container::util::clean_dir;
+use crate::builder::commands::composer::ComposerConfig;
+use crate::builder::commands::gem::GemConfig;
+use crate::builder::commands::pip::PipConfig;
+use crate::builder::commands::npm::NpmConfig;
+use crate::capsule;
+use crate::file_util::Dir;
+use crate::process_util::PROXY_ENV_VARS;
+
 use super::packages;
 use super::timer;
-use file_util::Dir;
-use process_util::PROXY_ENV_VARS;
 
 
 pub struct Context<'a> {
diff --git a/src/builder/distrib.rs b/src/builder/distrib.rs
index 5b1c6cee..8f19db17 100644
--- a/src/builder/distrib.rs
+++ b/src/builder/distrib.rs
@@ -1,9 +1,9 @@
-use mopa::Any;
+use mopa::{Any, mopafy};
 
-use builder::context::Context;
-use builder::commands::alpine;
-use builder::error::StepError;
-use builder::packages;
+use crate::builder::commands::alpine;
+use crate::builder::context::Context;
+use crate::builder::error::StepError;
+use crate::builder::packages;
 
 
 /// This returns the same as Distribution::name but is separate trait because
diff --git a/src/builder/dns.rs b/src/builder/dns.rs
index 19e62e99..bd095f61 100644
--- a/src/builder/dns.rs
+++ b/src/builder/dns.rs
@@ -1,6 +1,7 @@
-use file_util::copy;
 use std::fs::symlink_metadata;
 
+use crate::file_util::copy;
+
 /// Reverts resolv.conf and hosts files after they might be replaces by
 /// come container unpacking or copying
 pub fn revert_name_files() -> Result<(), String> {
diff --git a/src/builder/error.rs b/src/builder/error.rs
index 824e6df1..d1eef4a1 100644
--- a/src/builder/error.rs
+++ b/src/builder/error.rs
@@ -7,10 +7,11 @@ use scan_dir;
 use libmount;
 use path_filter;
 use git2;
+use quick_error::quick_error;
 
-use build_step::BuildStep;
-use builder::packages::Package;
-use process_util::{cmd_debug};
+use crate::build_step::BuildStep;
+use crate::builder::packages::Package;
+use crate::process_util::cmd_debug;
 
 
 quick_error! {
diff --git a/src/builder/guard.rs b/src/builder/guard.rs
index eb0e7d23..b3f21881 100644
--- a/src/builder/guard.rs
+++ b/src/builder/guard.rs
@@ -2,17 +2,18 @@ use std::path::Path;
 use std::fs::remove_file;
 use std::collections::HashMap;
 
-use builder::context::Context;
-use builder::distrib::{Unknown,Distribution};
-use builder::error::{Error};
-use builder::commands::{composer, gem, npm, pip, dirs};
-use builder::packages;
-use build_step::BuildStep;
-use container::util::{clean_dir, write_container_signature};
-use container::mount::{unmount, mount_system_dirs, mount_proc, mount_run};
-use container::mount::unmount_system_dirs;
-use file_util::{Dir, copy, truncate_file};
-use path_util::IterSelfAndParents;
+use crate::build_step::BuildStep;
+use crate::builder::context::Context;
+use crate::builder::distrib::{Unknown,Distribution};
+use crate::builder::error::{Error};
+use crate::builder::commands::{composer, gem, npm, pip, dirs};
+use crate::builder::packages;
+use crate::container::mount::{
+    unmount, mount_system_dirs, mount_proc, mount_run, unmount_system_dirs,
+};
+use crate::container::util::{clean_dir, write_container_signature};
+use crate::file_util::{Dir, copy, truncate_file};
+use crate::path_util::IterSelfAndParents;
 
 
 pub struct Guard<'a> {
diff --git a/src/builder/mod.rs b/src/builder/mod.rs
index d9952089..3613c75a 100644
--- a/src/builder/mod.rs
+++ b/src/builder/mod.rs
@@ -1,16 +1,18 @@
 use std::io::{stdout, stderr};
 use std::default::Default;
 use std::path::Path;
-use rand;
 
-use config::find_config_or_exit;
-use config::{Config, Container, Settings};
 use argparse::{ArgumentParser, Store, StoreTrue};
+use rand;
+
+use crate::config::{Config, Container, find_config_or_exit, Settings};
+
 
 #[cfg(feature="containers")]
-pub use self::guard::Guard;
-#[cfg(feature="containers")]
-pub use self::error::StepError;
+pub use self::{
+    guard::Guard,
+    error::StepError,
+};
 
 #[cfg(feature="containers")]
 pub mod context;
diff --git a/src/builder/packages.rs b/src/builder/packages.rs
index 2222fc07..f3b17ff6 100644
--- a/src/builder/packages.rs
+++ b/src/builder/packages.rs
@@ -1,10 +1,10 @@
-use builder::commands::composer;
-use builder::commands::gem;
-use builder::commands::npm;
-use builder::commands::pip;
-use builder::context::Context;
-use builder::distrib::Distribution;
-use builder::error::StepError;
+use crate::builder::commands::composer;
+use crate::builder::commands::gem;
+use crate::builder::commands::npm;
+use crate::builder::commands::pip;
+use crate::builder::context::Context;
+use crate::builder::distrib::Distribution;
+use crate::builder::error::StepError;
 
 pub use self::Package::*;
 
diff --git a/src/capsule/build.rs b/src/capsule/build.rs
index 475a6bba..eebd296c 100644
--- a/src/capsule/build.rs
+++ b/src/capsule/build.rs
@@ -2,8 +2,8 @@ use std::io::{stdout, stderr};
 
 use argparse::{ArgumentParser, Store, StoreTrue};
 
-use capsule::Context;
-use launcher::build::build_container;
+use crate::capsule::Context;
+use crate::launcher::build::build_container;
 
 
 pub fn build_command(context: &Context, args: Vec<String>)
diff --git a/src/capsule/download.rs b/src/capsule/download.rs
index 04f4a39b..0066dfe7 100644
--- a/src/capsule/download.rs
+++ b/src/capsule/download.rs
@@ -12,12 +12,11 @@ use digest_traits::Digest;
 use sha2::Sha256;
 use unshare::{Command, Stdio};
 
-use capsule::Context;
-use capsule::packages as capsule;
-use capsule::packages::State;
-use file_util::check_stream_hashsum;
-use process_util::{cmd_show};
-use digest::hex;
+use crate::capsule::{Context, packages as capsule};
+use crate::capsule::packages::State;
+use crate::digest::hex;
+use crate::file_util::check_stream_hashsum;
+use crate::process_util::cmd_show;
 
 
 pub fn download_file<S>(state: &mut State, urls: &[S], sha256: Option<String>,
diff --git a/src/capsule/mod.rs b/src/capsule/mod.rs
index 3b888a19..912e2f91 100644
--- a/src/capsule/mod.rs
+++ b/src/capsule/mod.rs
@@ -8,12 +8,13 @@ use std::io::{Write, stdout, stderr};
 
 use argparse::{ArgumentParser, Store, List};
 
-use launcher;
+use crate::launcher;
 
 pub use self::packages::State;
-pub type Context = launcher::Context;
 
 
+pub type Context = launcher::Context;
+
 pub fn run_command(context: &Context, mut input_args: Vec<String>)
     -> Result<i32, String>
 {
diff --git a/src/capsule/packages.rs b/src/capsule/packages.rs
index ca9855fc..e9e111d2 100644
--- a/src/capsule/packages.rs
+++ b/src/capsule/packages.rs
@@ -11,13 +11,13 @@ use std::io::{Write};
 use std::path::Path;
 use std::sync::Arc;
 
-use unshare::Command;
 use libmount::BindMount;
+use unshare::Command;
 
-use config::settings::Settings;
-use process_util::{squash_stdio, run_success};
-use builder::commands::alpine::LATEST_VERSION;
-use file_util::Dir;
+use crate::config::settings::Settings;
+use crate::builder::commands::alpine::LATEST_VERSION;
+use crate::file_util::Dir;
+use crate::process_util::{squash_stdio, run_success};
 
 pub use self::Feature::*;
 
diff --git a/src/capsule/run.rs b/src/capsule/run.rs
index 07a51920..39a9f60e 100644
--- a/src/capsule/run.rs
+++ b/src/capsule/run.rs
@@ -4,10 +4,10 @@ use argparse::{ArgumentParser};
 use argparse::{List, Store};
 use unshare::{Command};
 
-use capsule::Context;
-use launcher::wrap::Wrapper;
-use launcher::build::build_container;
-use process_util::{run_and_wait, convert_status};
+use crate::capsule::Context;
+use crate::launcher::build::build_container;
+use crate::launcher::wrap::Wrapper;
+use crate::process_util::{run_and_wait, convert_status};
 
 
 pub fn run_command(context: &Context, mut args: Vec<String>)
diff --git a/src/capsule/script.rs b/src/capsule/script.rs
index f5e08a2c..df87080f 100644
--- a/src/capsule/script.rs
+++ b/src/capsule/script.rs
@@ -7,11 +7,10 @@ use argparse::{ArgumentParser};
 use argparse::{List, Store, StoreOption, StoreTrue};
 use unshare::{Command};
 
-use capsule::Context;
-use capsule::packages::State;
-use capsule::download;
-use launcher::wrap::Wrapper;
-use process_util::{run_and_wait, convert_status};
+use crate::capsule::{Context, download};
+use crate::capsule::packages::State;
+use crate::launcher::wrap::Wrapper;
+use crate::process_util::{run_and_wait, convert_status};
 
 
 pub fn run_script(context: &Context, mut args: Vec<String>)
diff --git a/src/config/builders.rs b/src/config/builders.rs
index d3703514..47044253 100644
--- a/src/config/builders.rs
+++ b/src/config/builders.rs
@@ -1,13 +1,12 @@
 use std::fmt;
 use std::rc::Rc;
 
-use builder::commands as cmd;
 use quire::validate as V;
-use serde::de::{self, Deserializer, Deserialize};
+use serde::de::{self, Deserializer, Deserialize, EnumAccess, VariantAccess, Visitor};
 use serde::ser::{Serializer, Serialize};
-use serde::de::{VariantAccess, Visitor, EnumAccess};
 
-use build_step::{Step, BuildStep};
+use crate::build_step::{Step, BuildStep};
+use crate::builder::commands as cmd;
 
 macro_rules! define_commands {
     ($($module: ident :: $item: ident,)*) => {
diff --git a/src/config/command.rs b/src/config/command.rs
index b4ba495d..3182bc32 100644
--- a/src/config/command.rs
+++ b/src/config/command.rs
@@ -7,10 +7,11 @@ use quire::{Error, ErrorCollector, Pos};
 use quire::ast::{Ast, Ast as A};
 use quire::ast::Tag::{NonSpecific, LocalTag};
 
-use config::Range;
-use super::volumes::{Volume, volume_validator};
+use crate::config::Range;
 #[cfg(feature="containers")]
-use launcher::system::SystemInfo;
+use crate::launcher::system::SystemInfo;
+
+use super::volumes::{Volume, volume_validator};
 
 #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Copy)]
 #[allow(non_camel_case_types)]
diff --git a/src/config/containers.rs b/src/config/containers.rs
index b800cf8c..8a02bdfd 100644
--- a/src/config/containers.rs
+++ b/src/config/containers.rs
@@ -4,10 +4,11 @@ use std::rc::Rc;
 
 use quire::validate as V;
 
+use crate::build_step::{Step};
+
 use super::builders::{builder_validator};
 use super::volumes::{Volume, volume_validator};
 use super::Range;
-use build_step::{Step};
 
 
 #[derive(Serialize, Deserialize, Clone)]
diff --git a/src/config/read_settings.rs b/src/config/read_settings.rs
index a1a90698..591c5382 100644
--- a/src/config/read_settings.rs
+++ b/src/config/read_settings.rs
@@ -5,8 +5,8 @@ use std::path::{Path, PathBuf};
 use quire::{parse_config, parse_string, Options};
 use quire::validate as V;
 
-use config::Settings;
-use path_util::Expand;
+use crate::config::Settings;
+use crate::path_util::Expand;
 
 
 #[derive(PartialEq, Deserialize, Debug)]
diff --git a/src/config/validate.rs b/src/config/validate.rs
index b8003771..91466164 100644
--- a/src/config/validate.rs
+++ b/src/config/validate.rs
@@ -1,6 +1,7 @@
+use crate::build_step::Step;
+
 use super::Config;
 use super::containers::Container;
-use build_step::Step;
 
 fn find_name(name: &str, cont: &Container, cfg: &Config) -> Result<(), String>
 {
diff --git a/src/container/mount.rs b/src/container/mount.rs
index bd52964a..146a8f4e 100644
--- a/src/container/mount.rs
+++ b/src/container/mount.rs
@@ -8,8 +8,8 @@ use std::ptr::null;
 use libc::{c_ulong, c_int};
 use libmount::{BindMount, Tmpfs};
 
-use file_util::Dir;
-use path_util::ToCString;
+use crate::file_util::Dir;
+use crate::path_util::ToCString;
 
 // sys/mount.h
 static MS_RDONLY: c_ulong = 1;                /* Mount read-only.  */
diff --git a/src/container/root.rs b/src/container/root.rs
index 092892b9..0e65059b 100644
--- a/src/container/root.rs
+++ b/src/container/root.rs
@@ -5,7 +5,7 @@ use std::path::Path;
 use libc::chdir;
 use libc::{c_int, c_char};
 
-use path_util::ToCString;
+use crate::path_util::ToCString;
 
 
 extern {
diff --git a/src/container/uidmap.rs b/src/container/uidmap.rs
index 642fe89f..f0853729 100644
--- a/src/container/uidmap.rs
+++ b/src/container/uidmap.rs
@@ -10,10 +10,10 @@ use unshare::{Command, Stdio};
 use libc::{geteuid, getegid};
 use libc::{uid_t, gid_t};
 
-use config::Range;
-use config::Settings;
+use crate::config::{Range, Settings};
+use crate::process_util::{capture_output, CaptureOutput, env_path_find};
+
 use self::Uidmap::*;
-use process_util::{env_path_find, CaptureOutput, capture_output};
 
 #[derive(Clone)]
 pub enum Uidmap {
diff --git a/src/container/util.rs b/src/container/util.rs
index e6f9c651..574191ad 100644
--- a/src/container/util.rs
+++ b/src/container/util.rs
@@ -13,10 +13,11 @@ use dir_signature::v1::{Entry, EntryKind, Hashes, Parser, ParseError};
 use dir_signature::v1::merge::FileMergeBuilder;
 use libc::{uid_t, gid_t};
 use tempfile::tempfile;
-use quick_error::ResultExt;
+use quick_error::{quick_error, ResultExt};
+
+use crate::file_util::{Dir, ShallowCopy};
 
 use super::root::temporary_change_root;
-use file_util::{Dir, ShallowCopy};
 
 quick_error!{
     #[derive(Debug)]
diff --git a/src/digest.rs b/src/digest.rs
index 34f104d2..f65479a3 100644
--- a/src/digest.rs
+++ b/src/digest.rs
@@ -4,11 +4,12 @@ use std::fmt::{self, Write as WriteFmt};
 use std::path::{Path, PathBuf};
 use std::os::unix::ffi::OsStrExt;
 
-use digest_traits::{Digest as DigestTrait, FixedOutput};
-use sha2::Sha256;
 use blake2::Blake2b;
+use digest_traits::{Digest as DigestTrait, FixedOutput};
 use serde_json;
-use config::Range;
+use sha2::Sha256;
+
+use crate::config::Range;
 
 /// This is a wrapper that has convenience methods for hashing in vagga
 /// commands
diff --git a/src/file_util.rs b/src/file_util.rs
index 5bff810e..4cb950c5 100644
--- a/src/file_util.rs
+++ b/src/file_util.rs
@@ -16,8 +16,8 @@ use nix::fcntl::{flock, FlockArg};
 use digest_traits::Digest;
 use sha2::Sha256;
 
-use digest::hex;
-use path_util::ToCString;
+use crate::digest::hex;
+use crate::path_util::ToCString;
 
 pub struct Lock {
     file: fs::File,
diff --git a/src/launcher/build.rs b/src/launcher/build.rs
index 9d7f62b1..3071f22f 100644
--- a/src/launcher/build.rs
+++ b/src/launcher/build.rs
@@ -4,18 +4,19 @@ use std::io::{stdout, stderr};
 use argparse::{ArgumentParser, Store, StoreTrue};
 use unshare::{Command, Namespace};
 
-use launcher::Context;
-use launcher::wrap::Wrapper;
-use options::build_mode::BuildMode;
-use process_util::{capture_fd3, copy_env_vars, squash_stdio};
-use container::util::version_from_symlink;
+use crate::container::util::version_from_symlink;
+use crate::launcher::Context;
+use crate::launcher::wrap::Wrapper;
+use crate::options::build_mode::BuildMode;
+use crate::process_util::{capture_fd3, copy_env_vars, squash_stdio};
 
 
 pub fn build_container(context: &Context, name: &String, mode: BuildMode,
     capsule: bool)
     -> Result<String, String>
 {
-    use options::build_mode::BuildMode::*;
+    use crate::options::build_mode::BuildMode::*;
+
     let ver = match mode {
         Normal => build_internal(context, name, &[], capsule)?,
         NoImage => build_internal(context, name,
diff --git a/src/launcher/capsule.rs b/src/launcher/capsule.rs
index 2cdd72e4..6ec5f131 100644
--- a/src/launcher/capsule.rs
+++ b/src/launcher/capsule.rs
@@ -2,14 +2,13 @@ use std::collections::HashMap;
 
 use unshare::{Command, Fd};
 
-use config::command::{CapsuleInfo};
-use process_util::{run_and_wait, convert_status};
-use super::wrap::Wrapper;
+use crate::config::command::{CapsuleInfo};
+use crate::launcher::{Context, socket};
+use crate::launcher::options::{ArgError, parse_docopts};
+use crate::process_util::{run_and_wait, convert_status};
+
 use super::network;
-use launcher::options::ArgError;
-use launcher::Context;
-use launcher::socket;
-use launcher::options::parse_docopts;
+use super::wrap::Wrapper;
 
 
 const DEFAULT_DOCOPT: &'static str = "\
diff --git a/src/launcher/commands.rs b/src/launcher/commands.rs
index c4579b92..5f9c32b8 100644
--- a/src/launcher/commands.rs
+++ b/src/launcher/commands.rs
@@ -2,11 +2,11 @@ use std::io::{self, stdout, stderr};
 use std::fs::{read_link};
 use std::env;
 use std::path::Path;
-use launcher::Context;
 
 use argparse::{ArgumentParser, StoreConst};
 
-use file_util::{safe_ensure_dir, force_symlink};
+use crate::file_util::{force_symlink, safe_ensure_dir};
+use crate::launcher::Context;
 
 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
 pub enum Which {
diff --git a/src/launcher/completion.rs b/src/launcher/completion.rs
index 911b3992..3fee75e9 100644
--- a/src/launcher/completion.rs
+++ b/src/launcher/completion.rs
@@ -3,13 +3,12 @@ use std::collections::{BTreeMap, HashSet};
 
 use argparse::{ArgumentParser, Store, StoreTrue};
 
-use config::Config;
-use config::command::MainCommand;
-use config::containers::Container;
+use crate::config::Config;
+use crate::config::command::MainCommand;
+use crate::config::containers::Container;
 
-use launcher::{Context, run};
-use launcher::user;
-use launcher::list;
+use crate::launcher::{Context, run};
+use crate::launcher::{list, user};
 
 
 #[derive(PartialEq, Eq, Hash)]
diff --git a/src/launcher/environ.rs b/src/launcher/environ.rs
index 675ec14c..a6bc1fff 100644
--- a/src/launcher/environ.rs
+++ b/src/launcher/environ.rs
@@ -3,9 +3,10 @@ use std::collections::BTreeSet;
 
 use regex::{Regex, escape};
 
-use config::read_settings::MergedSettings;
 use failure::{Error, err_msg, ResultExt};
 
+use crate::config::read_settings::MergedSettings;
+
 
 fn patterns_to_regex(patterns: &BTreeSet<String>) -> Result<Regex, Error> {
     let mut var_pattern = String::with_capacity(100);
diff --git a/src/launcher/integration.rs b/src/launcher/integration.rs
index 663dd465..a5e20c17 100644
--- a/src/launcher/integration.rs
+++ b/src/launcher/integration.rs
@@ -3,7 +3,7 @@ use std::io::{stdout, stderr};
 use argparse::{ArgumentParser, StoreTrue};
 use serde_json;
 
-use config::Config;
+use crate::config::Config;
 
 
 pub fn dump_config(config: &Config, mut args: Vec<String>)
diff --git a/src/launcher/list.rs b/src/launcher/list.rs
index 73a72a40..053c05f0 100644
--- a/src/launcher/list.rs
+++ b/src/launcher/list.rs
@@ -5,7 +5,7 @@ use std::collections::HashSet;
 
 use argparse::{ArgumentParser, StoreTrue, StoreFalse};
 
-use config::Config;
+use crate::config::Config;
 
 
 pub fn print_list(config: &Config, mut args: Vec<String>)
diff --git a/src/launcher/mod.rs b/src/launcher/mod.rs
index c6bc2bf0..9e74acd4 100644
--- a/src/launcher/mod.rs
+++ b/src/launcher/mod.rs
@@ -7,10 +7,10 @@ use std::os::unix::fs::MetadataExt;
 use libc::getuid;
 use argparse::{ArgumentParser, Store, List, Collect, Print, StoreFalse, StoreTrue};
 
-use options::build_mode::{build_mode, BuildMode};
-use config::{Config, ConfigError, Settings, find_config};
-use config::read_settings::{read_settings, MergedSettings};
-use launcher::environ::set_initial_vaggaenv_vars;
+use crate::config::{Config, ConfigError, Settings, find_config};
+use crate::config::read_settings::{read_settings, MergedSettings};
+use crate::launcher::environ::set_initial_vaggaenv_vars;
+use crate::options::build_mode::{build_mode, BuildMode};
 
 mod list;
 mod integration;
@@ -210,7 +210,7 @@ pub fn run(input_args: Vec<String>) -> i32 {
         args.insert(0, "vagga _network".to_string());
 
         #[cfg(feature="containers")]
-        return ::network::run(args);
+        return crate::network::run(args);
 
         #[cfg(not(feature="containers"))]
         {
@@ -361,7 +361,7 @@ pub fn run(input_args: Vec<String>) -> i32 {
         }
         #[cfg(feature="containers")]
         "_capsule" => {
-            ::capsule::run_command(&context, args)
+            crate::capsule::run_command(&context, args)
         }
         #[cfg(feature="containers")]
         _ => {
diff --git a/src/launcher/network.rs b/src/launcher/network.rs
index 55f8a2d8..fde6ff41 100644
--- a/src/launcher/network.rs
+++ b/src/launcher/network.rs
@@ -9,22 +9,22 @@ use std::os::unix::io::AsRawFd;
 
 use argparse::{ArgumentParser};
 use argparse::{StoreTrue, StoreFalse};
+use digest_traits::Digest;
 use libc::{geteuid};
 use libmount::BindMount;
 use log::Level::Debug;
 use rand::{thread_rng, Rng};
 use serde_json;
+use sha2::Sha256;
 use unshare::{Command, Stdio, Fd, Namespace};
 
-use container::uidmap::get_max_uidmap;
-use container::network::detect_local_dns;
-use super::super::config::Config;
-use super::super::container::nsutil::{set_namespace};
-use digest_traits::Digest;
-use sha2::Sha256;
-use file_util::Dir;
-use process_util::{set_uidmap, env_command, run_success, cmd_err, cmd_show};
-use digest::hex;
+use crate::config::Config;
+use crate::container::uidmap::get_max_uidmap;
+use crate::container::network::detect_local_dns;
+use crate::container::nsutil::{set_namespace};
+use crate::digest::hex;
+use crate::file_util::Dir;
+use crate::process_util::{set_uidmap, env_command, run_success, cmd_err, cmd_show};
 
 static MAX_INTERFACES: u32 = 2048;
 
diff --git a/src/launcher/pack.rs b/src/launcher/pack.rs
index 62342778..4f5904b5 100644
--- a/src/launcher/pack.rs
+++ b/src/launcher/pack.rs
@@ -1,10 +1,10 @@
 use unshare::Command;
 
-use options::pack::{Options};
-use launcher::Context;
-use launcher::build::build_container;
-use launcher::wrap::Wrapper;
-use process_util::convert_status;
+use crate::launcher::Context;
+use crate::launcher::build::build_container;
+use crate::launcher::wrap::Wrapper;
+use crate::options::pack::{Options};
+use crate::process_util::convert_status;
 
 
 pub fn pack_command(context: &Context, args: Vec<String>)
diff --git a/src/launcher/prerequisites.rs b/src/launcher/prerequisites.rs
index 3500614e..86878907 100644
--- a/src/launcher/prerequisites.rs
+++ b/src/launcher/prerequisites.rs
@@ -1,10 +1,8 @@
 use std::collections::HashSet;
 
-use config::volumes::Volume;
-use config::volumes::PersistentInfo;
-use config::command::MainCommand;
-use launcher::Context;
-use launcher::storage_dir;
+use crate::config::command::MainCommand;
+use crate::config::volumes::{PersistentInfo, Volume};
+use crate::launcher::{Context, storage_dir};
 
 
 fn _check_volumes<'x, I>(ctx: &Context, iter: I, result: &mut Vec<&'x String>)
diff --git a/src/launcher/push.rs b/src/launcher/push.rs
index 3507ca21..af55311f 100644
--- a/src/launcher/push.rs
+++ b/src/launcher/push.rs
@@ -3,12 +3,11 @@ use std::path::{Path, PathBuf};
 
 use unshare::{Command, Stdio};
 
-use process_util::{run_success};
-use launcher::Context;
-use launcher::build::build_container;
-use launcher::wrap::Wrapper;
-use launcher::storage_dir;
-use options::push::Options;
+use crate::launcher::{Context, storage_dir};
+use crate::launcher::build::build_container;
+use crate::launcher::wrap::Wrapper;
+use crate::options::push::Options;
+use crate::process_util::{run_success};
 
 
 pub fn push_command(ctx: &Context, args: Vec<String>) -> Result<i32, String>
diff --git a/src/launcher/simple.rs b/src/launcher/simple.rs
index b94296ad..406c97d4 100644
--- a/src/launcher/simple.rs
+++ b/src/launcher/simple.rs
@@ -2,16 +2,15 @@ use std::collections::HashMap;
 
 use unshare::{Command, Fd};
 
-use config::command::{CommandInfo, WriteMode};
-use process_util::{run_and_wait, convert_status};
+use crate::config::command::{CommandInfo, WriteMode};
+use crate::launcher::{Context, socket};
+use crate::launcher::options::{ArgError, parse_docopts};
+use crate::launcher::volumes::prepare_volumes;
+use crate::process_util::{run_and_wait, convert_status};
+
 use super::build::{build_container};
-use super::wrap::Wrapper;
 use super::network;
-use launcher::volumes::prepare_volumes;
-use launcher::options::ArgError;
-use launcher::Context;
-use launcher::socket;
-use launcher::options::parse_docopts;
+use super::wrap::Wrapper;
 
 
 const DEFAULT_DOCOPT: &'static str = "\
diff --git a/src/launcher/storage.rs b/src/launcher/storage.rs
index 1871e093..e7fa260f 100644
--- a/src/launcher/storage.rs
+++ b/src/launcher/storage.rs
@@ -3,8 +3,8 @@ use std::io::{stdout, stderr, Write};
 
 use argparse::{ArgumentParser, Store, StoreTrue};
 
-use file_util::{safe_ensure_dir, ensure_symlink};
-use config::read_settings::MergedSettings;
+use crate::config::read_settings::MergedSettings;
+use crate::file_util::{ensure_symlink, safe_ensure_dir};
 
 
 pub fn init_dir(settings: &MergedSettings, project_root: &Path,
diff --git a/src/launcher/storage_dir.rs b/src/launcher/storage_dir.rs
index dab760db..1d107180 100644
--- a/src/launcher/storage_dir.rs
+++ b/src/launcher/storage_dir.rs
@@ -1,8 +1,8 @@
 use std::env;
 use std::path::PathBuf;
 
-use launcher::Context;
-use storage_dir::sanitize;
+use crate::launcher::Context;
+use crate::storage_dir::sanitize;
 
 
 pub fn get_base(ctx: &Context) -> Option<PathBuf> {
diff --git a/src/launcher/supervisor.rs b/src/launcher/supervisor.rs
index daed28b3..2e398c8b 100644
--- a/src/launcher/supervisor.rs
+++ b/src/launcher/supervisor.rs
@@ -13,22 +13,21 @@ use nix::unistd::getpid;
 use nix::sys::signal::Signal;
 use unshare::{Command, Child, Namespace, reap_zombies, Fd};
 
-use options::build_mode::{build_mode, BuildMode};
-use container::nsutil::{set_namespace, unshare_namespace};
-use config::command::{SuperviseInfo, Networking};
-use config::command::SuperviseMode::{wait_all_successful};
-use config::command::ChildCommand::{BridgeCommand};
-use tty_util::{TtyGuard};
-use super::network;
+use crate::config::command::{SuperviseInfo, Networking};
+use crate::config::command::ChildCommand::BridgeCommand;
+use crate::config::command::SuperviseMode::wait_all_successful;
+use crate::container::nsutil::{set_namespace, unshare_namespace};
+use crate::file_util::Dir;
+use crate::launcher::{Context, socket};
+use crate::launcher::options::{ArgError, parse_docopts};
+use crate::launcher::volumes::prepare_volumes;
+use crate::options::build_mode::{build_mode, BuildMode};
+use crate::process_util::{convert_status, send_signal, send_pg_signal};
+use crate::tty_util::TtyGuard;
+
 use super::build::{build_container};
-use file_util::Dir;
-use process_util::{convert_status, send_signal, send_pg_signal};
+use super::network;
 use super::wrap::Wrapper;
-use launcher::volumes::prepare_volumes;
-use launcher::options::ArgError;
-use launcher::socket;
-use launcher::Context;
-use launcher::options::parse_docopts;
 
 
 const DEFAULT_DOCOPT: &'static str = "\
diff --git a/src/launcher/system.rs b/src/launcher/system.rs
index e5864c57..f9e566e0 100644
--- a/src/launcher/system.rs
+++ b/src/launcher/system.rs
@@ -3,11 +3,11 @@ use std::io::{Read, Write};
 use std::fs::File;
 
 use libc::getuid;
-
-use process_util::env_path_find;
-use launcher::Context;
 use unshare::{Command, Stdio};
 
+use crate::launcher::Context;
+use crate::process_util::env_path_find;
+
 
 pub struct SystemInfo {
     pub expect_inotify_limit: Option<usize>,
diff --git a/src/launcher/underscore.rs b/src/launcher/underscore.rs
index bfaab867..fb09bf94 100644
--- a/src/launcher/underscore.rs
+++ b/src/launcher/underscore.rs
@@ -4,16 +4,16 @@ use argparse::{ArgumentParser};
 use argparse::{StoreTrue, List, StoreOption, Store};
 use unshare::{Command, Namespace};
 
-use options::build_mode::build_mode;
-use options::version_hash;
-use container::nsutil::{set_namespace};
-use process_util::{run_and_wait, convert_status};
+use crate::container::nsutil::set_namespace;
+use crate::launcher::Context;
+use crate::launcher::volumes::prepare_volumes;
+use crate::options::build_mode::build_mode;
+use crate::options::version_hash;
+use crate::process_util::{run_and_wait, convert_status};
 
+use super::build::build_container;
 use super::network;
-use super::build::{build_container};
 use super::wrap::Wrapper;
-use launcher::Context;
-use launcher::volumes::prepare_volumes;
 
 
 pub fn run_command(context: &Context, mut args: Vec<String>)
diff --git a/src/launcher/user.rs b/src/launcher/user.rs
index e6a070ed..d77ec75e 100644
--- a/src/launcher/user.rs
+++ b/src/launcher/user.rs
@@ -1,8 +1,6 @@
-use config::command::{MainCommand, CommandInfo, SuperviseInfo, CapsuleInfo};
-use launcher::prerequisites;
-use launcher::system;
-use launcher::{supervisor, simple, capsule};
-use launcher::Context;
+use crate::config::command::{MainCommand, CommandInfo, SuperviseInfo, CapsuleInfo};
+use crate::launcher::{Context, prerequisites};
+use crate::launcher::{capsule, simple, supervisor, system};
 
 
 enum Args<'a> {
@@ -52,7 +50,7 @@ fn run_commands(context: &Context, commands: Vec<String>,
     if context.prerequisites {
         commands = prerequisites::scan(context, commands);
     }
-    use launcher::options::ArgError::*;
+
     let mut all_args = Vec::new();
     let last_cmd = commands.len() -1;
     let mut last_cmd_args = Some(last_command_args);
@@ -71,6 +69,9 @@ fn run_commands(context: &Context, commands: Vec<String>,
                         Run vagga without arguments to see the list.", cmd)),
         };
         system::check(&cinfo.system(), context)?;
+
+        use crate::launcher::options::ArgError::*;
+
         let arg = match *cinfo {
             MainCommand::Command(ref info) => {
                 let a = match simple::parse_args(info, context, cmd, args) {
diff --git a/src/launcher/volumes.rs b/src/launcher/volumes.rs
index 21fa27f5..9f6d38da 100644
--- a/src/launcher/volumes.rs
+++ b/src/launcher/volumes.rs
@@ -1,7 +1,7 @@
-use config::volumes::SnapshotInfo;
-use config::volumes::Volume::{self, Container, Snapshot};
-use launcher::build::build_container;
-use launcher::Context;
+use crate::config::volumes::SnapshotInfo;
+use crate::config::volumes::Volume::{self, Container, Snapshot};
+use crate::launcher::build::build_container;
+use crate::launcher::Context;
 
 
 pub fn prepare_volumes<'x, I>(volumes: I, context: &Context)
diff --git a/src/launcher/wrap.rs b/src/launcher/wrap.rs
index 1f07237b..d6ef72ec 100644
--- a/src/launcher/wrap.rs
+++ b/src/launcher/wrap.rs
@@ -4,9 +4,9 @@ use std::os::unix::ffi::OsStrExt;
 
 use unshare::{Command, Namespace};
 
-use config::{Settings, Container, Range};
-use process_util::{set_uidmap, copy_env_vars};
-use container::uidmap::{get_max_uidmap, map_users};
+use crate::config::{Settings, Container, Range};
+use crate::container::uidmap::{get_max_uidmap, map_users};
+use crate::process_util::{set_uidmap, copy_env_vars};
 
 
 pub trait Wrapper {
diff --git a/src/main.rs b/src/main.rs
index 3907d041..58e643aa 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -6,46 +6,10 @@
 use std::env;
 use std::process::exit;
 
-extern crate digest_traits;
-extern crate sha2;
-extern crate blake2;
-extern crate typenum;
-extern crate libc;
-extern crate nix;
-extern crate rand;
-extern crate env_logger;
-extern crate argparse;
-extern crate quire;
-extern crate regex;
-extern crate scan_dir;
-extern crate docopt;
-extern crate humantime;
-extern crate itertools;
-extern crate serde;
-extern crate serde_json;
-extern crate resolv_conf;
 #[macro_use] extern crate failure;
-#[macro_use] extern crate matches;
-#[macro_use] extern crate mopa;
 #[macro_use] extern crate log;
-#[macro_use] extern crate quick_error;
-#[macro_use] extern crate lazy_static;
 #[macro_use] extern crate serde_derive;
 
-#[cfg(feature="containers")] extern crate tempfile;
-#[cfg(feature="containers")] extern crate git2;
-#[cfg(feature="containers")] extern crate bzip2;
-#[cfg(feature="containers")] extern crate signal;
-#[cfg(feature="containers")] extern crate tar;
-#[cfg(feature="containers")] extern crate zip;
-#[cfg(feature="containers")] extern crate xz2;
-#[cfg(feature="containers")] extern crate net2;
-#[cfg(feature="containers")] extern crate dir_signature;
-#[cfg(feature="containers")] extern crate flate2;
-#[cfg(feature="containers")] extern crate libmount;
-#[cfg(feature="containers")] extern crate path_filter;
-#[cfg(feature="containers")] extern crate unshare;
-
 #[cfg(feature="containers")] #[macro_use] mod macros;
 mod config;
 #[cfg(feature="containers")] mod container;
diff --git a/src/network/graphs.rs b/src/network/graphs.rs
index 1868e502..85822cd4 100644
--- a/src/network/graphs.rs
+++ b/src/network/graphs.rs
@@ -4,9 +4,9 @@ use std::collections::{HashSet, HashMap};
 
 use argparse::{ArgumentParser, List};
 
-use config::Config;
-use config::command::{Networking};
-use config::command::{MainCommand};
+use crate::config::Config;
+use crate::config::command::{MainCommand, Networking};
+
 use self::NodeLinks::*;
 
 
diff --git a/src/network/iptables.rs b/src/network/iptables.rs
index 2dd2962b..6aee9bf6 100644
--- a/src/network/iptables.rs
+++ b/src/network/iptables.rs
@@ -3,10 +3,11 @@ use std::path::PathBuf;
 
 use unshare::{Command, Stdio, Namespace};
 
-use process_util::{env_path_find, cmd_show, cmd_err};
+use crate::container::nsutil::set_namespace;
+use crate::process_util::{env_path_find, cmd_show, cmd_err};
+
 use super::graphs::{Graph, NodeLinks};
 use super::graphs::NodeLinks::{Full, Isolate, DropSome};
-use super::super::container::nsutil::set_namespace;
 
 
 fn _rule<W: Write, S:AsRef<str>>(out: &mut W, data: S) -> Result<(), String> {
diff --git a/src/network/mod.rs b/src/network/mod.rs
index 72f4464a..318f6baf 100644
--- a/src/network/mod.rs
+++ b/src/network/mod.rs
@@ -3,8 +3,8 @@ use std::path::Path;
 
 use argparse::{ArgumentParser, Store, List};
 
-use config::Config;
-use super::config::find_config_or_exit;
+use crate::config::{Config, find_config_or_exit};
+
 use self::iptables::apply_graph;
 
 mod graphs;
diff --git a/src/network/run.rs b/src/network/run.rs
index e6458049..9bae3b1f 100644
--- a/src/network/run.rs
+++ b/src/network/run.rs
@@ -4,10 +4,9 @@ use std::io::{stdout, stderr};
 use unshare::{Command, Namespace};
 use argparse::{ArgumentParser, Store, List};
 
-use config::Config;
-use config::command::{Networking};
-use config::command::{MainCommand};
-use container::nsutil::set_namespace;
+use crate::config::Config;
+use crate::config::command::{MainCommand, Networking};
+use crate::container::nsutil::set_namespace;
 
 
 pub fn run_command_cmd(config: &Config, args: Vec<String>)
diff --git a/src/options/compression_type.rs b/src/options/compression_type.rs
index ab1769f8..4f7e0e64 100644
--- a/src/options/compression_type.rs
+++ b/src/options/compression_type.rs
@@ -1,7 +1,7 @@
 use argparse::{ArgumentParser, StoreConst};
 
 #[cfg(feature="containers")]
-use capsule::packages as capsule;
+use crate::capsule::packages as capsule;
 
 
 #[derive(Clone, Copy, Debug)]
diff --git a/src/process_util.rs b/src/process_util.rs
index f8846ddb..ae47a3b6 100644
--- a/src/process_util.rs
+++ b/src/process_util.rs
@@ -14,9 +14,11 @@ use unshare;
 use unshare::{Command, Stdio, Fd, ExitStatus, UidMap, GidMap, child_events};
 use signal::trap::Trap;
 
-use config::Settings;
-use container::uidmap::{Uidmap, read_mapped_gids};
-use tty_util::{TtyGuard};
+use lazy_static::lazy_static;
+
+use crate::config::Settings;
+use crate::container::uidmap::{read_mapped_gids, Uidmap};
+use crate::tty_util::{TtyGuard};
 
 
 extern {
diff --git a/src/runner/mod.rs b/src/runner/mod.rs
index 0a0834a8..b09f9136 100644
--- a/src/runner/mod.rs
+++ b/src/runner/mod.rs
@@ -4,7 +4,7 @@ use std::io::{stdout, stderr, Write};
 use argparse::{ArgumentParser, Store, StoreOption, List};
 use unshare::Command;
 
-use process_util::{set_fake_uidmap, cmd_err};
+use crate::process_util::{set_fake_uidmap, cmd_err};
 
 fn run_as(args: Vec<String>) -> Result<i32, String> {
     let mut user_id: Option<u32> = None;
diff --git a/src/setup_netns/mod.rs b/src/setup_netns/mod.rs
index f8216d12..b04a5177 100644
--- a/src/setup_netns/mod.rs
+++ b/src/setup_netns/mod.rs
@@ -12,7 +12,7 @@ use serde_json;
 use unshare::{Command, Stdio};
 use argparse::{ArgumentParser, Store, List};
 
-use process_util::{env_command, run_success};
+use crate::process_util::{env_command, run_success};
 
 fn has_interface(name: &str) -> Result<bool, String> {
     File::open(&Path::new("/proc/net/dev"))
diff --git a/src/storage_dir.rs b/src/storage_dir.rs
index a1f23710..6a9d7bd2 100644
--- a/src/storage_dir.rs
+++ b/src/storage_dir.rs
@@ -1,5 +1,7 @@
 use regex::Regex;
 
+use lazy_static::lazy_static;
+
 
 lazy_static! {
     static ref DIR_REPLACE_RE: Regex = Regex::new("[^a-zA-Z0-9_-]+").unwrap();
diff --git a/src/version/mod.rs b/src/version/mod.rs
index 33ae474d..1a891b2d 100644
--- a/src/version/mod.rs
+++ b/src/version/mod.rs
@@ -6,9 +6,7 @@ use std::os::unix::io::FromRawFd;
 
 use argparse::{ArgumentParser, Store, StoreTrue};
 
-use config::find_config_or_exit;
-use config::Settings;
-
+use crate::config::{find_config_or_exit, Settings};
 
 mod version;
 mod error;
diff --git a/src/version/version.rs b/src/version/version.rs
index ace37234..94531e4a 100644
--- a/src/version/version.rs
+++ b/src/version/version.rs
@@ -1,6 +1,7 @@
-use config::{Config, Container};
+use crate::config::{Config, Container};
+use crate::build_step::{BuildStep, Digest};
+
 use super::error::Error;
-use build_step::{BuildStep, Digest};
 
 
 #[cfg(feature="containers")]
diff --git a/src/wrapper/build.rs b/src/wrapper/build.rs
index ab79becb..4449ac81 100644
--- a/src/wrapper/build.rs
+++ b/src/wrapper/build.rs
@@ -16,20 +16,20 @@ use unshare::{Command, Namespace, ExitStatus};
 use libmount::BindMount;
 use itertools::Itertools;
 
-use builder::context::Context;
-use builder::commands::tarcmd::unpack_file;
-use capsule::download::maybe_download_and_check_hashsum;
-use config::{Config, Container, Settings};
-use container::util::{clean_dir, hardlink_container_files};
-use container::util::write_container_signature;
-use container::util::{collect_container_dirs, collect_containers_from_storage};
-use container::mount::{unmount};
-use file_util::{Dir, Lock, copy, human_size};
-use process_util::{capture_fd3_status, copy_env_vars};
+use crate::build_step::Step;
+use crate::builder::context::Context;
+use crate::builder::commands::tarcmd::unpack_file;
+use crate::capsule::download::maybe_download_and_check_hashsum;
+use crate::config::{Config, Container, Settings};
+use crate::container::mount::unmount;
+use crate::container::util::{clean_dir, collect_container_dirs, collect_containers_from_storage};
+use crate::container::util::{hardlink_container_files, write_container_signature};
+use crate::file_util::{Dir, Lock, copy, human_size};
+use crate::options::version_hash::Options;
+use crate::process_util::{capture_fd3_status, copy_env_vars};
+
 use super::Wrapper;
 use super::setup;
-use build_step::Step;
-use options::version_hash::Options;
 
 
 struct ContainerInfo<'a> {
diff --git a/src/wrapper/capsule.rs b/src/wrapper/capsule.rs
index 674df363..04597110 100644
--- a/src/wrapper/capsule.rs
+++ b/src/wrapper/capsule.rs
@@ -7,13 +7,13 @@ use std::path::Path;
 use argparse::{ArgumentParser};
 use serde_json;
 
-use config::command::{CapsuleInfo, Run};
+use crate::config::command::{CapsuleInfo, Run};
+use crate::file_util::Dir;
+use crate::process_util::{run_and_wait, convert_status, copy_env_vars};
 
 use super::setup;
 use super::Wrapper;
 use super::util::{gen_command};
-use file_util::Dir;
-use process_util::{run_and_wait, convert_status, copy_env_vars};
 
 
 const BUSYBOX_COMMANDS: &'static [&'static str] = &[
diff --git a/src/wrapper/clean.rs b/src/wrapper/clean.rs
index 2b6a41d7..0e22ca25 100644
--- a/src/wrapper/clean.rs
+++ b/src/wrapper/clean.rs
@@ -11,13 +11,14 @@ use argparse::{ArgumentParser, PushConst, StoreTrue, StoreOption};
 use scan_dir::ScanDir;
 use humantime;
 
+use crate::config::command::MainCommand::{Supervise, Command, CapsuleCommand};
+use crate::config::volumes::Volume::Persistent;
+use crate::container::util::clean_dir;
+use crate::file_util::{read_visible_entries, Lock};
+use crate::wrapper::build::get_version_hash;
+
 use super::setup;
 use super::Wrapper;
-use container::util::clean_dir;
-use config::volumes::Volume::Persistent;
-use config::command::MainCommand::{Supervise, Command, CapsuleCommand};
-use file_util::{read_visible_entries, Lock};
-use wrapper::build::get_version_hash;
 
 
 #[derive(Clone, Copy)]
diff --git a/src/wrapper/commandline.rs b/src/wrapper/commandline.rs
index 13d1ec32..38e59a27 100644
--- a/src/wrapper/commandline.rs
+++ b/src/wrapper/commandline.rs
@@ -7,15 +7,13 @@ use std::str::FromStr;
 use libc::pid_t;
 use argparse::{ArgumentParser};
 
-use config::volumes::{Volume, PersistentInfo};
-use config::command::{CommandInfo, WriteMode, Run};
+use crate::config::command::{CommandInfo, Run, WriteMode};
+use crate::config::volumes::{PersistentInfo, Volume};
+use crate::process_util::{convert_status, copy_env_vars, run_and_wait, set_fake_uidmap};
+use crate::wrapper::init_persistent::{Guard, PersistentVolumeGuard};
 
-use super::setup;
-use super::Wrapper;
+use super::{setup, Wrapper};
 use super::util::{gen_command, warn_if_data_container};
-use process_util::{run_and_wait, convert_status, copy_env_vars};
-use process_util::{set_fake_uidmap};
-use wrapper::init_persistent::{Guard, PersistentVolumeGuard};
 
 
 pub fn commandline_cmd(cmd_name: &str, command: &CommandInfo,
diff --git a/src/wrapper/debug.rs b/src/wrapper/debug.rs
index 547eae3a..57d66c38 100644
--- a/src/wrapper/debug.rs
+++ b/src/wrapper/debug.rs
@@ -4,10 +4,11 @@ use std::fs::{create_dir, File};
 use unshare::{Command};
 use libmount::Overlay;
 
-use process_util::convert_status;
+use crate::process_util::convert_status;
+use crate::wrapper::capsule;
+
 use super::Wrapper;
 use super::setup::setup_base_filesystem;
-use wrapper::capsule;
 
 
 pub fn run_interactive_build_shell(wrapper: &Wrapper) -> i32 {
diff --git a/src/wrapper/hardlink.rs b/src/wrapper/hardlink.rs
index eb84c4ba..7a5fa087 100644
--- a/src/wrapper/hardlink.rs
+++ b/src/wrapper/hardlink.rs
@@ -2,13 +2,12 @@ use std::io::{stdout, stderr};
 
 use argparse::{ArgumentParser, Store, StoreTrue};
 
-use file_util::human_size;
+use crate::container::util::{check_signature, collect_containers_from_storage};
+use crate::container::util::{collect_container_dirs, hardlink_all_identical_files};
+use crate::container::util::{version_from_symlink, write_container_signature};
+use crate::file_util::human_size;
 
-use super::Wrapper;
-use super::setup;
-use container::util::{version_from_symlink, hardlink_all_identical_files};
-use container::util::{write_container_signature, check_signature};
-use container::util::{collect_containers_from_storage, collect_container_dirs};
+use super::{Wrapper, setup};
 
 
 pub fn verify_cmd(wrapper: &Wrapper, args: Vec<String>)
diff --git a/src/wrapper/init_persistent.rs b/src/wrapper/init_persistent.rs
index 983db1ac..2a0c1890 100644
--- a/src/wrapper/init_persistent.rs
+++ b/src/wrapper/init_persistent.rs
@@ -5,10 +5,10 @@ use std::os::unix::io::RawFd;
 use nix::fcntl;
 use libc::{open, renameat};
 
-use config::volumes::PersistentInfo;
-use file_util::{Lock, Dir};
-use container::util::clean_dir;
-use path_util::ToCString;
+use crate::config::volumes::PersistentInfo;
+use crate::file_util::{Lock, Dir};
+use crate::container::util::clean_dir;
+use crate::path_util::ToCString;
 
 
 pub trait Guard {
diff --git a/src/wrapper/mod.rs b/src/wrapper/mod.rs
index 1329a4b5..55ce6d9c 100644
--- a/src/wrapper/mod.rs
+++ b/src/wrapper/mod.rs
@@ -5,9 +5,10 @@ use std::sync::Arc;
 
 use argparse::{ArgumentParser, Store, StoreOption, List};
 
+use crate::config::read_settings::{read_settings, MergedSettings};
+
 use super::config::{find_config_or_exit, Config, Settings};
 use super::config::command::MainCommand::{Command, Supervise, CapsuleCommand};
-use config::read_settings::{read_settings, MergedSettings};
 
 
 mod debug;
diff --git a/src/wrapper/pack.rs b/src/wrapper/pack.rs
index 8c91a858..7e06d99c 100644
--- a/src/wrapper/pack.rs
+++ b/src/wrapper/pack.rs
@@ -3,10 +3,11 @@ use std::path::Path;
 
 use unshare::{Command, Stdio};
 
-use capsule::packages as capsule;
-use options::pack::Options;
-use wrapper::Wrapper;
-use process_util::{convert_status, cmd_show, cmd_err};
+use crate::capsule::packages as capsule;
+use crate::options::pack::Options;
+use crate::process_util::{convert_status, cmd_show, cmd_err};
+use crate::wrapper::Wrapper;
+
 use super::setup;
 
 
diff --git a/src/wrapper/run.rs b/src/wrapper/run.rs
index 4ce3e06e..d69ad94e 100644
--- a/src/wrapper/run.rs
+++ b/src/wrapper/run.rs
@@ -8,11 +8,12 @@ use libc::pid_t;
 use argparse::{ArgumentParser, Store, List, StoreTrue};
 use unshare::{Command};
 
+use crate::process_util::DEFAULT_PATH;
+use crate::process_util::{copy_env_vars, run_and_wait, convert_status};
+
 use super::setup;
 use super::Wrapper;
 use super::util::warn_if_data_container;
-use process_util::DEFAULT_PATH;
-use process_util::{copy_env_vars, run_and_wait, convert_status};
 
 
 pub fn run_command_cmd(wrapper: &Wrapper, cmdline: Vec<String>)
diff --git a/src/wrapper/setup.rs b/src/wrapper/setup.rs
index 3adbaea0..fa44b036 100644
--- a/src/wrapper/setup.rs
+++ b/src/wrapper/setup.rs
@@ -10,21 +10,18 @@ use std::path::{Path, PathBuf};
 use libc::pid_t;
 use libmount::{BindMount, Tmpfs, Remount};
 
-use config::{Container, Settings};
-use config::command::{CommandInfo, CapsuleInfo};
-use config::volumes::Volume;
-use config::volumes::Volume as V;
-use container::root::{change_root};
-use container::mount::{unmount, mount_system_dirs};
-use container::mount::{mount_proc, mount_dev, mount_run};
-use container::util::{hardlink_dir, clean_dir};
-use container::network::detect_local_dns;
-use config::read_settings::{MergedSettings};
-use process_util::{DEFAULT_PATH, PROXY_ENV_VARS};
-use file_util::{Dir, safe_ensure_dir};
-use wrapper::snapshot::make_snapshot;
-use container::util::version_from_symlink;
-use storage_dir::sanitize;
+use crate::config::{Container, Settings};
+use crate::config::command::{CommandInfo, CapsuleInfo};
+use crate::config::read_settings::{MergedSettings};
+use crate::config::volumes::Volume;
+use crate::container::root::{change_root};
+use crate::container::mount::{mount_dev, mount_proc, mount_run,  mount_system_dirs, unmount};
+use crate::container::network::detect_local_dns;
+use crate::container::util::{clean_dir, hardlink_dir, version_from_symlink};
+use crate::file_util::{Dir, safe_ensure_dir};
+use crate::process_util::{DEFAULT_PATH, PROXY_ENV_VARS};
+use crate::storage_dir::sanitize;
+use crate::wrapper::snapshot::make_snapshot;
 
 
 #[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -504,6 +501,9 @@ pub fn setup_filesystem(setup_info: &SetupInfo, container_ver: &str)
     for (path, vol) in setup_info.volumes.iter() {
         let ref rel_path = path.strip_prefix("/").unwrap();
         let dest = tgtroot.join(rel_path);
+
+        use crate::config::volumes::Volume as V;
+
         match *vol {
             &V::Tmpfs(ref params) => {
                 Tmpfs::new(&dest)
diff --git a/src/wrapper/snapshot.rs b/src/wrapper/snapshot.rs
index 51d4d690..8dcda9b5 100644
--- a/src/wrapper/snapshot.rs
+++ b/src/wrapper/snapshot.rs
@@ -4,10 +4,10 @@ use std::os::unix::fs::{MetadataExt, PermissionsExt};
 
 use libmount::{BindMount, Tmpfs};
 
-use config::volumes::SnapshotInfo;
-use file_util::Dir;
-use container::mount::{unmount};
-use container::util::{copy_dir};
+use crate::config::volumes::SnapshotInfo;
+use crate::container::mount::unmount;
+use crate::container::util::copy_dir;
+use crate::file_util::Dir;
 
 
 pub fn make_snapshot(src: &Path, dest: &Path, info: &SnapshotInfo)
diff --git a/src/wrapper/supervise.rs b/src/wrapper/supervise.rs
index 61fc2584..1383df2b 100644
--- a/src/wrapper/supervise.rs
+++ b/src/wrapper/supervise.rs
@@ -7,13 +7,12 @@ use std::str::FromStr;
 use libc::pid_t;
 use argparse::{ArgumentParser, Store};
 
-use super::super::config::command::{SuperviseInfo, CommandInfo, WriteMode};
-use super::super::config::command::ChildCommand as CC;
-use super::Wrapper;
+use crate::config::command::{ChildCommand as CC, SuperviseInfo, CommandInfo, WriteMode};
+use crate::process_util::{cmd_err, convert_status, copy_env_vars};
+use crate::process_util::{run_and_wait, set_fake_uidmap};
+
+use super::{setup, Wrapper};
 use super::util::{gen_command, warn_if_data_container};
-use super::setup;
-use process_util::{run_and_wait, convert_status, copy_env_vars};
-use process_util::{set_fake_uidmap, cmd_err};
 
 
 pub fn supervise_cmd(cname: &String, command: &SuperviseInfo,
diff --git a/src/wrapper/util.rs b/src/wrapper/util.rs
index 32bbb235..3173379a 100644
--- a/src/wrapper/util.rs
+++ b/src/wrapper/util.rs
@@ -3,8 +3,8 @@ use std::collections::BTreeMap;
 
 use unshare::{Command};
 
-use config::Container;
-use config::command::Run;
+use crate::config::Container;
+use crate::config::command::Run;
 
 
 pub fn find_cmd(cmd: &str, env: &BTreeMap<String, String>)


Test patch:
diff --git a/path_filter/tests/walk.rs b/path_filter/tests/walk.rs
index 62413dfa..64239099 100644
--- a/path_filter/tests/walk.rs
+++ b/path_filter/tests/walk.rs
@@ -1,9 +1,6 @@
-extern crate globset;
-extern crate path_filter;
-
 use std::path::{Path, PathBuf};
 
-use path_filter::PathFilter;
+use crate::path_filter::PathFilter;
 
 
 fn glob_paths(rules: &[&str]) -> Vec<PathBuf> {