Skip to content

Conversation

smoors
Copy link
Contributor

@smoors smoors commented Jun 21, 2025

required for installing in bwrap namespace, see also #4110
if install dir is bind mounted, it cannot be removed

@smoors smoors added the change label Jun 21, 2025
Samuel Moors added 2 commits June 21, 2025 14:58
@boegel
Copy link
Member

boegel commented Aug 13, 2025

@smoors As discussed during today's conf call, it probably makes sense to introduce another function (clean_dir?) that does a two-step approach: try to remove the specified directory, fall back to emptying it when that fails for some reason.

@smoors smoors changed the title empty install dir but don't remove it empty install dir removing it fails Aug 14, 2025
@smoors smoors changed the title empty install dir removing it fails empty install dir if removing it fails Aug 14, 2025
Copy link
Member

@boegel boegel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smoors Let's also add a test for the clean_dir function?

from easybuild.tools.filetools import get_cwd, get_source_tarball_from_git, is_alt_pypi_url, is_binary, is_parent_path
from easybuild.tools.filetools import is_sha256_checksum, mkdir, move_file, move_logs, read_file, remove_dir
from easybuild.tools.filetools import remove_file, remove_lock, symlink, verify_checksum, weld_paths, write_file
from easybuild.tools.filetools import download_file, clean_dir, encode_class_name, extract_file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from easybuild.tools.filetools import download_file, clean_dir, encode_class_name, extract_file
from easybuild.tools.filetools import clean_dir, download_file, encode_class_name, extract_file


def make_dir(self, dir_name, clean, dontcreateinstalldir=False):
def make_dir(self, dir_name, clean, dontcreateinstalldir=False, isinstalldir=False):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isinstalldir can be renamed to something that more directly specifies what it done when this is enabled/disabled:

Suggested change
def make_dir(self, dir_name, clean, dontcreateinstalldir=False, isinstalldir=False):
def make_dir(self, dir_name, clean, dontcreateinstalldir=False, clean_instead_of_remove=False):

Comment on lines +450 to +451
except EasyBuildError:
_log.debug("Failed to remove directory %s, emptying it instead", path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
except EasyBuildError:
_log.debug("Failed to remove directory %s, emptying it instead", path)
except EasyBuildError as err:
_log.debug(f"Removing directory {path} failed, will try to empty it instead: {err}")

@boegel boegel changed the title empty install dir if removing it fails try to empty install dir if removing it fails Aug 27, 2025
@boegel boegel added enhancement and removed change labels Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants