0

Whenever I attempt to set the EDITOR environment variable, a subsequent check reveals no value has been set.

I was attempting to edit the crontab:

sudo crontab -e -u mycooluser

which returns:

no crontab for mycooluser - using an empty one
Error opening terminal: unknown.
crontab: "/usr/bin/sensible-editor" exited with status 1

I then found this post: Setup a cronjob from commandline which suggested I change the editor used.

So I tried (including variations):

export EDITOR="/bin/nano"
export EDITOR="usr/bin/nano"
export EDITOR=nano

and when I execute (per this link How do I find and set my $EDITOR environment variable?):

echo $EDITOR

OR

printenv | grep EDITOR

I get nothing, a quick printenv check also confirms that no EDITOR variable exists in the list. To be clear, by 'nothing' I mean that on the echo $EDITOR it prints a blank line and for printenv | grep EDITOR nothing is printed.

Any idea why the variable isn't being set or why I can't seem to change it?

System: Ubuntu 18.04.1, Using Terminal in Webmin

  • You do not get a message like EDITOR: readonly variable when attempting to set the value, correct? – Jeff Schaller Apr 11 at 16:20
  • Correct, I do not, when I set the value, it acts as though it was executed with no other messages displayed. – Josh Whitlow Apr 11 at 16:21
  • What happens if you try EDITOR="/bin/nano" crontab -e? – Panki Apr 11 at 17:30
  • It returns the following: Error opening terminal: unknown. crontab: "/bin/nano" exited with status 1 – Josh Whitlow Apr 11 at 17:34
7

You are using the so-called "popup shell". This is not a terminal. Nor is it in fact really a shell.

It's a piece of user interface fakery inside a WWW browser that executes shell commands separately from one another as individual transactions. There's no actual continually running shell to hold an environment variable. It is merely presented that way by the user interface in the WWW browser. The shell commands are run in a nonce process environment where no TERM environment variable has been set, and in a session with no controlling terminal. And even if it were set, there's no terminal emulator to handle the terminal I/O that full-screen programs like text editors use. Indeed, there is only provision for relaying output of the program back to the local machine; no input is sent in the other direction.

nano, pico, and emacs will complain about being unable to determine the terminal type and open the terminal. VIM and NeoVIM fall back to assumptions that simply do not hold in this case, and give the appearance of simply hanging. Not even line-mode editors like ex and ed will work as user input is simply not sent to the remote machine. (One possibly could drive ex non-interactively with its -c option.) Similarly, one cannot change passwords with the passwd command.

This has been a misunderstanding of the "popup shell" since at least 2016.

Further reading

  • I decided to SSH into the server and then run the crontab commands and it worked just fine, thanks for the info I had no idea! Even the history command doesn't show a single thing I've typed into the "popup shell". – Josh Whitlow Apr 11 at 17:50
  • I think I heard you say that this was an opportunity for ed! – Jeff Schaller Apr 11 at 18:37
  • Recent versions of the theme would raise internal editor, upon calling edit, nano, vi and etc for path/to/file in inbuilt Command Shell port. – Ilia Rostovtsev Jun 10 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.