From 98f6a32e8a6bc1d01ea510beea8e5d3c3cd79cde Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Mon, 24 Nov 2025 13:42:34 +0100 Subject: [PATCH 1/2] Don't append empty component to start_dir In most cases `start_dir` is unset/empty. When passing it to `os.path.join` it leads to `/topdir/` which could cause issues when using the template as `%(startdir)s/subdir` as a double-slash might be treated specially. --- easybuild/framework/easyblock.py | 2 +- test/framework/easyblock.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/easybuild/framework/easyblock.py b/easybuild/framework/easyblock.py index 4f04cdabe7..b5a4bab879 100644 --- a/easybuild/framework/easyblock.py +++ b/easybuild/framework/easyblock.py @@ -2382,7 +2382,7 @@ def guess_start_dir(self): # make sure start_dir subdir exists (cfr. check below) mkdir(os.path.join(topdir, start_dir), parents=True) - abs_start_dir = os.path.join(topdir, start_dir) + abs_start_dir = os.path.join(topdir, start_dir) if start_dir else topdir if topdir.endswith(start_dir) and not os.path.exists(abs_start_dir): self.cfg['start_dir'] = topdir else: diff --git a/test/framework/easyblock.py b/test/framework/easyblock.py index c818dd7187..f05a354050 100644 --- a/test/framework/easyblock.py +++ b/test/framework/easyblock.py @@ -2845,6 +2845,8 @@ def check_start_dir(expected_start_dir): abs_expected_start_dir = os.path.join(eb.builddir, expected_start_dir) self.assertTrue(os.path.samefile(eb.cfg['start_dir'], abs_expected_start_dir)) self.assertTrue(os.path.samefile(os.getcwd(), abs_expected_start_dir)) + self.assertTrue(eb.cfg['start_dir'].endswith(abs_expected_start_dir)) + self.assertFalse(eb.cfg['start_dir'].endswith(os.path.sep)) # default (no start_dir specified): use unpacked dir as start dir self.assertEqual(ec['ec']['start_dir'], None) From 5e8b0ee8ed73bf0b071d603d1fe537a8b02f5cd8 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Mon, 24 Nov 2025 15:23:50 +0100 Subject: [PATCH 2/2] Fix check in test_start_dir_template --- test/framework/easyconfig.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/framework/easyconfig.py b/test/framework/easyconfig.py index 9dddc29f46..86465456b6 100644 --- a/test/framework/easyconfig.py +++ b/test/framework/easyconfig.py @@ -1510,8 +1510,8 @@ def test_start_dir_template(self): eb.run_all_steps(False) logtxt = read_file(eb.logfile) start_dir = os.path.join(eb.builddir, 'toy-0.0') - self.assertIn('start_dir in configure is %s/ &&' % start_dir, logtxt) - self.assertIn('start_dir in build is %s/ &&' % start_dir, logtxt) + self.assertIn('start_dir in configure is %s &&' % start_dir, logtxt) + self.assertIn('start_dir in build is %s &&' % start_dir, logtxt) ext_start_dir = os.path.join(eb.builddir, 'bar', 'bar-0.0') self.assertIn('start_dir in extension configure is %s &&' % ext_start_dir, logtxt) self.assertIn('start_dir in extension build is %s &&' % ext_start_dir, logtxt)