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

zsh function .zwc parse errors #742

Open
bengolder opened this issue Apr 24, 2024 · 2 comments
Open

zsh function .zwc parse errors #742

bengolder opened this issue Apr 24, 2024 · 2 comments

Comments

@bengolder
Copy link

bengolder commented Apr 24, 2024

After installing, I get errors every time I open a new iTerm window:

/Users/bengolder/.zsh/functions/_git_delete_branch.zwc:1: parse error near `)'
/Users/bengolder/.zsh/functions/change-extension.zwc:1: no such file or directory: ^G^F^E^D^A^H^A
/Users/bengolder/.zsh/functions/envup.zwc:1: no such file or directory: ^G^F^E^D^Ax^A
[3] 75334
/Users/bengolder/.zsh/functions/g.zwc:1: no such file or directory: ^G^F^E^D^A
[4] 75335
/Users/bengolder/.zsh/functions/g.zwc:1: no such file or directory:
[4]  + exit 127    ��
[3]  + exit 127    �A
/Users/bengolder/.zsh/functions/g.zwc:1: command not found: A
/Users/bengolder/.zsh/functions/mcd.zwc:1: no such file or directory: ^G^F^E^D^A\M-T
Wed Apr 24 10:42 AM ~ %

It's clear that these are occurring when the zshrc file runs this loop to source all the files in .zsh/functions:

# load custom executable functions
for function in ~/.zsh/functions/*; do
  source $function
done

If I delete the ~/.zsh directory and rerun rcup, the errors are absent until new .zwc files are autogenerated for each file in ~/.zsh/functions:

Wed Apr 24 10:49 AM functions % pwd
/Users/bengolder/.zsh/functions
Wed Apr 24 10:49 AM functions % ls -la
total 40
drwxr-xr-x  12 bengolder  staff  384 Apr 24 10:47 .
drwxr-xr-x   5 bengolder  staff  160 Apr 24 10:46 ..
lrwxr-xr-x   1 bengolder  staff   58 Apr 24 10:46 _git_delete_branch -> /Users/bengolder/dotfiles/zsh/functions/_git_delete_branch
-rw-r-----   1 bengolder  staff  480 Apr 24 10:47 _git_delete_branch.zwc
lrwxr-xr-x   1 bengolder  staff   56 Apr 24 10:46 change-extension -> /Users/bengolder/dotfiles/zsh/functions/change-extension
-rw-r-----   1 bengolder  staff  528 Apr 24 10:47 change-extension.zwc
lrwxr-xr-x   1 bengolder  staff   45 Apr 24 10:46 envup -> /Users/bengolder/dotfiles/zsh/functions/envup
-rw-r-----   1 bengolder  staff  752 Apr 24 10:47 envup.zwc
lrwxr-xr-x   1 bengolder  staff   41 Apr 24 10:46 g -> /Users/bengolder/dotfiles/zsh/functions/g
-rw-r-----   1 bengolder  staff  512 Apr 24 10:47 g.zwc
lrwxr-xr-x   1 bengolder  staff   43 Apr 24 10:46 mcd -> /Users/bengolder/dotfiles/zsh/functions/mcd
-rw-r-----   1 bengolder  staff  424 Apr 24 10:47 mcd.zwc

System details:

  • MacOS 14.4.1
  • iTerm2 3.4.23
  • zsh 5.9 (arm-apple-darwin23.0.0), installed via homebrew

Any questions or debugging suggestions welcome!

@mikegee
Copy link
Contributor

mikegee commented Apr 25, 2024

I googled the zwc file extension because those look like they shouldn't be there.

https://www.reddit.com/r/zsh/comments/k1yaa1/help_me_understand_errors_in_zwc_files/

Apparently zsh can compile scripts into zwc files. News to me. Sourcing those files breaks things. I wonder why you have those zwc files in there. 🤔

Here's a previous PR in this repo to skip zwc files in another context: #526
Perhaps we should bring the same technique to sourcing the functions directory?

@bengolder
Copy link
Author

I don't know what is creating the .zwc files. They seem to be autogenerated after the first time the functions are accessed in zsh. I've taken no intentional steps to compile them, and I assumed they were just part of a default zsh or dotfiles setup. 🤔

It seems that .zwc files are skipped throughout load_settings, so I can add a PR to do that for these additional function files.

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

2 participants