Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

Problems with multi user setup and sorin prompt #35

Open
donpatrice opened this issue Mar 3, 2017 · 12 comments
Open

Problems with multi user setup and sorin prompt #35

donpatrice opened this issue Mar 3, 2017 · 12 comments

Comments

@donpatrice
Copy link

I am using a multi user setup on Ubuntu 16.04 and have the problems mentioned in sorin-ionescu#1199 even after this commit. Any ideas? Thanks!

@paulmelnikow
Copy link

Thanks for reporting the issue.

What is the value of $TMPDIR?

Perhaps the test in 436a7f9 should check ownership (-O) instead of, or in addition to, existence.

@donpatrice
Copy link
Author

Sorry, now I am confused. The test was removed with 3392332. So TMPDIR is empty, and

$ echo $TMPPREFIX 
/tmp/zsh

for every user and this makes trouble:
prompt_sorin_precmd_async:4: permission denied: /tmp/zsh-prompt_sorin_data.

@paulmelnikow
Copy link

Huh, you're right. Looks like that was changed in #6. That change makes sense to me though.

Is mktemp -d returning /tmp? That seems broken. This is what I get on my Mac.

❯ mktemp -d
/var/folders/m2/3rwkhb908xnfvd0059_t24yh0000gq/T/tmp.KpNG9sPv
❯ mktemp -d
/var/folders/m2/3rwkhb908xnfvd0059_t24yh0000gq/T/tmp.OTagTfUI
❯ mktemp -d
/var/folders/m2/3rwkhb908xnfvd0059_t24yh0000gq/T/tmp.McdBhifs
❯ mktemp -d
/var/folders/m2/3rwkhb908xnfvd0059_t24yh0000gq/T/tmp.mt3fyYFJ
❯ mktemp -d
/var/folders/m2/3rwkhb908xnfvd0059_t24yh0000gq/T/tmp.eZ1kEsgJ

This is from a CentOS system:

$ mktemp -d
/tmp/tmp.GUOYd17245
$ mktemp -d
/tmp/tmp.RrArI17248
$ mktemp -d
/tmp/tmp.THmwU17249
$ mktemp -d
/tmp/tmp.RJLRU17268

@donpatrice
Copy link
Author

On Ubuntu I get:

$ mktemp -d
/tmp/tmp.lRx1l3MyNf
$ mktemp -d
/tmp/tmp.VuH8Q9EBIR

So this seems okay, but I still get

prompt_sorin_precmd_async:4: permission denied: /tmp/zsh-prompt_sorin_data

@paulmelnikow
Copy link

Hmmm. Seems like it should be working then. This is the operative line in the prompt.

Here's what I'm seeing:

~ ❯❯❯ echo $TMPPREFIX
/var/folders/m2/3rwkhb908xnfvd0059_t24yh0000gq/T/tmp.YwyQqQ2D/zsh
~ ❯❯❯ echo $_prompt_sorin_precmd_async_data
/var/folders/m2/3rwkhb908xnfvd0059_t24yh0000gq/T/tmp.YwyQqQ2D/zsh-prompt_sorin_data

@donpatrice
Copy link
Author

I think I found the problem, but I don't understand it. If I change the login shell to zsh everything is working as expected. But if I have a different shell and then call

zsh

the problem appears.

@paulmelnikow
Copy link

paulmelnikow commented Mar 8, 2017

Ah! This is from the zsh manpage:

Commands are then read from $ZDOTDIR/.zshenv. If the shell is a login shell, commands are read from /etc/zprofile and then $ZDOTDIR/.zprofile. Then, if the shell is interactive, commands are read from /etc/zshrc and then $ZDOTDIR/.zshrc. Finally, if the shell is a login shell, /etc/zlogin and $ZDOTDIR/.zlogin are read.

In other words, if your login shell is bash and then you invoke zsh, your .zprofile isn't read! So TMPPREFIX="$(mktemp -d)/zsh" isn't executed.

@donpatrice
Copy link
Author

Ah I see. One more thing to understand it better. If I have a bash as login shell and then I call

$ zsh
prompt_sorin_precmd_async:4: permission denied: /tmp/zsh-prompt_sorin_data
$ echo $TMPPREFIX
prompt_sorin_precmd_async:4: permission denied: /tmp/zsh-prompt_sorin_data
$ source .zprofile
prompt_sorin_precmd_async:4: permission denied: /tmp/zsh-prompt_sorin_data
$ echo $TMPPREFIX
/tmp/tmp.BF4fQhzPv5/zsh
prompt_sorin_precmd_async:4: permission denied: /tmp/zsh-prompt_sorin_data

So the prompt plugin does not use the new $TMPPREFIX, does it? So there is no chance of getting it work without zsh as login shell?

Thank you so much.

@paulmelnikow
Copy link

Unfortunately it's too late then. TMPPREFIX needs to be set before prompt_sorin_setup runs. e.g.

TMPPREFIX=$(mktemp -d) zsh

I think the right fix is to change Prezto, and move that logic from zprofile into init.zsh (or maybe environment/init.zsh). It's a good out-of-the-box default for any zsh shell, not only a login shell.

Can you check one thing? Is your current shell exporting TMPPREFIX?

❯ env | grep TMPPREFIX
❯

TMPPREFIX is a zsh thing AFAICT, so I would guess your result will be the same as mine.

I would prefer not to clobber that variable if it's already set. Though if bash or your system is setting it to some useless / incorrect value it would be the right thing to do.

@donpatrice
Copy link
Author

@paulmelnikow I get the same empty answer:

$ env | grep TMPPREFIX
$

And your workaround with

TMPPREFIX=$(mktemp -d) zsh

works as well. Thank you.
I think you are right, it is probably best to fix Prezto and move things.

@paulmelnikow
Copy link

There is code in runcoms/zshenv that seems intended to load zprofile at other times. However it only runs when "$SHLVL" -eq 1. zsh started from a bash login shell is probably SHLVL 2.

The SHLVL test was added in sorin-ionescu#500, prior to which these settings were in zshenv and unconditionally loaded.

@paulmelnikow
Copy link

Picking this up at sorin-ionescu#1199.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants