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

Getting Error :init: Expected printf output from shell #43

Closed
didibus opened this issue Jun 25, 2016 · 5 comments
Closed

Getting Error :init: Expected printf output from shell #43

didibus opened this issue Jun 25, 2016 · 5 comments

Comments

@didibus
Copy link

didibus commented Jun 25, 2016

When launching spacemacs which uses exec-path-from-shell I get the following error from it:

Error (use-package): exec-path-from-shell :init: Expected printf output from shell, but got: "%  

�[01;36muser@cloud] �[00m"

I'm sure it's due to some of the things I do or source from my .zshrc, but I'm not sure what, and I'd rather exec-path-from-shell could handle the customization of my zsh, then me having to get rid of it.

Anyone got this problem before?

P.S.: Same thing happens if I manually run (exec-path-from-shell-initialize) or (exec-path-from-shell-copy-env) for any variable.

@purcell
Copy link
Owner

purcell commented Jun 25, 2016

Yeah, your shell is clearly printing stuff out when it runs commands. It looks like a prompt, so that's a bit strange to me, because shells don't normally print out prompts when invoked with -c to run a command. In other words, your config is a bit funky. :-)

You have a couple of options: either fix the spurious prompt printing (and as a shortcut for that, you can try skipping some config if $INSIDE_EMACS is set), or change exec-path-from-shell-arguments to remove the -i flag so that .zshrc is not sourced at startup when exec-path-from-shell runs zsh.

I also use zsh and I don't have this problem. I put all my env var setup code in .zshenv, and then only have a few aliases and prompt config things in .zshrc. That setup works for me with or without the -i flag.

@purcell purcell closed this as completed Jun 25, 2016
@didibus
Copy link
Author

didibus commented Mar 15, 2018

I figured out this is caused by exporting a custom PROMPT in my zshrc file, like this:

export PROMPT="%{$fg_bold[cyan]%}%n@cloud] %{$reset_color%}%";

But if I run /bin/zsh -l -i -c "printf \"Path: %s\" $PATH" it does not print out the prompt. So I'm not sure why it does from exec-path-from-shell.

@purcell
Copy link
Owner

purcell commented Mar 15, 2018

@didibus try setting exec-path-from-shell-debug to t so you can confirm what exec-path-from-shell is receiving from your shell.

@didibus
Copy link
Author

didibus commented Mar 29, 2018

I get:

Invoking shell /bin/zsh with args ("-l" "-i" "-c" "/usr/bin/printf '__RESULT\\000%s\\000%s\\000__RESULT' \"${PATH-851f8100b2783cafbcce2d6e0476fded}\" \"${MANPATH-851f8100b2783cafbcce2d6e0476fded}\"")
Shell printed: "%  
 
�[01;36mdidibus@cloud] �[00m"

And:

Error (use-package): exec-path-from-shell/:init: Expected printf output from shell, but got: "%  
 
�[01;36mdidibus@cloud] �[00m"

I can't seem to find what in my zshrc changes the prompt to return this. Setting the prompt explicitly at the end to "" still doesn't work, I get:

Invoking shell /bin/zsh with args ("-l" "-i" "-c" "/usr/bin/printf '__RESULT\\000%s\\000%s\\000__RESULT' \"${PATH-d0f2de2d4ac0b7a85a8b54f3db589d51}\" \"${MANPATH-d0f2de2d4ac0b7a85a8b54f3db589d51}\"")
Shell printed: "%  
 
"

instead.

Removing the -i flag works.

Also it looks like INSIDE_EMACS is not set, since I tried putting if [ -z "${INSIDE_EMACS+1}" ]; then around my entire zshrc file, and it did not work.

@purcell
Copy link
Owner

purcell commented Mar 30, 2018

Based on the above, I suspect there's a mistake in one of your shell start-up files, or you're misunderstanding which of those files are evaluated by zsh when -i is either set or unset.

(INSIDE_EMACS is set by Emacs itself when running interactive shells, e.g. via M-x shell. It's not surprising to me that shell-command-to-string does not set it.)

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