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

Can't run Red from other programs #3562

Closed
maximvl opened this issue Oct 12, 2018 · 10 comments
Closed

Can't run Red from other programs #3562

maximvl opened this issue Oct 12, 2018 · 10 comments
Assignees
Labels
status.resolved Issue has been resolved without a change in the source code (should be elaborated in comments).
Milestone

Comments

@maximvl
Copy link

maximvl commented Oct 12, 2018

Describe the bug
When I try to execute Red from another program it fails with PROGRAM ERROR: Invalid encapsulated data.

To Reproduce
Steps to reproduce the behavior:

  1. Install Elixir
  2. Clone https://gitlab.com/maxvel/reddish.git
  3. In the repo run iex -S mix
  4. In the REPL type
p = Reddish.start
Reddish.send_input(p, "5 + 5\n")
flush()
  1. See message {#PID<0.170.0>, :data, :out, "PROGRAM ERROR: Invalid encapsulated data.\n"}
  2. After this I can't even run Red as regular:
> red
PROGRAM ERROR: Invalid encapsulated data.
  1. And in a new shell instance:
> red
** Script Error: Invalid compressed data - problem: -3
** Near: script: decapsulate 
if none? script

Expected behavior
flush() prints message with "10" returned by Red, Red is runnable.

Screenshots
screenshot

Platform version(please complete the following information):

Red 0.6.3 for Linux built 11-Oct-2018/3:00:23+02:00 commit #b1f01cc
@9214
Copy link
Collaborator

9214 commented Oct 12, 2018

#543, #1547

@maximvl
Copy link
Author

maximvl commented Oct 12, 2018

I also tried to create a wrapper like this:

#!/bin/bash
red $@

With it I don't get the error, but got no output either. From what I tried this works with cat, bash and ipython, but doesn't work with python (same no output). So it might be more than just fixing encapping.

@dockimbel
Copy link
Member

If you need only the Red interpreter, compile the CLI console and use that binary instead of red.exe.

@x8x
Copy link
Contributor

x8x commented Oct 20, 2018

I work around this issue by wrapping the Red call into sh like this:

sh -c "red -r code.red"

I suspect a path issue in certain environment where the console called from red binary can't find the crush decompressor maybe not as in the example the toolchain is called not the console.., but haven't investigated further.

Other example, given %code.red:

Red []
print 123

Run a Red Console:

  o: "" call/output {red code.red} o print o
** Script Error: Invalid compressed data - problem: -3
** Near: script: decapsulate 
if none? script

  o: "" call/output {sh -c "red code.red"} o print o
123

Wondering if it's a regression, must have had similar code working without wrapping long ago.

Not really related.. we should really have something like rebol --do "print 123" for quickies.

@qtxie qtxie added this to the 0.6.5 milestone Oct 22, 2018
@beenotung
Copy link

I found similar bug on windows.
I saved red as red.exe, and add the containing folder into PATH.
I found it will raise below error when launch form cmd:

PROGRAM ERROR: Invalid encapsulated data.

below case will trigger error

  1. if the current directory is not containing red, and using red or red.exe
  2. if the current directory is not containing red, and using ..\local\bin\red

below case will not trigger error

  1. if the current directory is containing red, and using red or red.exe
  2. if the current directory is not containing red, and using ..\local\bin\red.exe

@beenotung
Copy link

beenotung commented May 23, 2019

I tried the test cases with rebol-core and rebol-view, all the two cases trigger error for red do not trigger error for rebol.

@greggirwin
Copy link
Contributor

Thanks for the note @beenotung.

@pierstitus
Copy link

pierstitus commented Jul 6, 2020

I get the same error when running from ipython3:

Python 3.8.2 (default, Apr 27 2020, 15:53:34) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import subprocess

In [2]: subprocess.run('./red-064')
** Script Error: Invalid compressed data - problem: -3
** Near: script: decapsulate 
if none? script
Out[2]: CompletedProcess(args='./red-064', returncode=0)

Running from python3 gives a slightly different error:

Python 3.8.2 (default, Apr 27 2020, 15:53:34) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.run('./red-064')
** Script Error: Not enough memory
** Near: script: decapsulate 
if none? script
CompletedProcess(args='./red-064', returncode=0)

It doesn't matter what arguments are given, subprocess.run(['./red-064','hello.red']) or subprocess.run(['./red-064','-V']) give the same error. Compiled red programs do run normally.

@hiiamboris hiiamboris added the status.waiting Ticket is put on hold fo some dependency to be first processed (should be elaborated in comments). label Jul 13, 2020
@endo64
Copy link
Contributor

endo64 commented Feb 26, 2021

I just realized that, on Windows, if your red.exe is located in your PATH, you get PROGRAM ERROR: Invalid encapsulated data. if you execute red.exe in command prompt (cmd.exe), but it works if you use Powershell.

And also the output speed is much faster on Powershell.

@dockimbel dockimbel removed this from the 21.10 milestone Aug 11, 2022
@dockimbel
Copy link
Member

The Red binary is now separated in several binaries. The CLI console binary can be called from other languages if needed.

@dockimbel dockimbel added status.resolved Issue has been resolved without a change in the source code (should be elaborated in comments). and removed status.waiting Ticket is put on hold fo some dependency to be first processed (should be elaborated in comments). labels Sep 28, 2022
@dockimbel dockimbel self-assigned this Sep 28, 2022
@dockimbel dockimbel added this to the 0.7.0 milestone Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status.resolved Issue has been resolved without a change in the source code (should be elaborated in comments).
Projects
None yet
Development

No branches or pull requests

10 participants