warpdotdev / warpdotdev/warp

Subshell ignores .zshenv configuration

Open
#3,463 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:shell-terminal bug ready-to-implement triaged
Dominant language
Rust
Stars
65.1k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

Discord username (optional)

nightkhaos

Describe the bug

I first noticed this when logging into a remote machine after a recent update. I would run into issues with the the remote machine complaining that unsupported options are being used for both sed and mktemp.

sed: invalid option -- 'E'
Usage: mktemp [-dq] TEMPLATE

In the remote environment (QNAP NAS) the coreutils are other binaries are provided by busybox by default, and to get the GNU binaries I have installed them via Entware. This means that binaries like sed and mktemp are actually in /opt/bin instead of the default /bin.

In order to fix this, I have added the following to my .zshenv:

pupdate() { case ":${PATH:=$1}:" in *:"$1":*) ;; *) export PATH="$1:$PATH" ;; esac; }

pupdate /opt/bin
pupdate /usr/local/bin

As you can see the function pupdate allows you to prepend the path if the path is not already in the PATH variable. This should result in /opt/bin being before /bin in the path, and thus the shell should choose /opt/bin/sed over /bin/sed.

At first I thought this was an SSH specific issue, then I noted that if I login in via /usr/bin/ssh and then send a DCS to start a subshell, the issue persists.

To reproduce
  1. Create an environment where the basic coreutils are provided by Busybox and do not support some used options, like sed -E.
  2. SSH into this environment. The environment should partially fail mid-bootstrap printing an error for unsupported options for some commands.
  3. Attempt to override the coreutils from Busybox to GNU based coreutils using a path override in .zshenv.
  4. Use /usr/bin/ssh to confirm that the path overrides were successful.
  5. Note that the issue persists with ssh or if you invoke a subshell directly using a DCS.
Expected behavior

Help pages for sed and mktemp should not be printed out. The PATH changes in .zshenv should be reflected by Warp.

Screenshots

No response

Operating system

Linux

Operating system and version

QNAP 5

Shell Version

zsh 5.9

Current Warp version

v0.2023.07.25.08.03.stable_00

Regression

Yes, this bug started recently or with an X Warp version

Recent working Warp date

Unknown.

Additional context

Based upon my (limited) understanding, it appears that when you bootstrap a zsh environment subshell you setup some "temporary" rc files using the ZDOTDIR override. ZDOTDIR overrides rc configurations like .zshenv. I believe this is the cause of the issue, as this behavior seems unique to zsh. Warp should respect the .zshenv file, therefore it may be better to directly source the required configuration files.

Does this block you from using Warp daily?

No

Is this a Warp specific issue? (i.e. does it happen in Terminal, iTerm, Kitty, etc.)

N/A, the issue only applies to a Warp specific feature. (i.e. Warp AI, Workflows)

Warp Internal (ignore): linear-label:b8107fdf-ba31-488d-b103-d271c89cac3e

None

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the zsh subshell bootstrap that uses a temporary ZDOTDIR override, then reproduce the issue with the reported .zshenv PATH changes and DCS subshell flow. Done means .zshenv is respected and the subshell no longer invokes the BusyBox sed and mktemp binaries when the PATH selects GNU alternatives.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, shell, zsh
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.