Pipenv: jsondecodeerror if pipfile.lock does not exist

Created on 27 Sep 2017  ·  9Comments  ·  Source: pypa/pipenv

seems like a recent regression

$ pipenv install
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Traceback (most recent call last):
  File "/Users/johria/.pyenv/versions/3.6.2/bin/pipenv", line 11, in <module>
    load_entry_point('pipenv==8.0.8', 'console_scripts', 'pipenv')()
  File "/Users/johria/.pyenv/versions/3.6.2/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/johria/.pyenv/versions/3.6.2/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/johria/.pyenv/versions/3.6.2/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/johria/.pyenv/versions/3.6.2/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/johria/.pyenv/versions/3.6.2/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/johria/.pyenv/versions/3.6.2/lib/python3.6/site-packages/pipenv/cli.py", line 1732, in install
    do_init(dev=dev, allow_global=system, ignore_pipfile=ignore_pipfile, system=system, skip_lock=skip_lock, verbose=verbose, concurrent=concurrent, deploy=deploy)
  File "/Users/johria/.pyenv/versions/3.6.2/lib/python3.6/site-packages/pipenv/cli.py", line 1244, in do_init
    do_lock(system=system)
  File "/Users/johria/.pyenv/versions/3.6.2/lib/python3.6/site-packages/pipenv/cli.py", line 1110, in do_lock
    lockfile['_meta']['host-environment-markers'] = simplejson.loads(c.out)
  File "/Users/johria/.pyenv/versions/3.6.2/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/Users/johria/.pyenv/versions/3.6.2/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Users/johria/.pyenv/versions/3.6.2/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Most helpful comment

I added instructions for when this occurs now.

All 9 comments

Can you try the latest version v8.1.0?

this is ussually because of an error in your environment.

I'll add a better traceback when that occurs.

There is no regression, something is wrong with your virtualenv.

thanks @kennethreitz, you're right it was from an older project which was installed using an older version of pipenv

$ pipenv --rm
$ pipenv install

fixed it

I added instructions for when this occurs now.

v8.1.1 released, which includes this.

I was doing a pipenv lock while my pc shut off due to a low battery.
This left an empty Pipfile.lock:

[bebo@albtop]$ ls -l
-rw-r--r--   1 bebo bebo    0 Nov 21 18:12 Pipfile.lock

Doing a pipenv lock again, now fails with the same traceback reported by the OP.

This is reproducible with a:

$ > Pipfile.lock
$ pipenv lock
...
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

and can be solved by deleting the file: rm Pipfile.lock.

Could we include a test case catching whether the .lock file is empty? I could do a PR. What do you think?

PS: Hi @kennethreitz, I'm using pipenv and many of your other libraries, and they are great! ;-)

Oh, good idea, I missed this earlier. Would appreciate a test case for that, absolutely

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jerzyk picture jerzyk  ·  3Comments

ipmb picture ipmb  ·  3Comments

jakul picture jakul  ·  3Comments

AkiraSama picture AkiraSama  ·  3Comments

hynek picture hynek  ·  3Comments