17344: Silence misleading warning during gem install.
authorTom Clegg <tom@curii.com>
Mon, 11 Jul 2022 13:51:21 +0000 (09:51 -0400)
committerTom Clegg <tom@curii.com>
Thu, 14 Jul 2022 13:21:41 +0000 (09:21 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

cmd/arvados-package/fpm.go
lib/install/deps.go

index c58450d86a327104cc9f3a0acdd44f0fc115cf55..c337d8563ba53e8d3156bc47f9471132519ecae9 100644 (file)
@@ -34,15 +34,7 @@ func fpm(ctx context.Context, opts opts, stdin io.Reader, stdout, stderr io.Writ
                return fmt.Errorf("arvados-server install failed: exit code %d", exitcode)
        }
 
-       cmd := exec.Command("/var/lib/arvados/bin/gem", "install", "--user", "--no-document", "fpm")
-       cmd.Stdout = stdout
-       cmd.Stderr = stderr
-       err := cmd.Run()
-       if err != nil {
-               return fmt.Errorf("gem install fpm: %w", err)
-       }
-
-       cmd = exec.Command("/var/lib/arvados/bin/gem", "env", "gempath")
+       cmd := exec.Command("/var/lib/arvados/bin/gem", "env", "gempath")
        cmd.Stderr = stderr
        buf, err := cmd.Output() // /root/.gem/ruby/2.7.0:...
        if err != nil || len(buf) == 0 {
@@ -50,6 +42,17 @@ func fpm(ctx context.Context, opts opts, stdin io.Reader, stdout, stderr io.Writ
        }
        gempath := string(bytes.TrimRight(bytes.Split(buf, []byte{':'})[0], "\n"))
 
+       cmd = exec.Command("/var/lib/arvados/bin/gem", "install", "--user", "--no-document", "fpm")
+       cmd.Stdout = stdout
+       cmd.Stderr = stderr
+       // Avoid "WARNING: You don't have [...] in your PATH, gem
+       // executables will not run"
+       cmd.Env = append(os.Environ(), "PATH="+os.Getenv("PATH")+":"+gempath)
+       err = cmd.Run()
+       if err != nil {
+               return fmt.Errorf("gem install fpm: %w", err)
+       }
+
        if _, err := os.Stat(gempath + "/gems/fpm-1.11.0/lib/fpm/package/deb.rb"); err == nil {
                // Workaround for fpm bug https://github.com/jordansissel/fpm/issues/1739
                cmd = exec.Command("sed", "-i", `/require "digest"/a require "zlib"`, gempath+"/gems/fpm-1.11.0/lib/fpm/package/deb.rb")
index a8e95edea699055b6c79b81a87ebdbd934d52d8f..11ce0f188fb18e1654f285d384020d0c5de41ff2 100644 (file)
@@ -614,9 +614,9 @@ yarn install
                                {"touch", "log/production.log"},
                                {"chown", "-R", "--from=root", "www-data:www-data", "/var/www/.bundle", "/var/www/.gem", "/var/www/.npm", "/var/www/.passenger", "log", "tmp", "vendor", ".bundle", "Gemfile.lock", "config.ru", "config/environment.rb"},
                                {"sudo", "-u", "www-data", "/var/lib/arvados/bin/gem", "install", "--user", "--conservative", "--no-document", "bundler:" + bundlerversion},
-                               {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "--set", "--local", "deployment", "true"},
-                               {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "--set", "--local", "path", "/var/www/.gem"},
-                               {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "--set", "--local", "without", "development test diagnostics performance"},
+                               {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "set", "--local", "deployment", "true"},
+                               {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "set", "--local", "path", "/var/www/.gem"},
+                               {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "set", "--local", "without", "development test diagnostics performance"},
                                {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "install", "--jobs", "8"},
 
                                {"chown", "www-data:www-data", ".", "public/assets"},