magicant / yash

Yet another shell
http://magicant.github.io/yash/
GNU General Public License v2.0
346 stars 30 forks source link

python's venv activate script errors out #62

Closed prez closed 2 months ago

prez commented 2 months ago

Describe the bug

. .venv/bin/activate

errors out with

.venv/bin/activate:34: syntax error: the parameter name is missing or invalid
.venv/bin/activate:34: syntax error: `fi' is missing

To Reproduce Steps to reproduce the behavior:

  1. Create a python venv
  2. Source the activation script

Additional context

I've attached the activate script for your convenience activate.txt

As this is a very standard workflow for python development, it would be great to have this fixed. Thank you!

magicant commented 2 months ago

Thank you for opening the issue.

In the script file you attached, the line SCRIPT_PATH="${(%):-%x}" contains a zsh-specific extension that is unlikely to be implemented in yash. Yash is designed to eagerly catch unsupported syntax, even in commands that are not executed, so unfortunately, this cannot be “fixed.”

To resolve this issue, the venv authors should consider rewriting this line to eval 'SCRIPT_PATH="${(%):-%x}"'. This way, the line will only be parsed if it is executed.

ay-ex commented 6 days ago

Same issue over here. @prez thank you for opening the issue over at uv, did get the activate script to work via patching? I eval wrapped ZSH and KSH, as described by @magicant , also checked for YASH_VERSION, but what would be the equivalent for BASH_SOURCE to get the activate script path in yash? 🤔 (with the path hardcoded and OSTYPE set, activate works)

prez commented 4 days ago

@ay-ex No, I haven't attempted to patch it. It'd be nice to get the fix upstream, but in the meantime I'm just using bash to source it.