Skip to content

REPL shell mode is incompatible with nushell #54291

@MilesCranmer

Description

@MilesCranmer
Member

It seems that the nushell shell is incompatible with the Julia REPL at the moment. When I hit ; in the Julia REPL to open the shell, and write any command, I get this:

julia> ;
shell> echo "Hello World"
Error: nu::parser::shell_andand

  × The '&&' operator is not supported in Nushell
   ╭─[source:1:22]
 1 │ (echo 'Hello World') && true
   ·                      ─┬
   ·                       ╰── instead of '&&', use ';' or 'and'
   ╰────
  help: use ';' instead of the shell '&&', or 'and' instead of the boolean '&&'

I think the Julia REPL should either be made compatible with nushell, or it should run commands in a compatible shell like bash. Right now I can't seem to do anything in the shell mode because my default shell is nushell.

Context: Nushell is a new type of cross-platform shell written in pure rust: https://github.com/nushell/nushell/. Instead of "&&" they use "and" (among several other differences).

Activity

jakobjpeters

jakobjpeters commented on Apr 29, 2024

@jakobjpeters
Contributor

I also would like to use nushell. This Discourse post says that shell mode only supports POSIX shells and that one can set the JULIA_SHELL environment variable as a workaround.

Seelengrab

Seelengrab commented on Apr 29, 2024

@Seelengrab
Contributor

The shell> mode in the REPL doesn't actually spawn a shell, and instead evokes programs directly IIRC. How does this end up calling into nushell in the first place?

MilesCranmer

MilesCranmer commented on Apr 29, 2024

@MilesCranmer
SponsorMemberAuthor

I’m not sure how it gets called. Maybe if JULIA_SHELL is unset it simply takes SHELL?

But where does the && come from? All that needs to be changed is that. Is that from run?

At the bottom of #23597 @xgdgsc and @stevengj were also discussing Nushell as a potential solution to having a shell mode on windows.

KristofferC

KristofferC commented on Apr 29, 2024

@KristofferC
Member

The shell> mode in the REPL doesn't actually spawn a shell, and instead evokes programs directly IIRC

I think the shell mode does spawn a shell. Perhaps you are thinking about run?

Anyway, a small tweak to

julia/base/client.jl

Lines 63 to 68 in 6023ad6

if shell_name == "fish"
shell_escape_cmd = "begin; $(shell_escape_posixly(cmd)); and true; end"
else
shell_escape_cmd = "($(shell_escape_posixly(cmd))) && true"
end
cmd = `$shell -c $shell_escape_cmd`

could probably fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @KristofferC@MilesCranmer@Seelengrab@jakobjpeters

      Issue actions

        REPL shell mode is incompatible with nushell · Issue #54291 · JuliaLang/julia