Xonsh: Config wizard escapes strings; errors on next start

Created on 13 Aug 2016  Â·  5Comments  Â·  Source: xonsh/xonsh

If a user is new to xonsh, and running through the wizard to setup environment variables, I don't think there's any reason to assume that when presented with:

Default: 'best'
Current: 'readline'
>>>
that the user will realise they are to enter a string without quotes.

>>> 'prompt_toolkit' # it's Python, right, so this is a string
...
$ # awesome - now I'll just install prompt_toolkit so I can use it
^D
% pip install prompt_toolkit pygments
...
% xonsh
Traceback (most recent call last):
  File "/usr/bin/xonsh", line 3, in <module>
    main()
  File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 16518, in main
    args = premain(argv)
  File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 16503, in premain
    shell = builtins.__xonsh_shell__ = Shell(**shell_kwargs)
  File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 16282, in __init__
    shell_type))
xonsh.__amalgam__.XonshError: 'prompt_toolkit' is not recognized as a shell type
sh-4.3$ xonsh
Traceback (most recent call last):
  File "/usr/bin/xonsh", line 3, in <module>
    main()
  File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 16518, in main
    args = premain(argv)
  File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 16503, in premain
    shell = builtins.__xonsh_shell__ = Shell(**shell_kwargs)
  File "/usr/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 16282, in __init__
    shell_type))
xonsh.__amalgam__.XonshError: 'prompt_toolkit' is not recognized as a shell type
% # :(
% # this is not even immediately obvious, quoting a variable's value in an error message
% #     is reasonable enough
% # hmm..
% cat $XDG_CONFIG_HOME/xonsh/config.json
{
...
  "SHELL_TYPE": "'prompt_toolkit'"
...
}

Removing the single quotes fixes it.

Without being more familiar with the 'philosophy' of xonsh (do I ever need quote Python strings?) I think the easiest solution might just be to remove the quotes from the reprd default and current values.

I might still get it wrong - imagining it has to be valid Python - but at least I'd have only myself to blame as the prompt would not have included them. As it stands I just think it's a little misleading.

feature help wanted

Most helpful comment

You're right @OJFord, there is a discussion on making the wizard more intuitive and easy for newcomers. The philosophy of xonsh is that 'python always wins', in this case, getting input from the user, it should be kind of obvious that the input will always be a string, like when using pythons input() builtin function. What makes this ambiguous is that default and current values have quotes around them so the user maybe be tempted to do the same. Either way thanks for bringing this up and this should definitely be more clear!

All 5 comments

You're right @OJFord, there is a discussion on making the wizard more intuitive and easy for newcomers. The philosophy of xonsh is that 'python always wins', in this case, getting input from the user, it should be kind of obvious that the input will always be a string, like when using pythons input() builtin function. What makes this ambiguous is that default and current values have quotes around them so the user maybe be tempted to do the same. Either way thanks for bringing this up and this should definitely be more clear!

Yep that sounds good.

it should be kind of obvious that the input will always be a string, like when using pythons input() builtin function

Perhaps it could be more obvious if the prompt were something other than >>>? Because:

>>> prompt_toolkit
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'prompt_toolkit' is not defined
>>> 'prompt_toolkit'
'prompt_toolkit'
>>>

Anyway, awesome work - loving xonsh so far! :)

Perhaps it could be more obvious if the prompt were something other than >>>

+1

or we can take it a step further and numerate the options so the user will just enter a number and not the whole name.

I like numeration for choices that aren't open ended. For others, we should
just strip out punctuation

On Aug 13, 2016 4:39 PM, "Konstantinos Tsakiltzidis" <
[email protected]> wrote:

Perhaps it could be more obvious if the prompt were something other than

+1

or we can take it a step further and numerate the options so the user will
just enter a number and not the whole name.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/xonsh/xonsh/issues/1555#issuecomment-239640468, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ADbix6Vbdy0y6OtxkOpzg5oVnMBpHeF8ks5qfiuegaJpZM4JjvqH
.

Any UI fixes to the wizard are very much appreciated!

Was this page helpful?
0 / 5 - 0 ratings