arkade icon indicating copy to clipboard operation
arkade copied to clipboard

Support spaces in Windows user paths

Open kilgariff opened this issue 5 years ago • 1 comments

I tried using Arkade on a Windows system using git bash. My username has a space in it, so the directory ~/.arkade expands to C:\Users\Ross Work\.arkade. Arkade does not support this.

Expected Behaviour

Arkade should work seamlessly on Windows when the user path contains a space.

Current Behaviour

When helm is invoked, the first part of the user path before the first space (C:\Users\Ross in my case) is treated as the command to execute and the remaining parts (Work\.arkade\bin\helm3) are treated as arguments.

Possible Solution

I hacked together a solution for my purposes, but there's probably a better fix. My solution was to change uses of execute.ExecTask to populate Args instead of concatenating everything into Command, so that...

	task := execute.ExecTask{
		Command:     fmt.Sprintf("%s repo add %s %s", env.LocalBinary("helm", subdir), name, url),
		Env:         os.Environ(),
		StreamStdio: true,
	}
	res, err := task.Execute()

...became:

	task := execute.ExecTask{
		Command:     env.LocalBinary("helm", subdir),
		Args:        []string{"repo", "add", name, url},
		Env:         os.Environ(),
		StreamStdio: true,
	}
	res, err := task.Execute()

I then had to modify the external package go-execute in the function Execute() (ExecResult, error) so that...

		if strings.Index(et.Command, " ") > 0 {
			parts := strings.Split(et.Command, " ")
			command := parts[0]
			args := parts[1:]
			cmd = exec.Command(command, args...)

		} else {
			cmd = exec.Command(et.Command, et.Args...)
		}

became just:

cmd = exec.Command(et.Command, et.Args...)

Otherwise, exec.Command would still get only part of the path as it's first argument.

This golang issue indicates there may be a more general problem, but Arkade works for me with the changes listed above. FYI I'm using go 1.14.4.

Steps to Reproduce (for bugs)

  1. Follow standard instructions to install Arkade on Windows using Git Bash.
  2. Use Arkade in a way that tries to invoke Helm, for example: arkade install nginx-ingress.

Context

Using arkade at all on a Windows system with a space in its user path seems to be impossible. Some users may have no control over this, and in any case creating a brand new user account for this is very high-friction.

Your Environment

  • What Kubernetes distribution are you using?

N/A

  • Operating System and version (e.g. Linux, Windows, MacOS):

Windows 10 64-bit

  • What arkade version is this?

0.3.3

kilgariff avatar Jun 02 '20 17:06 kilgariff

We should be using command for the full path and then the args for everything subsequent.

If you want to test and propose a fix in a PR, I'll take a look.

alexellis avatar Jun 02 '20 19:06 alexellis