Skip to content

Env vars fail to read with fish #1047

@cbrown1234

Description

@cbrown1234

I'm experiencing an issue where the env vars from the host are not being loaded

[303 ms] userEnvProbe: loginInteractiveShell (default)
[304 ms] userEnvProbe: not found in cache
[304 ms] userEnvProbe shell: /home/linuxbrew/.linuxbrew/bin/fish
[361 ms] Error reading shell environment.
[362 ms] Command failed: /home/linuxbrew/.linuxbrew/bin/fish -lic echo -n c00316a7-e1f8-4276-9675-388abcf6d015; cat /proc/self/environ; echo -n c00316a7-e1f8-4276-9675-388abcf6d015

I believe this to be the cause of a subsequent issue with the ssh-agent not being made available in the container

[2071 ms] Start: Launching Dev Containers helper.
[2071 ms] ssh-agent: SSH_AUTH_SOCK not set on wsl host.
[2071 ms] ssh-agent: SSH_AUTH_SOCK not set on local host.
[2072 ms] X11 forwarding: DISPLAY not set on wsl host.
[2072 ms] X11 forwarding: DISPLAY not set on local host.

I've tested the command in my terminal and I see the following warning:

$ /home/linuxbrew/.linuxbrew/bin/fish -lic echo -n c00316a7-e1f8-4276-9675-388abcf6d015; cat /proc/self/environ; echo -n c00316a7-e1f8-4276-9675-388abcf6d015
warning: Can not use the no-execute mode when running an interactive session

<some env vars>c00316a7-e1f8-4276-9675-388abcf6d015¶

(Note the lack of the first uuid, only the final one)

The warning is coming from fish
https://github.com/ridiculousfish/fish-shell/blob/9def5b8fdafdbd32b5e3036058ef8822f709cba6/src/bin/fish.rs#L468
and it indicates that the -n (which short for --no-execute per the fish man page) is being passed to fish rather than echo

So it seems that the problem here is that the commands to be run are not being properly escaped.

If I instead run the following, it seems to work as expected

$ /home/linuxbrew/.linuxbrew/bin/fish -lic 'echo -n c00316a7-e1f8-4276-9675-388abcf6d015; cat /proc/self/environ; echo -n c00316a7-e1f8-4276-9675-388abcf6d015'
c00316a7-e1f8-4276-9675-388abcf6d015<some env vars>c00316a7-e1f8-4276-9675-388abcf6d015¶

Metadata

Metadata

Assignees

Labels

info-neededIssue requires more information from poster

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions