From 5a91ca2c564a91b3cc86cac94cccc6c7624339ec Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 23 Mar 2026 13:22:07 +0000 Subject: [PATCH] Make file writable before applying strip Fixes elixir-desktop/desktop-example-app#31 The strip command modifies files in-place and fails with 'Permission denied' when files (e.g. .so NIF libraries) have read-only permissions. Ensure the file is writable with File.chmod! before running strip, matching the pattern already used in file_replace/3. Co-authored-by: Dominic Letz --- lib/tooling.ex | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/tooling.ex b/lib/tooling.ex index 43c8f4b..c545692 100644 --- a/lib/tooling.ex +++ b/lib/tooling.ex @@ -76,11 +76,17 @@ defmodule Desktop.Deployment.Tooling do is_binary = extname == "" is_library = Regex.match?(~r/\.(so|dylib|smp)($|\.)/, extname) - cond do - os() == MacOS and is_library -> cmd!("strip", ["-x", "-S", file]) - os() == MacOS and is_binary -> cmd!("strip", ["-u", "-r", file]) - is_binary || is_library -> cmd!("strip", ["-s", file]) - true -> :ok + strip_args = + cond do + os() == MacOS and is_library -> ["-x", "-S"] + os() == MacOS and is_binary -> ["-u", "-r"] + is_binary || is_library -> ["-s"] + true -> nil + end + + if strip_args do + File.chmod!(file, Bitwise.bor(File.lstat!(file).mode, 0o200)) + cmd!("strip", strip_args ++ [file]) end file