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

UnicodeDecodeError installing legit from GitHub #1738

Closed
techtonik opened this issue Apr 21, 2014 · 11 comments
Closed

UnicodeDecodeError installing legit from GitHub #1738

techtonik opened this issue Apr 21, 2014 · 11 comments
Labels
auto-locked Outdated issues that have been locked by automation

Comments

@techtonik
Copy link
Contributor

pip 1.5.4, python 2.7.6

> py -m pip install https://github.com/kennethreitz/legit
Downloading/unpacking https://github.com/kennethreitz/legit
Cleaning up...
Exception:
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\pip\basecommand.py", line 122, in main
    status = self.run(options, args)
  File "C:\Python27\lib\site-packages\pip\commands\install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "C:\Python27\lib\site-packages\pip\req.py", line 1197, in prepare_files
    do_download,
  File "C:\Python27\lib\site-packages\pip\req.py", line 1375, in unpack_url
    self.session,
  File "C:\Python27\lib\site-packages\pip\download.py", line 582, in unpack_http_url
    unpack_file(temp_location, location, content_type, link)
  File "C:\Python27\lib\site-packages\pip\util.py", line 627, in unpack_file
    and is_svn_page(file_contents(filename))):
  File "C:\Python27\lib\site-packages\pip\util.py", line 210, in file_contents
    return fp.read().decode('utf-8')
  File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x8b in position 1: invalid start byte
@pwaller
Copy link
Contributor

pwaller commented Jun 8, 2014

👍 encountered this over on pyfiglet.

@defance
Copy link

defance commented Jul 10, 2014

You shoud try:

py -m pip install git+https://github.com/kennethreitz/legit

@xavfernandez
Copy link
Member

Yup, https://github.com/kennethreitz/legit is a link to a webpage, nothing much pip can do from it.
The error message is slightly better now:

$ pip install https://github.com/kennethreitz/legit
Collecting https://github.com/kennethreitz/legit
  Downloading https://github.com/kennethreitz/legit
     | 61kB 436kB/s
  Cannot unpack file /tmp/pip-f5Htwo-unpack/legit (downloaded from /tmp/pip-vinjwI-build, content-type: text/html; charset=utf-8); cannot detect archive format
Cannot determine archive format of /tmp/pip-vinjwI-build

The solution is indeed to add the vcs scheme:

pip install git+https://github.com/kennethreitz/legit

This can be closed.

@techtonik
Copy link
Contributor Author

But Git is somehow able to pull from this URL, so pip should be able to pull from this too.

@defance
Copy link

defance commented Aug 16, 2015

Yes. That's why you specify vcs scheme to perform pull. If you say git+ then pip will use git to pull.

@techtonik
Copy link
Contributor Author

@defance, you misunderstood. The Git somehow communicates with web server to receive info that the https:// URL also contains a Git repository, which it then clones, so pip can do this too.

@xavfernandez
Copy link
Member

git starts by sending a GET on /info/refs?service=git-upload-pack with User-Agent: git/1.9.1.
bzr, hg and svn each certainly do something different.

pip could certainly first try to get a valid package file and if it can not determine the archive format, tries each bzr+https, git+https, hg+https and svn+https.

Or the user could directly provide the needed information...

@techtonik
Copy link
Contributor Author

pip could certainly first try to get a valid package file and if it can not determine the archive format, tries each bzr+https, git+https, hg+https and svn+https.

Yes, this is what I expect it to do. Maybe lightweight probes are better than a full fledged try/fail cycle?

@dstufft
Copy link
Member

dstufft commented Mar 22, 2017

Closing this as the issue seems to be trying to install an HTML page instead of a git repository.

@dstufft dstufft closed this as completed Mar 22, 2017
@pwaller
Copy link
Contributor

pwaller commented Mar 22, 2017

@dstufft, even if the use case is bad, the error message is still not informative and confusing for anyone unfortunate enough to hit this accidentally. Is there any way that could be improved, perhaps by detecting that the content type is wrong, or something like this?

@dstufft
Copy link
Member

dstufft commented Mar 22, 2017

@pwaller it has an error message now:

$ pip install https://github.com/kennethreitz/legit
Collecting https://github.com/kennethreitz/legit
  Downloading https://github.com/kennethreitz/legit
     - 92kB 3.6MB/s
  Cannot unpack file /private/var/folders/14/9jkprxq17f30vp_2wbfw79780000gn/T/pip-QcRZcu-unpack/legit (downloaded from /private/var/folders/14/9jkprxq17f30vp_2wbfw79780000gn/T/pip-PJXNfN-build, content-type: text/html; charset=utf-8); cannot detect archive format
Cannot determine archive format of /private/var/folders/14/9jkprxq17f30vp_2wbfw79780000gn/T/pip-PJXNfN-build

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 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
Projects
None yet
Development

No branches or pull requests

5 participants