Open alecthegeek opened 4 months ago
Thanks for the issue. The command works properly when you use finch run
, but fails with finch container run
:
$ finch run -it --rm --env="E=v" busybox env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
E=v
TERM=xterm
HOME=/root
$ finch container run -it --rm --env="E=v" busybox env
FATA[0000] unknown shorthand flag: 'e' in -e
FATA[0000] exit status 1
The --debug
option shows improper ordering of nerdctl arguments, where -e
argument is passed before the run
command:
$ finch --debug container run -it --rm --env="E=v" busybox env
DEBU[0000] Creating limactl command: ARGUMENTS: [shell finch sudo nerdctl container -e E=v run -it --rm busybox env], LIMA_HOME: /Applications/Finch/lima/data
...
In the following code:
limaArgs = append(limaArgs, append([]string{nerdctlCmdName}, strings.Fields(cmdName)...)...)
var finalArgs []string
for key, val := range envVars {
finalArgs = append(finalArgs, "-e", fmt.Sprintf("%s=%s", key, val))
}
finalArgs = append(finalArgs, nerdctlArgs...)
// Add -E to sudo command in order to preserve existing environment variables, more info:
// https://stackoverflow.com/questions/8633461/how-to-keep-environment-variables-when-using-sudo/8633575#8633575
limaArgs = append(limaArgs, finalArgs...)
The environment variables (such as -e E=v
) are appended first, followed by rest of the arguments. For most cases, such as finch run
, this should be fine because run
is used as the command appended before any arguments. However, for cases like finch container run
, run
is treated as another argument and appended after the environment variables.
Tested release 1.1.3
The original bug report is now fixed.
However as explained in the PR the following does not work
finch container run -it --rm -e "E=v" busybox echo -e "hello\tbye"
Describe the bug Cannot use
--env
optionSteps to reproduce
Expected behavior
Screenshots or logs
Actual result
Additional context
Note: Updated to Finch 1.1.2 -- error still present
As a test I ran
nerdctl
(installed via Rancher Desktop) and it worked as expectedTo help debug the issue as quickly as possible, we recommend generating a support bundle with
finch support-bundle generate
and attaching it to this issue. This packages all Finch-related configs and logs into one file. finch-support-20240222101339.zip