question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Confusing error message when run in Dockerfile

See original GitHub issue

When experimenting in a Dockerfile, I hit an odd error message:

Creating a virtualenv for this project…
usage: pew [-h] [-p PYTHON] [-i PACKAGES] [-r REQUIREMENTS] [-d] [-a PROJECT]
           envname
pew: error: the following arguments are required: envname

Virtualenv location: 
Creating a Pipfile for this project…
Creating a virtualenv for this project…
usage: pew [-h] [-p PYTHON] [-i PACKAGES] [-r REQUIREMENTS] [-d] [-a PROJECT]
           envname
pew: error: the following arguments are required: envname

Virtualenv location: 
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
An unexpected error occurred while accessing your virtualenv's python installation!
Please run $ pipenv --rm to re-create your environment.

Obviously a Dockerfile is a pathological environment to be running in (and I’ve moved on to resolve the issue), but it feels like pipenv should abort much earlier than it did

Describe your environment
  1. OS Type: ubuntu:16.04
  2. Python version: 3.5
  3. Pipenv version: latest from PyPI
Expected result

Error message explaining the actual issue.

Actual result

Above error message.

Steps to replicate

Attempt to build this Dockerfile:

FROM ubuntu:16.04

RUN apt-get update && apt-get install -y python3-pip
RUN pip3 install pipenv

ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

RUN pipenv install --deploy --verbose

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:16
  • Comments:17 (11 by maintainers)

github_iconTop GitHub Comments

12reactions
tsiq-olivercommented, Mar 15, 2018

Can we reopen this?

I disagree that Docker is “a pathological environment”! In particular, if Pipenv doesn’t work out of the box with an official Python Docker image, something is wrong (though I’m not sure whether it’s the image or Pipenv that should be fixed.)

FWIW, here’s my repro:

FROM python:3.6.4

RUN pip install pipenv
RUN pipenv --three

Output:

Sending build context to Docker daemon  14.19MB
Step 1/3 : FROM python:3.6.4
 ---> 336d482502ab
Step 2/3 : RUN pip install pipenv
 ---> Using cache
 ---> 91428d6b95e1
Step 3/3 : RUN pipenv --three
 ---> Running in 492b2b8a1779
Creating a virtualenv for this project…
Using /usr/local/bin/python3 (3.6.4) to create virtualenv…
usage: __main__.py [-h] [-p PYTHON] [-i PACKAGES] [-r REQUIREMENTS] [-d]
                   [-a PROJECT]
                   envname
__main__.py: error: the following arguments are required: envname

Virtualenv location:
Creating a Pipfile for this project…
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 152, in cli
    core.ensure_project(three=three, python=python, warn=True, site_packages=site_packages)
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 672, in ensure_project
    ensure_pipfile(validate=validate, skip_requirements=skip_requirements)
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 321, in ensure_pipfile
    project.create_pipfile(python=python)
  File "/usr/local/lib/python3.6/site-packages/pipenv/project.py", line 416, in create_pipfile
    config_parser = ConfigOptionParser(name=self.name)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pip9/baseparser.py", line 149, in __init__
    assert self.name
AssertionError
The command '/bin/sh -c pipenv --three' returned a non-zero code: 1
5reactions
sgrowecommented, Mar 29, 2018

In case it helps others I was able to solve this issue by setting WORKDIR to /opt/app:

FROM python:3.6.4-stretch

WORKDIR /opt/app

# build your stuff....
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can you make any sense of Dockers error-messages?
First check Docker file name(D should be capital), then run docker build -f Dockerfile . (dot ...
Read more >
How to properly override the ENTRYPOINT using docker run
Well the documentation clearly states that the ENTRYPOINT only specifies the executable to run, when the container starts. So they get an error...
Read more >
Why new Macs break your Docker build, and how to fix it
So it can be a little confusing when you try to build your Python-based Dockerfile on a new Mac, and everything starts failing....
Read more >
Docker Compose release notes
Bug fixes and enhancements . Added a quiet option when pushing an image. Fixed compose#9089; Fixed a misleading error message for port...
Read more >
Debugging a weird 'file not found' error - Julia Evans
Let's start by showing the error message I got. ... docker run -it broken-container:latest /app/serve standard_init_linux.go:228: exec user ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found