Skip to main content

ensure_loader_scripts_executable

Function ensure_loader_scripts_executable 

Source
pub fn ensure_loader_scripts_executable(
    target_dir: &Path,
) -> Result<Vec<PathBuf>>
Expand description

Marks every LOADER_SCRIPTS entry present in target_dir executable, returning the paths whose mode this call actually changed.

Thunderstore loader packages ship these scripts without an execute bit: BepInExPack_Valheim 5.4.2333 records start_game_bepinex.sh as 0666 in its archive. Both LaunchProgram::ProfileScript and the wrapper from wrapper_script_contents exec one of them directly, so without this that exec fails with Permission denied, and under Steam that error reaches only Steam’s own console log: the launch presents to the user as the game silently never starting. The bit therefore has to come from the manager, exactly as r2modman sets it. Preserving the archive’s recorded mode is no substitute, because there is no execute bit in the archive to preserve.

Applied at launch time rather than at install time so a target that arrived by any route is covered, whether that is a fresh install, an import, an export round-trip, a restored backup, or one already on disk from an older version, instead of only freshly installed ones. Kept out of launch_plan_in, which stays a pure computation, so the caller decides when the target is written to. Keyed on the same LOADER_SCRIPTS list the plan and the wrapper both resolve from, so all three agree about which files have to be runnable.

A script that is already executable is left untouched, so repeated launches do not rewrite modes.