From c7a44cccc29ebd7df17833af42ee09449c1b99dd Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Fri, 15 Jan 2021 06:59:13 +0200 Subject: [PATCH] Fix NPM in Linux (fix #604) --- src/steps/node.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/steps/node.rs b/src/steps/node.rs index 6d1605af..d59808e4 100644 --- a/src/steps/node.rs +++ b/src/steps/node.rs @@ -28,7 +28,7 @@ impl NPM { Command::new(&self.command) .args(&["root", "-g"]) .check_output() - .map(PathBuf::from) + .map(|s| PathBuf::from(s.trim())) } fn upgrade(&self, run_type: RunType) -> Result<()> { @@ -44,6 +44,10 @@ pub fn run_npm_upgrade(_base_dirs: &BaseDirs, run_type: RunType) -> Result<()> { #[cfg(target_os = "linux")] { let npm_root = npm.root()?; + if !npm_root.exists() { + return Err(SkipStep(format!("NPM root at {} doesn't exist", npm_root.display(),)).into()); + } + let metadata = std::fs::metadata(&npm_root)?; let uid = Uid::effective(); @@ -51,7 +55,7 @@ pub fn run_npm_upgrade(_base_dirs: &BaseDirs, run_type: RunType) -> Result<()> { return Err(SkipStep(format!( "NPM root at {} is owned by {} which is not the current user", npm_root.display(), - uid + metadata.uid() )) .into()); }