gerbil icon indicating copy to clipboard operation
gerbil copied to clipboard

Gerbil should give actionable error message when gsc is GhostScript

Open alecStewart1 opened this issue 5 years ago • 22 comments

I'm not entirely sure what caused this issue, but building (on Linux) gives this bit of errors

>>> preparing /home/bigdaddy/Tools/Lisp/gerbil
>>> compiling runtime
building gerbil/runtime in /home/bigdaddy/Tools/Lisp/gerbil/lib
... compile gx-gambc
GPL Ghostscript 9.26 (2018-11-20)
Copyright (C) 2018 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefinedfilename in (-e)
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push
Dictionary stack:
   --dict:972/1684(ro)(G)--   --dict:0/20(G)--   --dict:79/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.26: Unrecoverable error, exit code 1
*** ERROR IN for-each -- Compilation error; gsc exit with nonzero status "gx-gambc"
>>> preparing core build
'gerbil/prelude/core.ssxi.ss' -> '/home/bigdaddy/Tools/Lisp/gerbil/lib/gerbil/core.ssxi.ss'
'gerbil/runtime/gx-gambc#.scm' -> '/home/bigdaddy/Tools/Lisp/gerbil/lib/static/gx-gambc#.scm'
'gerbil/runtime/gx-gambc.scm' -> '/home/bigdaddy/Tools/Lisp/gerbil/lib/static/gx-gambc.scm'
'gerbil/runtime/gx-gambc0.scm' -> '/home/bigdaddy/Tools/Lisp/gerbil/lib/static/gx-gambc0.scm'
'gerbil/runtime/gx-gambc1.scm' -> '/home/bigdaddy/Tools/Lisp/gerbil/lib/static/gx-gambc1.scm'
'gerbil/runtime/gx-gambc2.scm' -> '/home/bigdaddy/Tools/Lisp/gerbil/lib/static/gx-gambc2.scm'
'gerbil/runtime/gx-version.scm' -> '/home/bigdaddy/Tools/Lisp/gerbil/lib/static/gx-version.scm'
>>> compiling gerbil core
*** ERROR IN for-each -- No such file or directory
(load "/home/bigdaddy/Tools/Lisp/gerbil/bootstrap/lib/gx-gambc0")
*** ERROR; build failed

Although I will say running gsc opens up a blank frame with "ghostscript" at the frames title. gsc-script actually runs the Gambit compiler. Don't know if that helps anything.

alecStewart1 avatar Mar 24 '19 01:03 alecStewart1

gsc is the name of the Gambit Scheme Compiler, but also that of the GhostScript Console interface. Gerbil expects the former to be in your $PATH but at least with a recent Gerbil, you can also export GERBIL_GSC=/path/to/proper/gsc

fare avatar Mar 24 '19 04:03 fare

Maybe Gerbil could better detect this situation and give usable advice to the user?

fare avatar Mar 24 '19 04:03 fare

I can't remember what I have installed that requires GhostScript, but I know it's require for some software I have.

I'll try the export GERBIL_GSC=/path/to/gsc-script.

alecStewart1 avatar Mar 24 '19 15:03 alecStewart1

Hm, I actually just changed this line in build0.scm to gsc-script and it worked, as well as export GERBIL_GSC=/path/to/gsc-script.

I'm no Scheme expert, but could path: take (or "gsc" "gsc-script")? That viable in some situations in Common Lisp, but I don't know about Scheme (I'd be surprised if it wouldn't work). I would test that myself, but I'm about to be pretty busy with other things.

alecStewart1 avatar Mar 24 '19 15:03 alecStewart1

There is no option to take a disjunction for the executable. Besides, gsc exists it just happens to be the ghostscript interpreter in your system, so even if it was possible it wouldn't help.

vyzo avatar Mar 24 '19 16:03 vyzo

When the call to gsc fails, Gerbil could call a diagnostic function that returns a more appropriate error message.

fare avatar Mar 24 '19 16:03 fare

Could it not attempt using gsc-script if gsc fails? That'd be quick to fail for most systems, considering this might be a fringe case of my system calling the gambit compiler gsc-script. It would fail for most easily. But again, I feel like my situation is a fringe case.

