I moved my python project from a native Linux installation to Windows and I tried to run pipenv custom scripts through WSL 2 on Windows 10 using pipenv run my_script
.
Although the same command works in a native Ubuntu installation, on WSL 2 (Ubuntu 20.04) I get an Attribute error in the shlex module regarding the instream object not having attribute read.
My [scripts] section in the Pipfile looks like this, but I've also tried running python scripts (instead of shell ones) and the error can be reproduced with any custom script.
[scripts]
build = "bash ./scripts/main.sh -b"
analyze = "bash ./scripts/main.sh -a"
I've also tried to update the pipenv package but looks like I'm running the latest version (11.9.0, pipenv-2020.6.2).
My code doesn't seem to run at all since I get an error before the arguments are passed to the custom script. This is the stacktrace I get from running the command:
Traceback (most recent call last):
File "/usr/bin/pipenv", line 11, in <module>
load_entry_point('pipenv==11.9.0', 'console_scripts', 'pipenv')()
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/pipenv/cli.py", line 602, in run
core.do_run(command=command, args=args, three=three, python=python)
File "/usr/lib/python3/dist-packages/pipenv/core.py", line 2200, in do_run
command = ' '.join(project.scripts[command])
File "/usr/lib/python3/dist-packages/pipenv/project.py", line 374, in scripts
scripts[k] = shlex.split(v, posix=True)
File "/usr/lib/python3.8/shlex.py", line 311, in split
return list(lex)
File "/usr/lib/python3.8/shlex.py", line 300, in __next__
token = self.get_token()
File "/usr/lib/python3.8/shlex.py", line 109, in get_token
raw = self.read_token()
File "/usr/lib/python3.8/shlex.py", line 140, in read_token
nextchar = self.instream.read(1)
AttributeError: 'list' object has no attribute 'read'