Skip to content

build: Explore running build & test scripts under an isolated Flox.dev PATH #1235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions test-under-isolated-flox-PATH
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -euxo pipefail

# Find flox (while PATH is still available)
FLOX=$(which flox)

# Clear PATH!
PATH=
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Clearing the entire PATH might be too aggressive. Consider a more targeted approach, such as saving the original PATH and restoring it after the test, or only removing specific directories that might conflict with Flox. What happens if test.bash relies on something in /usr/bin?

# Save the original PATH
ORIGINAL_PATH=$PATH

# Clear PATH!
PATH=

# ... your flox activation code ...

# Restore the original PATH after the test
PATH=$ORIGINAL_PATH


# NOT source tools/flox
$FLOX activate --mode=run

echo "Now source ./test.bash ..."
source ./test.bash

# TODO or use something like:
# env -i flox activate -- source
5 changes: 3 additions & 2 deletions test.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
#
# Copyright 2023-2025 The Enola <https://enola.dev> Authors
Expand All @@ -15,7 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -euo pipefail
set -euxo pipefail

echo "test.bash: Yo!"

# This script builds the project *WITHOUT* requiring containers.
# It can be used *IN* a container though; and is so, by the ./build script.
Expand Down