Pipenv: environment variables in pipfile scripts are not recognized correctly

Created on 19 Aug 2019  路  4Comments  路  Source: pypa/pipenv

When running scripts from pipfile. Unix style environment variables are wrongly recognized as commands.

Expected result

hello=world is recognized as setting an environment variable

Actual result

Error: the command hello=world (from generic-script) could not be found within PATH.

Steps to replicate

  • have the following part in pipfile
    [scripts] generic-script = 'hello=world python --version'
  • $ pipenv run generic-script
CLI Type

Most helpful comment

What about multiple environment arguments?

All 4 comments

fyi: npm scripts in package.json handles this correctly

a workaround is to use $ env hello=world <commands> on unix systems.

What about multiple environment arguments?

Hello everyone,
I am trying to contribute to the project trying to solve this issue.

I made a first hackish version that fixes the error of the issue.

Something that is missing, is defining which use cases this feature should cover.
Some examples:

  • do we want to solve variables into the command? ${MYVAR} or $MY_VAR
  • do we want to allow the execution of multiple commands if separated by semicolon? echo "hello"; python --version
  • do we want to allow multiple command execution with | or && or || operators?

I think that the purpose of this feature was to give an easy tool for a developer to run local script to do tests.

Was this page helpful?
0 / 5 - 0 ratings