-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REPL broken on main #58859
Comments
REPL hasn't been working on Windows as far as I can remember. I think it's also been that way on Linux. In other words, it only has ever worked on macOS. If what I have concluded is correct, this wouldn't be a "regression" if it never did work correctly in the first place. |
@philipturner it always worked on Linux up to including 5.6. It is definitely a regression. |
I saw a commit somewhere in the driver that this was intentional, don’t think this is a bug or anything |
Oh thank you! That makes (some) sense (although quite the change in a minor release) and I guess my macOS toolchain is just not new enough to get that functionality. @bitjammer I wasn't able to find the accepted Swift Evolution proposal for this change. Mind sharing that with me? |
Yes, this is expected behavior. |
However there was discussion about CL UX changes here: https://forums.swift.org/t/command-line-ux-enhancements-for-swift |
Okay thanks. @tomerd is that always the case that command line UX changes do not go through Evo? In this case, it may actually break scripts. Previously, this would run code:
now, it does no longer do that.
|
Change |
Sure, I'm just saying that this is a (potentially) breaking change. So some scripts may be broken by this change. Just FTR: I'm not against this change but I used to use this to quickly test stuff in docker. Of course adding a |
I guess what the developers of swift could do is detect for stdin input and then launch repl from there, which would maintain compatibility with these scripts, wouldn’t it? |
@bitjammer, @weissi makes a good point about this change breaking scripts / existing flows. could we detect the mode of trying to run a script (eg by examining the inputs) and "do the right thing"? |
What you can do is detect if swift is being piped into: let isBeingPiped = (isatty(STDIN_FILENO) == 0)
if isBeingPiped {
// trigger REPL
} I actually tried changing the code to do that, and it did actually detect when its being piped into (ie, |
What I was trying to move toward with this change was making the REPL an equal peer to other subcommands so that a more generalized, context-aware I totally take your point about breaking scripts but we have a sample size of one here and no details about what a script would actually be trying to accomplish by piping directly into the REPL. You mentioned that this "may" break scripts. Piping directly into the REPL in an automation context seems very esoteric to me–I would be super surprised if that was a dominant use case. The REPL is meant for a human being to enter explicitly. In that case, the In this case, it seemed like you ran this manually but is that what happened? If so, were you just poking at the command to see if Swift was installed properly in the Docker container? Is there some other underlying concern? |
Could this be because |
No idea, but it does sound like what you’re describing, as the process would end with a status 0 exit code immediately after starting REPL |
@bitjammer the goal of separating the concerns is a good one IMO. that said, I suggest we provide a gradual transitional path. for example, if we can detect these invocations and emit a deprecation warning but still perform the script / maintain previous behavior for a full release then remove it, it may be more palatable for users that came to depend on this behavior |
So, I added the help intro when running the REPL back in September of last year and only recently made the final switch. Are you saying we should turn the REPL back on for another additional cycle? |
I think the behaviour suggested by tomer would be a better option, keep it as it is right now however support piping with a warning if the script simply invokes |
right, I am suggesting we keep the new behavior, but when we detect a piped input we emit a deprecation warning and tee it off to repel to preserve previous behavior for one more cycle. |
@tomerd Though I think piping should always be supported, but only to |
I'm surprised that piping into
i.e. compile and execute, which has slightly different semantics from REPL mode. @weissi would that solve your issue? It seems like the new welcome screen and changes to what's automatically printed would already cause problems for automated scripts. |
I think the canonical way which also doesn't need a file on disk is
I don't personally rely on the old functionality, I was just pointing out that this is something that would break. I'm fine with changing it but I was slightly surprised by such a profound change w/o an evolution proposal. |
Recently I've been confused by Although it probably hasn't been stated as a requirement for CLI changes to go through SE, there have been some precedents: SE-0085, SE-0179, and SE-0301. The previous discussion being in the "Evolution" category on the forums gives (me, at least) the impression that the discussed improvements will land via the Evolution process as well. Maybe it's too much to ask for this change to go through SE, but I think this should have at least been an announcement on the forums or the blog. |
It was discussed on the forums here: https://forums.swift.org/t/command-line-ux-enhancements-for-swift/50670 |
Yes, I know.
|
Ah, sorry, I missed that part of your comment. I didn’t mean to imply anything by posting there necessarily, it seemed like the best place to announce the upcoming changes at the time. Will keep it in mind for the future. |
Describe the bug
On
main
, if you start the REPL by typingswift
you don't actually get into the REPL, you'll just see the help and you're back at the shell prompt (instead of the REPL prompt).To Reproduce
Steps to reproduce the behavior:
docker pull swiftlang/swift:nightly-main
2.docker run -it --rm --privileged swiftlang/swift:nightly-main swift
3.Expected behavior
A REPL prompt like in Swift 5.6 (and earlier):
Screenshots
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: