setenv: preserve OMNeT++'s bin/ and python/ after venv activation#5
Open
tabgab wants to merge 1 commit intoomnetpp:mainfrom
Open
setenv: preserve OMNeT++'s bin/ and python/ after venv activation#5tabgab wants to merge 1 commit intoomnetpp:mainfrom
tabgab wants to merge 1 commit intoomnetpp:mainfrom
Conversation
The 'source $OPP_REPL_ROOT/.venv/bin/activate' call near the top of
setenv saves a snapshot of $PATH taken when the venv was created and
restores it on each activation. For most users that snapshot does NOT
include OMNeT++'s bin/ directory, so after:
source ~/omnetpp/setenv -q # puts OMNeT++ bin on PATH
source ~/opp_repl/setenv # venv activate erases it
`opp_makemake`, `opp_run`, `opp_scavetool` and every other OMNeT++
binary falls off PATH, even though the user sourced things "the right
way around". Typical symptom:
$ opp_makemake --help
bash: opp_makemake: command not found
The workaround was to source opp_repl's setenv FIRST, which is
counter-intuitive since opp_repl depends on OMNeT++ and not the other
way around. Order independence is what users reasonably expect.
This patch captures $__omnetpp_root_dir's bin/ and python/ paths
BEFORE the venv activation runs, then re-inserts them into $PATH /
$PYTHONPATH AFTER activation (only if they aren't already present).
Result: both sourcing orders give a working environment.
Verified on Ubuntu 24.04 / Python 3.12, OMNeT++ aipre:
$ env -i HOME=$HOME PATH=/usr/bin:/bin bash
$ source ~/omnetpp/setenv -q
$ source ~/omnetpp/misc/opp_repl/setenv # patched
$ command -v opp_makemake opp_run opp_repl
/home/gabor/omnetpp-aipre/bin/opp_makemake
/home/gabor/omnetpp-aipre/bin/opp_run
/home/gabor/omnetpp-aipre/misc/opp_repl/.venv/bin/opp_repl
All three resolve, in both sourcing orders.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
opp_repl's
setenvactivates the project's.venvnear the top:bin/activaterestores a snapshot of$PATHtaken when the venv wascreated. For most users that snapshot does NOT include OMNeT++'s
bin/, so after:opp_makemake,opp_run,opp_scavetooland every other OMNeT++binary falls off PATH, even though the user sourced things in the
"natural" order (dependency first, then dependent). Typical symptom:
The workaround is to source
opp_repl/setenvfirst — counter-intuitivesince opp_repl depends on OMNeT++, not the other way around.
Change
Capture
$__omnetpp_root_dir/{bin,python}BEFORE the venv activation,then re-prepend them to
$PATH/$PYTHONPATHAFTER activation (onlyif not already present). Result: both sourcing orders work.
Verified
All three resolve, and opp_repl's own
bin/is still prepended on top(so
opp_repl,opp_run_simulationsetc. take precedence for opp_repl-ownedtools).
Context
Found while verifying an Agent Skills pack
(tabgab/opp_repl-skill) that
walks agents through
testprompt.txt-style end-to-end scenarios. ThisPATH bug was one of the three remaining friction points weak models
couldn't navigate on their own.