Skip to content

[shell] respect ZDOTDIR for zsh startup files, and copy startup files instead of linking #1587

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

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

savil
Copy link
Collaborator

@savil savil commented Oct 25, 2023

Summary

Seeks to address two concerns that have arisen:

  1. Zsh startup files are linked, not copied. We should copy. This was affecting a user who was mounting the filesystem which disallows linking in that scenario.
    Fixes [Bug]: Fail to link .zshenv and .zprofile - invalid cross-device link #1536

  2. ZDOTDIR was not respected for finding the ZSH startup files. We should support it as the zsh manual specifies that its the location of its startup files: https://zsh.sourceforge.io/Intro/intro_3.html
    (Originally for [Bug]: zshenv is not sourced #1582 , but it seems that issue is unrelated to ZDOTDIR)

EDIT: Fixes #1582, as per user who reported the issue

How was it tested?

Tested by setting ZDOTDIR=~/zsh-dot-dir and moving my .zshenv and .zshrc files there. Starting a devbox shell showed that these startup files were run.

Moved them back to my homedir, and unset ZDOTDIR and starting a devbox shell still worked as expected.

Copy link
Collaborator Author

savil commented Oct 25, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@savil savil marked this pull request as ready for review October 26, 2023 00:34
@savil savil merged commit fd13459 into main Oct 26, 2023
@savil savil deleted the savil/zdotdir branch October 26, 2023 21:21
@weilbith
Copy link

weilbith commented Jan 9, 2024

I currently struggle to figure out if this is already released. Is it? 🙈

EDIT:
Found it. Sorry. Was releases with v0.8.0.
Now my issue: I'm running version v0.8.5, but it still doesn't work for me.

I have the file /etc/zsh/zshenv file with the content export $ZDOTDIR=$XDG_CONFIG_HOME/zsh. Having that, the custom shell configuration (something like /tmp/devbox[0-9]{9}) will not be loaded. And thereby most importantly the PATH variable will not be set. If I comment the ZDOTDIR line, it works fine.

@weilbith
Copy link

weilbith commented Jan 9, 2024

Where can I see how Zsh is started with the /tmp/devbox* configuration? 🤔
According to the debug output (DEBUG_DEVBOX=1) it runs a Bash explicitly with a --rcfile option argument. For Zsh I only see the binary itself. 🤷🏾

@weilbith
Copy link

weilbith commented Jan 9, 2024

Just using the devbox shellenv # ... does the job atm. Haven't checked it with all features yet.

EDIT:
Ah, the whole shell configuration features don't work (scripts, init hook, ...)

@savil
Copy link
Collaborator Author

savil commented Jan 9, 2024

@weilbith it may help to file an issue so we have more info about your system, with the specific files so we can try to reproduce the problem, and can discuss there (rather than in the PR).

I'm unable to repro your problem on my mac.

❯ cat /etc/zshenv
export TEST_FOO1=bar1

export XDG_CONFIG_HOME=/Users/savil/code/jetpack/devbox-projects/weilbith-zsh/xdg-config-home
export ZDOTDIR="${XDG_CONFIG_HOME}/zsh"

❯ cat /Users/savil/code/jetpack/devbox-projects/weilbith-zsh/xdg-config-home/zsh/.zshrc
export TEST_FOO=bar

and then opening a devbox shell works fine with TEST_FOO1 and TEST_FOO being set.

@weilbith
Copy link

You are right. Sorry for the noise. Will file in an issue with all details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: zshenv is not sourced [Bug]: Fail to link .zshenv and .zprofile - invalid cross-device link
3 participants