Skip to content

Commit

Permalink
fix(legacy_plugin): preserve snap environment variables in crystal pl…
Browse files Browse the repository at this point in the history
…ugin

This commit fixes an issue where the crystal plugin would fork without snap-related environment variables, which messed up the code path for detecting legacy snapcraft's data files.
  • Loading branch information
bepri committed Feb 11, 2025
1 parent 9094011 commit 2a2b5aa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion snapcraft_legacy/plugins/v2/crystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ def get_build_commands(self) -> List[str]:
else:
build_options = ""

env = dict(LANG="C.UTF-8", LC_ALL="C.UTF-8", SNAP=os.getenv("SNAP"), SNAP_NAME=os.getenv("SNAP_NAME"))
# Make sure snap-related environment variables survive through the shell call
# Filter environment variables for only the ones beginning with "SNAP"
snap_dict = {key: os.environ[key] for key in os.environ if key.startswith("SNAP")}
env = dict(LANG="C.UTF-8", LC_ALL="C.UTF-8", **snap_dict)
env_flags = [f"{key}={value}" for key, value in env.items()]

return [
Expand Down

0 comments on commit 2a2b5aa

Please sign in to comment.