skip to Main Content

When opening zsh on the normal terminal I have no errors, while when I open it on vscode I get this:

z4h: core parameters have unexpectedly changed

Expected:

  ZDOTDIR=/Users/*******

Found:

  ZDOTDIR=/var/folders/0f/**************/T/vscode-zsh

Restore the parameters or restart Zsh with exec zsh.

Restore the parameters or restart Zsh with exec zsh.

I installed zsh with z4h and for a while it worked well. Then it started showing this error randomly.

PS: I tried restarting Zsh with exec zsh.

EDIT:
Tried to create the folder "/var/folders/0f/******/T/vscode-zsh" and paste the files in /Users/ in there as suggested but it still didn’t work. Then in that folder, in the .zshrc I tried editing a part of it from this

if [[ "$VSCODE_INJECTION" == "1" ]]; then
    if [[ $options[norcs] = off  && -f $USER_ZDOTDIR/.zshrc ]]; then
        VSCODE_ZDOTDIR=$ZDOTDIR
        ZDOTDIR=$USER_ZDOTDIR
        . $USER_ZDOTDIR/.zshrc
        ZDOTDIR=$VSCODE_ZDOTDIR
    fi

    if [[ -f $USER_ZDOTDIR/.zsh_history ]]; then
        HISTFILE=$USER_ZDOTDIR/.zsh_history
    fi
fi

to this:

if [[ "$VSCODE_INJECTION" == "1" ]]; then
    if [[ $options[norcs] = off  && -f $USER_ZDOTDIR/.zshrc ]]; then
        VSCODE_ZDOTDIR=$ZDOTDIR
        ZDOTDIR=$USER_ZDOTDIR
        . $USER_ZDOTDIR/.zshrc
        ZDOTDIR=$USER_ZDOTDIR
    fi

    if [[ -f $USER_ZDOTDIR/.zsh_history ]]; then
        HISTFILE=$USER_ZDOTDIR/.zsh_history
    fi
fi

When in vscode the first time I opened a new terminal it worked, but after that the file was again the same as the fist one and creating another terminal would give the same error.

3

Answers


  1. The message shows vscode executes zsh from /var/folders/0f/**************/T/vscode-zsh.
    But no z4h’s setting there. A workaround as below:

    1. Backup if the /var/folders/0f/**************/T/vscode-zsh/.zshenv and /var/folders/0f/**************/T/vscode-zsh/.zshrc that existed in the path

    2. Copy /Users/*******/.zshenv and /Users/*******/.zshrc to /var/folders/0f/**************/T/vscode-zsh/

    3. Restart the terminal on vscode

    Login or Signup to reply.
  2. If it still doesn’t work. Another way that execute zsh with the same path. You need to reset the environment variable ZIM_HOME to the Expected path.

    1. In vscode CMD+Shift+P

    2. Choose Preferences: Open Settings (JSON)

    3. Add a keyname terminal.integrated.profiles.osx

    4. Add the following value to this key.

      {
        "zsh": {
            "path": "/bin/zsh",
            "ZDOTDIR": "/Users/*******"
        }
      }
      
    5. It would look like as below finally. [updated] the env var in your case
      is ZDOTDIR

      {
       ...
        "terminal.integrated.profiles.osx": {
           "zsh": {
                   "path": "/bin/zsh",
                   "ZDOTDIR": "/Users/*******"
           }
        }
      ...
      }
      
    6. Restart the terminal.

    Login or Signup to reply.
  3. Apparently, this is a bug on the VS code side and a fix has been made available in the insider build and will be available to the public shortly and can be tracked at link.

    For now, this can be solved by setting terminal.integrated.shellIntegration.enabled to false in settings.json file or by disabling this option in settings
    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search