heroku / heroku/cli

`config:edit` examples using `$EDITOR` / `$VISUAL` with args don't work

Open
#1,996 3 comments 3 reactions 0 assignees View on GitHub
feature request on-call reviewed
Dominant language
TypeScript
Stars
889
Forks
236
Avg merge
2d 10h
Merged PRs (30d)
33

Description

Do you want to request a *feature* or report a *bug*?
-----------------------------------------------------
Bug

What is the current behavior?
-----------------------------

The `config:edit` help text says:

```
DESCRIPTION
This command opens the app config in a text editor set by $VISUAL or $EDITOR.
Any variables added/removed/changed will be updated on the app after saving and closing the file.

EXAMPLES
# edit with vim
$ EDITOR="vim" heroku config:edit
# edit with emacs
$ EDITOR="emacs" heroku config:edit
# edit with pico
$ EDITOR="pico" heroku config:edit
# edit with atom editor
$ VISUAL="atom --wait" heroku config:edit
```

This works if I set `EDITOR` (or `VISUAL`) to a single command (such as `code`), however fails if I pass in additional arguments as per the final example in the help text.

```
$ EDITOR='code --wait' h config:edit
Fetching config... done
Waiting for code --wait... Error: spawn code --wait ENOENT
```

In VSCode's case, the argument `--wait` is required to make the editor wait for the window to be closed before the command returns (otherwise one gets a ` › Warning: no changes to config` warning from the Heroku CLI, as the command returned early).

This is using macOS 12.3.1 with Homebrew bash.

What is the expected behavior?
------------------------------

That:
- The examples reflect what works
- It's possible to have `EDITOR` or `VISUAL` set to values that include arguments to commands.

----

This editor functionality is provided by the `edit-string` package, called here:
https://github.com/heroku/cli/blob/b8292f347101f13c2bb833b1dcf088886c8aa984/packages/config/src/commands/config/edit.ts#L105

Whose implementation is here:
https://github.com/jdxcode/edit-string/blob/v1.1.6/src/edit.ts

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.