Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KUBE_EDITOR path with spaces on Windows doesn't work #117781

Open
theNailz opened this issue May 3, 2023 · 13 comments
Open

KUBE_EDITOR path with spaces on Windows doesn't work #117781

theNailz opened this issue May 3, 2023 · 13 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/windows Categorizes an issue or PR as relevant to SIG Windows.

Comments

@theNailz
Copy link

theNailz commented May 3, 2023

What happened:
I'm trying to configure kubectl to edit files using Sublime Text 3. My Sublime Text is installed in the default location (C:\Program files\Sublime Text 3\sublime_text.exe), which contains spaces.
I cannot seem to find the correct syntax for defining the KUBE_EDITOR environment variable, which works with this path.

Error produced:

PS C:\dev> $Env:KUBE_EDITOR="C:\Program Files\Sublime Text 3\sublime_text.exe" ; kubectl edit svc myservice
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
error: there was a problem with the editor "cmd /C C:\\Program Files\\Sublime Text 3\\sublime_text.exe"

What you expected to happen:
kubectl edit <resource> starts Sublime Text with the given resource yaml, either in CMD or PowerShell.

How to reproduce it (as minimally and precisely as possible):

# Powershell!
# Define the environment variable through system settings and run `kubetl edit <resource>`, or use this one-liner in Powershell:
# See also: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7.3#using-the-variable-syntax
$Env:KUBE_EDITOR="C:\Program Files\Sublime Text 3\sublime_text.exe" ; kubectl edit svc myservice
# CMD
# Define the environment variable through system settings and run `kubetl edit <resource>`, or use this syntax in CMD:
# See also: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/set_1
set KUBE_CONFIG="C:\Program Files\Sublime Text 3\sublime_text.exe"
kubectl edit svc myservice

Anything else we need to know?:

I've tried the following values, none of these work:

  • C:\Program Files\Sublime Text 3\sublime_text.exe (This is the correct path.)
  • "C:\Program Files\Sublime Text 3\sublime_text.exe"
  • 'C:\Program Files\Sublime Text 3\sublime_text.exe'
  • C:\\Program Files\\Sublime Text 3\\sublime_text.exe
  • file://C:/Program%20Files/Sublime%20Text%203/sublime_text.exe
  • C:\Program^ Files\Sublime^ Text^ 3\sublime_text.exe
  • C:\Program` Files\Sublime` Text` 3\sublime_text.exe

I have tried all variantions in both CMD and PowerShell.

Environment:

  • Kubernetes client and server versions (use kubectl version):
PS C:\dev> kubectl version --output=yaml
clientVersion:
  buildDate: "2023-04-14T13:21:19Z"
  compiler: gc
  gitCommit: 4c9411232e10168d7b050c49a1b59f6df9d7ea4b
  gitTreeState: clean
  gitVersion: v1.27.1
  goVersion: go1.20.3
  major: "1"
  minor: "27"
  platform: windows/amd64
kustomizeVersion: v5.0.1
serverVersion:
  buildDate: "2023-04-20T00:33:18Z"
  compiler: gc
  gitCommit: 8d0255af07e95b841952563253d27b0d10bd72f0
  gitTreeState: clean
  gitVersion: v1.26.4+k3s1
  goVersion: go1.19.8
  major: "1"
  minor: "26"
  platform: linux/amd64
  • Cloud provider or hardware configuration: n/a
  • OS (e.g: cat /etc/os-release):
OS Name:                   Microsoft Windows 11 Pro
OS Version:                10.0.22621 N/A Build 22621
PowerShell                 6.2.1
@theNailz theNailz added the kind/bug Categorizes issue or PR as related to a bug. label May 3, 2023
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label May 3, 2023
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@dims
Copy link
Member

dims commented May 3, 2023

@theNailz
Copy link
Author

theNailz commented May 4, 2023

@dims I have added two more variants to the list, with backticks and carets; neither works.

I have tried all variants in both CMD and PowerShell.

@dims
Copy link
Member

dims commented May 4, 2023

/transfer kubernetes

@k8s-ci-robot k8s-ci-robot transferred this issue from kubernetes/kubectl May 4, 2023
@k8s-ci-robot k8s-ci-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label May 4, 2023
@iyear
Copy link
Contributor

iyear commented May 6, 2023

https://www.sublimetext.com/docs/command_line.html#windows this may be helpful but have not been tested.

@oldium
Copy link

oldium commented May 9, 2023

Fixed in #112104 (not yet merged). Just keep in mind that double-quotes need to be preserved when setting the KUBE_EDITOR from PowerShell - PowerShell removes them (unlike cmd.exe), so those two lines are equivalent:

set KUBE_EDITOR="C:\Program Files\Sublime Text 3\sublime_text.exe"
$Env:KUBE_EDITOR="`"C:\Program Files\Sublime Text 3\sublime_text.exe`""
# or
$Env:KUBE_EDITOR='"C:\Program Files\Sublime Text 3\sublime_text.exe"'

And with the fix from #112104 it will be possible to pass additional arguments like this (example for Notepad++):

set KUBE_EDITOR="C:\Program Files\Notepad++\notepad++.exe" -multiInst -notabbar -nosession

or

$Env:KUBE_EDITOR="`"C:\Program Files\Notepad++\notepad++.exe`" -multiInst -notabbar -nosession"
# or
$Env:KUBE_EDITOR='"C:\Program Files\Notepad++\notepad++.exe" -multiInst -notabbar -nosession'

@pacoxu
Copy link
Member

pacoxu commented Aug 8, 2023

/sig cli windows

/close
per comments above, feel free to reopen if it still exists.
I edited, and I mis-read the message. Sorry

This may be dup with #72734 closed).

@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/windows Categorizes an issue or PR as relevant to SIG Windows. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 8, 2023
@k8s-ci-robot
Copy link
Contributor

@pacoxu: Closing this issue.

In response to this:

/sig cli windows

/close
per comments above, feel free to reopen if it still exists.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@pacoxu
Copy link
Member

pacoxu commented Aug 8, 2023

/reopen

@k8s-ci-robot k8s-ci-robot reopened this Aug 8, 2023
@k8s-ci-robot
Copy link
Contributor

@pacoxu: Reopened this issue.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@theNailz
Copy link
Author

theNailz commented Aug 22, 2023

@iyear Thanks! This way I was able to find a workaround:

  1. Add the Sublime Text directory to your PATH
  2. Set KUBE_EDITOR to sublime_text.exe -w (without the full path)

This does not fix the original issue, but does provide Windows users with a better editor, even when there are spaces in the path to the executable.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 26, 2024
@oldium
Copy link

oldium commented Jan 29, 2024

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/windows Categorizes an issue or PR as relevant to SIG Windows.
Projects
Status: Needs Triage
Status: No status
Development

No branches or pull requests

7 participants