alecStewart1 avatar Mar 24 '19 20:03 alecStewart1

But I removed GhostScript anyway. It wasn't an essential package for anything. I could just symlink gsc-script to gsc since GhostScript isn't on my system anymore and doesn't need to be.

alecStewart1 avatar Mar 24 '19 20:03 alecStewart1

There is no easy way to determine whether there was a compilation error or simply the wrong program executed. Perhaps with the exit value, but that's unreliable.

vyzo avatar Mar 25 '19 08:03 vyzo

That's why if there was something off, then run diagnostics, such as calling gsc with some parameters known to work, for instance comparing the output of gsc -v to the expected output, etc.

fare avatar Mar 25 '19 17:03 fare

Also specially recognize GhostScript, which is a frequent thing to clash with Gambit.

fare avatar Mar 25 '19 17:03 fare

it might make sense to run this diagnostic before starting the build. So instead of littering the compiler with ugly detection code, we can make it part of the build script.

vyzo avatar Mar 25 '19 17:03 vyzo

I would make it a diagnostic always run (with redirected output) after a single compilation call (of e.g. gxc), and explicitly called before by a build script when a build script is used.

fare avatar Mar 25 '19 18:03 fare

like a doctor script

ober avatar Aug 07 '19 02:08 ober

Both Gambit gsc and Ghostscript gsc have a -v flag to show the version number.

Gambit (all output on one long line, which I split with \):

$ gsc -v
v4.9.3 20180930122740 x86_64-unknown-linux-gnu "./configure \
'--prefix=/usr/local/gambit' '--enable-single-host' '--enable-openssl' \
'--enable-default-runtime-options=f8,-8,t8' '--enable-poll'"

Ghostscript:

$ gsc -v
GPL Ghostscript 9.27 (2019-04-04)
Copyright (C) 2018 Artifex Software, Inc.  All rights reserved.

Both commands commonly run in less than 0.05 seconds. So one option would be to add a gsc -v check before compiling. Read the first line of text from standard output and if it starts with GPL Ghostscript, show an error message about the gsc name conflict. The same check can be used to check that the version of Gambit is compatible with Gerbil, should you need that.

Both Gambit gsc -v and Ghostscript gsc -v write only to stdout, write nothing to stderr, and exit with code 0 when they succeed.

lassik avatar Sep 27 '19 07:09 lassik

I suggest that Gerbil should prepend "Gerbil " to its version string, which would make it easier to distinguish Gerbil from GhostScript.

fare avatar Sep 28 '19 13:09 fare

Neither gxc nor gxi seems to have a version flag at the moment. The above is Gambit's version output (both gsc -v and gsi -v work identically; gsc is an extended version of gsi IIRC).

Adding version flags to gxc and gxi would be a fine idea, as would starting the output with Gerbil. Perhaps Gambit's version output should start with Gambit as well, though those commands are old enough that someone may depend on the current output format.

lassik avatar Sep 28 '19 15:09 lassik

Oops, indeed this is a Gambit issue. I opened: https://github.com/gambit/gambit/issues/410

fare avatar Sep 28 '19 16:09 fare

Thanks! It's nice if it works out. Marc can probably say whether or not the change would be too big a break in backward-compatibility.

lassik avatar Sep 28 '19 16:09 lassik

From the above-linked thread in Gambit issues:

It seems the original problem can be solved much more directly by calling up the gsc-script program, which is the same as gsc but doesn't clash with ghostscript.

lassik avatar Oct 02 '19 20:10 lassik

Is this configurable? On Arch Linux, gambit-scheme compiler's name is gambit-c Nevermind I didn't read the comments

glyh avatar Apr 04 '22 15:04 glyh

you can set the GERBIL_GSC env variable.

vyzo avatar Apr 04 '22 15:04 vyzo

Should this be close or left open?

alecStewart1 avatar Oct 10 '22 17:10 alecStewart1

well, we probably should still check on configure for this, so lets leave it open.

vyzo avatar Oct 10 '22 17:10 vyzo

No longer an issue; We are in the Future, and Gambit has been integrated.

vyzo avatar Sep 09 '23 14:09 vyzo