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

pipenv run --help thows excption #2127

Closed
halloleo opened this issue May 3, 2018 · 7 comments
Closed

pipenv run --help thows excption #2127

halloleo opened this issue May 3, 2018 · 7 comments

Comments

@halloleo
Copy link

halloleo commented May 3, 2018

In an empty directory (where isn't a pipfile in any of the searched parents) issue the command

pipenv run --help

and you get:

Creating a virtualenv for this project…
Using /usr/local/bin/python3.6m (3.6.4) to create virtualenv…
⠋Running virtualenv with interpreter /usr/local/bin/python3.6m
Using base prefix '/usr/local'
New python executable in /home/me/tmp/tepiru/.venv/bin/python3.6m
Also creating executable in /home/me/tmp/tepiru/.venv/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /home/me/tmp/tepiru/.venv
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.5/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/pipenv/cli.py", line 637, in run
    do_run(command=command, args=args, three=three, python=python)
  File "/usr/local/lib/python3.5/site-packages/pipenv/core.py", line 2303, in do_run
    do_run_posix(script, command=command)
  File "/usr/local/lib/python3.5/site-packages/pipenv/core.py", line 2283, in do_run_posix
    os.execl(command_path, command_path, *script.args)
  File "/usr/local/lib/python3.5/os.py", line 583, in execl
    execv(file, args)
FileNotFoundError: [Errno 2] No such file or directory

I use the follwoing PIPENV variables:

PIPENV_DEFAULT_PYTHON_VERSION=3.6
PIPENV_VENV_IN_PROJECT=yes

Once the virtual env is created and you issue again pipenv run --help you get still the same exception.

@techalchemy
Copy link
Member

this is not a valid command, and calling run means pipenv looks for a script to run. I don't think there is any easy way around this as run literally drops anything you give it through to your environment

@halloleo
Copy link
Author

halloleo commented May 3, 2018

pipenv run --help is not a valid command? How do I get the help for pip run then? Also, pipenv install --help is valid and gives me the help for pipenv install.

@erinxocon
Copy link
Contributor

Hey @halloleo, thanks for using pipenv! I can understand the frustration of what seems like inconsistencies in the api, however due to the way run works, we have to capture any flags and pass them down into the environment like @techalchemy said. If you have an idea of how to work around it let us know and submit a PR!

@uranusjr
Copy link
Member

uranusjr commented May 3, 2018

The problem is that pipenv run --help can be (and is) interpreted as “run the command --help inside venv” because --help is totally a valid command name. One way to work around this would be to make this a special case, and require pipenv run -- --help if you really have a command named --help (which is obviously rare). As mentioned above, pull requests are welcomed!

@halloleo
Copy link
Author

halloleo commented May 3, 2018

Thanks for the explanation. See whether I get to it.

@immerrr
Copy link
Contributor

immerrr commented Jul 13, 2019

@techalchemy @erinxocon

You are saying that pipenv forwards everything to the subprocess command line, that is not exactly true:

$ pipenv run --verbose echo 123
123

This command does not run --verbose echo 123, it strips --verbose as pipenv option (as it should) and runs echo 123.

As @uranusjr pointed out, there already exists a convention for distinguishing options and arguments for a given command in case of ambiguity: the -- separator. Thanks to click adhering to those conventions, it works out of the box:

$ pipenv run -- --verbose echo 123
Error: the command --verbose could not be found within PATH or Pipfile's [scripts].

The only thing needed to enable --help command is to remove add_help_option=False kwarg added in PR #940.

@immerrr
Copy link
Contributor

immerrr commented Jul 14, 2019

I have created #3844 to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants