AcademySoftwareFoundation / AcademySoftwareFoundation/rez

Rez does not initialize properly in zsh when ~/.zshenv exists

Open
#837 0 comments 2 reactions 0 assignees View on GitHub
bug shell
Dominant language
Python
Stars
1.1k
Forks
374
Avg merge
9d 12h
Merged PRs (30d)
5

Description

### Summary

If the file ```~/.zshenv``` exists (which it often does if one uses a configuration framework like [prezto](https://github.com/sorin-ionescu/prezto)), a ```rez-env``` does not seem to work properly. It spawns the new instance of ```zsh``` but rez is never actually initialized.

From a bit of investigation, my best guess is that since [the base of shell plugins](https://github.com/nerdvegas/rez/blob/master/src/rez/shells.py#L437) resets ```$HOME``` back to the user's real home directory in every single startup file for a shell, including [```~/.zshenv``` in the case of zsh](https://github.com/nerdvegas/rez/blob/master/src/rezplugins/shell/zsh.py#L54), And since [$HOME/.zshenv runs before $HOME/.zshrc](http://zsh.sourceforge.net/Guide/zshguide02.html#l9) in interactive shells, it's resetting ```$HOME``` and then the rez-modified version of ```$HOME/.zshrc``` which does the heavy lifting in rez initialization, never runs.

### Info

**Rez version**: 2.50.0
**Platform and operating system:** CentOS Linux 7.6.1810
**Contextual information**: Trying to initialize a rez environment with zsh 5.7.1
**Simplest possible steps to reproduce**:
``` bash
touch ~/.zshenv
rez-env --shell=zsh
```

Contributor guide

Open the contributing guide

Research direction

Reproduce with `touch ~/.zshenv` followed by `rez-env --shell=zsh`. Read `src/rez/shells.py` around line 437 and `src/rezplugins/shell/zsh.py` around line 54, then trace the zsh startup-file ordering. Done means a zsh environment initializes correctly even when `~/.zshenv` exists.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, zsh
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.