diff mbox series

fetch2/npm: evaluate PATH before patching HOME

Message ID 20230524120448.40B7640A91@labor3.labor.astro
State Accepted, archived
Commit 893f3b116b628457fe0bfaf4b8394b1cd05a90a5
Headers show
Series fetch2/npm: evaluate PATH before patching HOME | expand

Commit Message

Arno Baumfalk May 24, 2023, 12:04 p.m. UTC
From 814de5df87fbd39c773177580639bb22862c11a6 Mon Sep 17 00:00:00 2001
From: Arno Baumfalk <a.baumfalk@astro-kom.de>
Date: Tue, 16 May 2023 17:18:26 +0200
Subject: [PATCH] fetch2/npm: evaluate PATH before patching HOME

When the user configures the TMPDIR variable in a way that it contains $HOME (in local.conf), the DataSmart (d) object's PATH variable will also contain $HOME.

As the NpmEnvironment patches HOME with a temporary directory, further evaluation of PATH will become invalid an the build breaks with an error (npm not found).

As countermeasure PATH is evaluated *before* patching HOME.

Signed-off-by: Arno Baumfalk <a.baumfalk@astro-kom.de>
---
 bitbake/lib/bb/fetch2/npm.py | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/bitbake/lib/bb/fetch2/npm.py b/bitbake/lib/bb/fetch2/npm.py
index 8a179a339a..e6d0598f5d 100644
--- a/bitbake/lib/bb/fetch2/npm.py
+++ b/bitbake/lib/bb/fetch2/npm.py
@@ -103,6 +103,7 @@  class NpmEnvironment(object):
         """Run npm command in a controlled environment"""
         with tempfile.TemporaryDirectory() as tmpdir:
             d = bb.data.createCopy(self.d)
+            d.setVar("PATH", d.getVar("PATH"))  # PATH might contain $HOME - evaluate it before patching
             d.setVar("HOME", tmpdir)
 
             if not workdir: