Closed didibus closed 8 years ago
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.
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.
@didibus try setting exec-path-from-shell-debug
to t
so you can confirm what exec-path-from-shell
is receiving from your shell.
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.
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.)
When launching spacemacs which uses exec-path-from-shell I get the following error from it:
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.