Skip to content
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

Warn user when installing scripts outside PATH #4553

Merged
merged 16 commits into from
Oct 2, 2017

Conversation

pradyunsg
Copy link
Member

@pradyunsg pradyunsg commented Jun 17, 2017

Fixes #3813, Helps with #1668.

@pfmoore
Copy link
Member

pfmoore commented Jun 17, 2017

We only need this warning if the install actually creates binaries. At the moment it warns unconditionally, whether or not there is an actual issue. I appreciate it's harder to only warn if binaries are being installed (maybe so much harder that it's impractical) but I'd prefer it that way. I'm a strong -1 on "warnings" that don't actually report an issue and can be safely ignored.

To ensure the warning is correctly produced, I'd suggest adding two tests - one that tests that installing a package with binaries warns, and one that tests that installing a package with no binary doesn't warn.

@pradyunsg
Copy link
Member Author

We only need this warning if the install actually creates binaries.

So, should we instead be checking if the installed path contain scripts that would be installed out of PATH?

I'd suggest adding two tests

Will do.

@pfmoore
Copy link
Member

pfmoore commented Jun 17, 2017

So, should we instead be checking if the installed path contain scripts that would be installed out of PATH?

Personally, I don't think this change is worth it in any case. But as long as the 2 tests I suggested pass, I don't really mind how it's done.

@dstufft
Copy link
Member

dstufft commented Jun 17, 2017

I think this change is worth it, since in a future where we default to --user, we don't want pip install foo && foo to raise an error that it can't find foo. I think this also applies to Windows installs that aren't using the latest installer?

In any case, I agree with @pfmoore that we should not be warning if it's not actually going to be doing something wrong, and I think that instead of explicitly focusing on --user, we should be warning anytime we're going to install a script outside of $PATH. The one modulation to that would be we shouldn't issue that same warning if we're using --target, and possibly also inside of a virtual environment (since people might be doing bin/foo instead).

@pradyunsg pradyunsg changed the title Display a warning when on --user and the user bin not on PATH [WIP] Display a warning when installing binary outside PATH Jun 17, 2017
@pradyunsg pradyunsg added the type: enhancement Improvements to functionality label Jun 27, 2017
@pradyunsg pradyunsg self-assigned this Jun 29, 2017
@BrownTruck
Copy link
Contributor

Hello!

I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the master branch into this pull request or rebase this pull request against master then it will eligible for code review and hopefully merging!

@BrownTruck BrownTruck added the needs rebase or merge PR has conflicts with current master label Jun 29, 2017
@pradyunsg pradyunsg changed the title [WIP] Display a warning when installing binary outside PATH [WIP] Warn user when installing scripts outside PATH Jul 5, 2017
@pradyunsg
Copy link
Member Author

pradyunsg commented Aug 18, 2017

So, the approach I'm thinking of taking here is adding the warning conditional to a user specified flag.

I'd actually not want to add virtualenv as a special case -- the warning could include how-to-suppress message; something along the lines of:

pip config {--venv,--global} set install.warn_about_script_path False

@pypa-bot pypa-bot removed the needs rebase or merge PR has conflicts with current master label Aug 18, 2017
@pradyunsg pradyunsg force-pushed the warn-user-when-installing-out-of-path branch from 7b43048 to f8b3697 Compare August 18, 2017 05:02
@pradyunsg pradyunsg changed the title [WIP] Warn user when installing scripts outside PATH Warn user when installing scripts outside PATH Aug 18, 2017
@pradyunsg
Copy link
Member Author

/request-review @pfmoore @dstufft

pip/wheel.py Outdated Show resolved Hide resolved
@pradyunsg pradyunsg force-pushed the warn-user-when-installing-out-of-path branch from a403a8c to b41a74c Compare August 18, 2017 10:32
@pradyunsg pradyunsg force-pushed the warn-user-when-installing-out-of-path branch from b41a74c to 4eb8325 Compare August 18, 2017 10:34
@pradyunsg pradyunsg added the needs rebase or merge PR has conflicts with current master label Sep 1, 2017
Copy link
Member

@xavfernandez xavfernandez left a comment

Choose a reason for hiding this comment

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

I like this change also 👍

pip/commands/install.py Outdated Show resolved Hide resolved
news/4553.feature Outdated Show resolved Hide resolved
pip/req/req_install.py Outdated Show resolved Hide resolved
pip/req/req_install.py Outdated Show resolved Hide resolved
@pradyunsg
Copy link
Member Author

pradyunsg commented Sep 2, 2017

Thanks for the review @xavfernandez!

I'll fix these when I rebase/merge.

@pradyunsg pradyunsg requested review from a team and removed request for dstufft and xavfernandez October 1, 2017 19:39
@pfmoore pfmoore merged commit fc7ca26 into pypa:master Oct 2, 2017
@pfmoore
Copy link
Member

pfmoore commented Oct 2, 2017

Thanks for this @pradyunsg 😄

@pradyunsg
Copy link
Member Author

You're welcome! ^>^

@asottile
Copy link
Contributor

asottile commented Apr 2, 2018

Should this only warn for --user installs? A pretty common workflow is to:

RUN virtualenv venv
RUN venv/bin/pip install ...
CMD ["dumb-init" "venv/bin/exe", ...]

(or outside of a dockerfile, similarly)

virtualenv venv
venv/bin/pip install ...
venv/bin/exe ...

(Just noticed this spamming my terminal with a lot of undesirable output after trying out the new 10.x betas)

@pfmoore
Copy link
Member

pfmoore commented Apr 2, 2018

Hmm, yes that's a very good point. We shouldn't really be warning in that situation. @pradyunsg any thoughts on this?

@pradyunsg
Copy link
Member Author

You're right, this is a common use case this PR did not cover.

My current thought is: if the executable is installed in dirname(sys.executable), we can skip the warning. Basically, treat dirname(sys.executable) as being a directory on PATH.

Pinging @dstufft @ncoghlan @xavfernandez for inputs.

@pfmoore pfmoore added the !release blocker Hold a release until this is resolved label Apr 2, 2018
@pfmoore
Copy link
Member

pfmoore commented Apr 2, 2018

Chipping in with my release manager hat on, I think that we need some solution to avoid spamming the user with warnings when installing into a non-activated virtualenv (IMO, using a virtualenv without activating it is an important use case). I'll leave the interested parties to agree on a suitable solution.

I'm going to mark this as a release blocker so it doesn't get forgotten about.

@pradyunsg
Copy link
Member Author

if the executable is installed in dirname(sys.executable), we can skip the warning. Basically, treat dirname(sys.executable) as being a directory on PATH.

FWIW, this is a matter of adding one line: path_env_var_parts.append(dirname(sys.executable)).

@ncoghlan
Copy link
Member

ncoghlan commented Apr 3, 2018

+1 for @pradyunsg's suggested resolution - not sure if you want to convert this into a full issue before resolving it :)

@pradyunsg
Copy link
Member Author

not sure if you want to convert this into a full issue before resolving it

Yeps -- #5157. :)

@pfmoore I'm removing "release blocker" label from this -- I imagine a dedicated issue would easier for you to track. :)

@pradyunsg pradyunsg removed the !release blocker Hold a release until this is resolved label Apr 3, 2018
@pfmoore
Copy link
Member

pfmoore commented Apr 3, 2018

Thanks, that's fine.

@lock
Copy link

lock bot commented Jun 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pip install --user should check that the user's $PATH is correct
8 participants