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

Unhelpful error message when --find-links is a non-existent file path (without file:// scheme) #2968

Closed
gtback opened this Issue Jul 8, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@gtback

gtback commented Jul 8, 2015

If --find-links is set to a file path (such as /home/user/.cache/wheelhouse), pip generates this warning when trying to install packages:

This repository located at None is not a trusted host, if this repository is available via HTTPS it is recommend to use HTTPS instead, otherwise you may silence this warning with '--trusted-host None'.

This is not necessarily an issue if the path is not needed to install the package (for example, if the package is on PyPI, it will still successfully install, even with the warning). This is less of an issue now that pip caches wheels automatically (so removing manual caching of wheels is a viable solution for me), but caused me quite a bit of confusion.

After a bit of investigation, it seems like this is because the code here sets parsed to ('', None, None).

One potential solution is to use location instead of parsed.hostname in the error message if the latter is None.

But that raises the issue of whether file paths should be considered secure origins even if they don't use a file: scheme. I imagine they probably should, but haven't thought through all the implications. If so, then the logic elsewhere in the _validate_secure_origin function should probably be modified instead. Using a URL such as file:///home/user/.cache/wheelhouse does not cause this issue.

Another potential solution would be to require local file references to use the file: scheme. This could break existing use cases, however, since the pip documentation refers to "a local path or file:// url".

@xavfernandez

This comment has been minimized.

Show comment
Hide comment
@xavfernandez

xavfernandez Jul 8, 2015

Contributor

It looks like /home/user/.cache/wheelhouse did not exist and _sort_locations classified it as an url:

is_local_path = os.path.exists(url)

I agree the warning could be improved maybe we could go the other way require a scheme for all url ? (and not for filepath).

Contributor

xavfernandez commented Jul 8, 2015

It looks like /home/user/.cache/wheelhouse did not exist and _sort_locations classified it as an url:

is_local_path = os.path.exists(url)

I agree the warning could be improved maybe we could go the other way require a scheme for all url ? (and not for filepath).

@gtback

This comment has been minimized.

Show comment
Hide comment
@gtback

gtback Jul 8, 2015

Ahh, that helps explain why no one else is really seeing this bug. I started on a new machine around the same time pip started caching wheels, so I didn't bother to create the wheelhouse directory. I didn't realize that this warning only occurs for directories that don't exist (and therefore are assumed to be URLs).

gtback commented Jul 8, 2015

Ahh, that helps explain why no one else is really seeing this bug. I started on a new machine around the same time pip started caching wheels, so I didn't bother to create the wheelhouse directory. I didn't realize that this warning only occurs for directories that don't exist (and therefore are assumed to be URLs).

@gtback gtback changed the title from Unhelpful error message when --find-links is a file path (without file:// scheme) to Unhelpful error message when --find-links is a non-existant file path (without file:// scheme) Jul 14, 2015

@gtback gtback changed the title from Unhelpful error message when --find-links is a non-existant file path (without file:// scheme) to Unhelpful error message when --find-links is a non-existent file path (without file:// scheme) Jul 14, 2015

xavfernandez added a commit to xavfernandez/pip that referenced this issue Dec 4, 2015

Ignores invalid urls with warning
for non-existing paths or url without scheme

closes pypa#2968

xavfernandez added a commit to xavfernandez/pip that referenced this issue Jan 2, 2016

Ignores invalid urls with warning
for non-existing paths or url without scheme

closes pypa#2968

xavfernandez added a commit to xavfernandez/pip that referenced this issue Jan 3, 2016

Ignores invalid urls with warning
for non-existing paths or url without scheme

closes pypa#2968

xavfernandez added a commit to xavfernandez/pip that referenced this issue Jan 3, 2016

Ignores invalid urls with warning
for non-existing paths or url without scheme

closes pypa#2968

xavfernandez added a commit to xavfernandez/pip that referenced this issue Jan 7, 2016

Ignores invalid urls with warning
for non-existing paths or url without scheme

closes pypa#2968
@gtback

This comment has been minimized.

Show comment
Hide comment
@gtback

gtback commented Jan 8, 2016

Thanks, @xavfernandez !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment