Skip to content
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

non-interactive REPL mode breaks STDIN #1824

Open
zoffixznet opened this issue May 13, 2018 · 8 comments
Open

non-interactive REPL mode breaks STDIN #1824

zoffixznet opened this issue May 13, 2018 · 8 comments
Labels
IO tests needed Issue is generally resolved but tests were not written yet

Comments

@zoffixznet
Copy link
Contributor

zoffixznet commented May 13, 2018

$ perl6 <<< get                                                                                                                                                                                                
Failed to stat file descriptor: Bad file descriptor
  in block <unit> at - line 1

$ echo 'get' | perl6 -
MVMArray: Index out of bounds
  in block <unit> at - line 1

$ perl6 -v
This is Rakudo version 2018.03-265-g656ff77b9 built on MoarVM version 2018.03-126-g876aa90ee
implementing Perl 6.c.

And the cause is:

$ echo '$*IN.native-descriptor.say' | perl6 -
-1

And the fix is to stick unless $filename eq '-' for the .close line in NQP (a few lines up, we use the same condition to set that handle to stdin)

@zoffixznet zoffixznet added IO good first issue This issue is likely easy for beginners to resolve easy to resolve This issue is likely easy for beginners to resolve good first issue and removed good first issue labels May 13, 2018
@uzluisf
Copy link

uzluisf commented May 20, 2018

I already added:

unless $filename eq '-' {
     $in-handle.close;
}

in my local repo and running the same commands but I'm still getting the same output. I'm not sure what I should do next so any advice would be appreciated.

@zoffixznet
Copy link
Contributor Author

zoffixznet commented May 20, 2018

Are you sure you rebuilt nqp and rakudo correctly? Which commands did you use?

@uzluisf
Copy link

uzluisf commented May 20, 2018

I just used make and make install.

@zoffixznet
Copy link
Contributor Author

Try this:

In your nqp dir:

make clean
make
make install

Then in your rakudo dir:

make clean
make
make install

That should make the fix available in your rakudo and fix the bug. You can then run:

make spectest

To run the spectest to ensure there are no new errors.

Alternatively, there's also Z-Script you could use:

Install and initialize in ~/R/:

    git clone https://github.com/zoffixznet/z ~/zscript &&
    cd ~/zscript &&
    zef --depsonly install .

    echo 'export PATH="$HOME/zscript/bin:$PATH"' >> ~/.bashrc
    . ~/.bashrc

    z init ~/R

Then swap nqp remote to your fork (you need to fork it. Click "Fork" button at the top right of the page):

    cd ~/R/nqp/
    git remote remove origin
    git remote add origin https://github.com/uzluisf/nqp

Then make the change, then run:

z n

That will rebuild NQP and rakudo and the change should fix the bug. Then you can run

z s

To run the spectest. Then commit the fix:

    cd ~/R/nqp
    git commit src/HLL/Compiler.nqp

Type a good commit message, then git push and then submit the PR on github.

@uzluisf
Copy link

uzluisf commented May 21, 2018

So I ran the commands to rebuild nqp and rakudo and everything went apparently fine.

After that, I executed perl6 <<< get, echo 'get' | perl6 - and echo '$*IN.native-descriptor.say' | perl6 - to check if the fix took effect but I'm getting the same output you detailed in the issue.

@zoffixznet
Copy link
Contributor Author

zoffixznet commented May 21, 2018

But is perl6 the rakudo you built or your system-installed one? In my builds, I have to use ./perl6 to run the one I built and running just perl6 without ./ runs the system one.

@uzluisf
Copy link

uzluisf commented May 21, 2018

Yes, you're totally right. I was running the system's rakudo not the one I built. Sorry for that misunderstanding.

Regarding the commit message, can I reference the issue? I'm not really sure what I should put for the commit message.

@zoffixznet
Copy link
Contributor Author

Regarding the commit message, can I reference the issue? I'm not really sure what I should put for the commit message.

Yeah, if you include a link to it, GitHub will even reference the commit on this Issue.

Message could be something like

Do not close STDIN it is the source of the program

Fixes https://github.com/rakudo/rakudo/issues/1824

@zoffixznet zoffixznet added tests needed Issue is generally resolved but tests were not written yet and removed easy to resolve This issue is likely easy for beginners to resolve good first issue This issue is likely easy for beginners to resolve labels May 21, 2018
@zoffixznet zoffixznet reopened this May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO tests needed Issue is generally resolved but tests were not written yet
Projects
None yet
Development

No branches or pull requests

2 participants