-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
Running with --no-venv
causes session.install
to use unexpected interpreter
#503
Comments
Thanks for reporting this!
That should work. You can check if |
I feel like invoking "install" without a virtual environment should be an
error, since all sorts of unexpected behavior can happen. If someone wants
to actually install something in the global python interpreter, they can
run pip install via session.run.
…On Fri, Nov 12, 2021, 11:41 PM Claudio Jolowicz ***@***.***> wrote:
Thanks for reporting this!
I suspect a fix could be applied in Session.install here to use
sys.executable instead of the string `"python". I'm not certain what
conditions we'd need to check beforhand (how to verify we aren't running in
a venv).
That should work. You can check if self._runner.venv is an instance of
PassthroughEnv, as that's the one that implements the --no-venv feature.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#503 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB5I46NLCZWEKFTZUQYLUTULXT7HANCNFSM5H534MMQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
I agree you typically shouldn't install things into the global python interpreter, however that doesn't seem like it should be |
Okay, sure, but I still don't think Nox should have a footgun like this
that's only turned off if the user knows some arcane pip stuff. We could
raise a helpful error when trying to use install without a virtualenv,
something like:
Session {name} does not have a virtual environment, so you can't use
session.install() since it would modify the global Python environment. If
you're really sure that is what you want to do, use session.run("pip",
"install", ...) instead.
…On Sun, Nov 14, 2021 at 12:20 PM Ryan Hoban ***@***.***> wrote:
I feel like invoking "install" without a virtual environment should be an
error, since all sorts of unexpected behavior can happen. If someone wants
to actually install something in the global python interpreter, they can
run pip install via session.run.
I agree you typically shouldn't install things into the global python
interpreter, however that doesn't seem like it should be nox's
responsibility to validate. This is basically why pip --require-virtualenv
<https://pip.pypa.io/en/latest/cli/pip/#cmdoption-require-virtualenv>
exists, I tend to export PIP_REQUIRE_VIRTUALENV in most setups to check
this.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#503 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB5I46VKJYYLJ4JIRBADUDUL7VXNANCNFSM5H534MMQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Yup, an error message (or even just a warning) would be better than doing pip variable manipulations. If you want, in the next week I can post a PR to do this. We only need to sketch how the message should look like ;) |
I agree that |
#301 is exactly the use case I'm interested in. |
Describe the bug
Running with
--no-venv
causessession.install
to be invoked with thepython
executable found onPATH
, not the one runningnox
.How to reproduce
Running in an environment where the executables
python
andpython3.8
are distinct:My
noxfile.py
just installspytest
. Running we obtain:Ignore the "No module named pip", the point being it's invoking
/usr/bin/python
, not/usr/bin/python3.8
.Expected behavior
Documentation on forcing-sessions-backend suggests this should run "on the current python interpreter (the one running nox)".
Possible fix
I suspect a fix could be applied in
Session.install
here to usesys.executable
instead of the string `"python". I'm not certain what conditions we'd need to check beforhand (how to verify we aren't running in a venv).The text was updated successfully, but these errors were encountered: