Flox activate should support Bourne Shell (/bin/sh) in WSL

WSL starts sh scripts on startup that is able to expand env with profile. By default VScode WSL extension does not run shell in interactive mode and does not load anything from .rc files

I managed to do a workaround to enable Flox in VScode server using bash as a helper in ~/.vscode-server/server-env-setup

set -eu
/bin/bash --login -c 'flox activate > "'"$temp_file"'"'
grep "export\|rm" "$temp_file" > "$temp_file2"
. "$temp_file2"
rm "$temp_file" "$temp_file2"
#echo "Activated FLOX in VSCode Server" >&2

–login is not strictly necessary but grep is as mangling the PS seems to not work well after that. We just know that Flux is loaded.

As Bourne Shell does not support . <() I had to use temp_file and this problem occurs:

$ flox activate > tmp

ERROR: unknown shell: /usr/bin/dash

It would be easier if sh would be directly supported. Or maybe it’s me doing something in non-supported way?

Hey thanks for the report.

I’ve been investigating this issue this morning and while I don’t have a Windows machine on hand I’ve been able to reproduce the issue on Linux.

I’ll file this with our engineering team and see if we can get a fix for you soon.

1 Like

Alright I’ve personally gone in and added support for dash and have ensured that commands like eval "$( flox activate -e foo; )"; emit POSIX compliant activation scripts.

You should see these fixes in the next release, or by using the “pre-release” executable:

bash $ flox pull -e flox/prerelease;
bash $ flox activate -e flox/prerelease;
[flox/prerelease default] bash $ dash;
$ eval "$( flox activate -e foo; )";
[foo flox/prerelease default] $

Nice, will try the new release :slight_smile:

1 Like