-
Notifications
You must be signed in to change notification settings - Fork 698
Closed
Labels
Description
The open
command is found, but the assumption this is a mac is too speculative at time in place for Linux.
To Reproduce
$ direnv edit .
direnv: $EDITOR not found.
xdg-open: unexpected option '-t'
Try 'xdg-open --help' for more information.
direnv: error exit status 1
Expected behavior
$ EDITOR=editor direnv edit .
# works
Environment
- OS: Ubuntu 22.04
- Shell: bash
- Direnv version 2.25.2
Additional context
$ printenv | sed -n '/^EDITOR=/p'
# no output
direnv/internal/cmd/cmd_edit.go
Lines 87 to 104 in 7323cc3
// Editors contains a list of known editors and how to start them. | |
var Editors = [][]string{ | |
{"subl", "-w"}, | |
{"mate", "-w"}, | |
{"open", "-t", "-W"}, // Opens with the default text editor on mac | |
{"nano"}, | |
{"vim"}, | |
{"emacs"}, | |
} | |
func detectEditor(pathenv string) string { | |
for _, editor := range Editors { | |
if _, err := lookPath(editor[0], pathenv); err == nil { | |
return strings.Join(editor, " ") | |
} | |
} | |
return "" | |
} |
$ namei -v `which open` | sed -nE '/^[fl]/p'
f: /usr/bin/open
l open -> /etc/alternatives/open
l open -> /usr/bin/xdg-open
$ namei -v `which editor` | sed -nE '/^[fl]/p'
f: /usr/bin/editor
l editor -> /etc/alternatives/editor
l editor -> /usr/bin/vim.basic
…
$ update-alternatives --get-selections | grep ^editor
editor auto /bin/nano
$ update-alternatives --list editor
/bin/ed
/bin/nano
/usr/bin/vim.tiny
$ EDITOR=open direnv edit .
# works, but fails if .envrc does not exists