Skip to content

Commit

Permalink
snap: set PATH for snapcraft command (#3208)
Browse files Browse the repository at this point in the history
Use the fixed path setup in the build environment, this brings parity to
the launchpad buildd environment and any other --destructive-mode
instance.

Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
  • Loading branch information
sergiusens committed Jul 9, 2020
1 parent 7fc0982 commit cd4f5d5
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 8 deletions.
1 change: 1 addition & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ assumes:
apps:
snapcraft:
environment:
PATH: "/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# https://github.com/lxc/pylxd/pull/361
PYLXD_WARNINGS: "none"
command: bin/snapcraft
Expand Down
5 changes: 0 additions & 5 deletions snapcraft/internal/build_providers/_base_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,6 @@ def _get_env_command(self) -> Sequence[str]:
# Tell Snapcraft it can take ownership of the host.
env_list.append("SNAPCRAFT_BUILD_ENVIRONMENT=managed-host")

# Setup PATH so that snaps have precedence.
env_list.append(
"PATH=/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
)

# Set the HOME directory.
env_list.append(f"HOME={self._get_home_directory().as_posix()}")

Expand Down
3 changes: 0 additions & 3 deletions tests/unit/build_providers/test_base_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ def test_passthrough_environment_flags_empty(self):
[
"env",
"SNAPCRAFT_BUILD_ENVIRONMENT=managed-host",
"PATH=/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"HOME=/root",
"SNAPCRAFT_HAS_TTY=False",
]
Expand All @@ -405,7 +404,6 @@ def test_passthrough_environment_flags_non_string(self):
[
"env",
"SNAPCRAFT_BUILD_ENVIRONMENT=managed-host",
"PATH=/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"HOME=/root",
"SNAPCRAFT_HAS_TTY=False",
"http_proxy=True",
Expand All @@ -430,7 +428,6 @@ def test_passthrough_environment_flags_all(self):
[
"env",
"SNAPCRAFT_BUILD_ENVIRONMENT=managed-host",
"PATH=/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"HOME=/root",
"SNAPCRAFT_HAS_TTY=False",
"http_proxy=http://127.0.0.1:8080",
Expand Down

0 comments on commit cd4f5d5

Please sign in to comment.