gerbil
gerbil copied to clipboard
Gerbil should give actionable error message when gsc is GhostScript
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.
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
Maybe Gerbil could better detect this situation and give usable advice to the user?
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
.
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.
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.
When the call to gsc
fails, Gerbil could call a diagnostic function that returns a more appropriate error message.
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.
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.
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.
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.
Also specially recognize GhostScript, which is a frequent thing to clash with Gambit.
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.
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.
like a doctor script
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.
I suggest that Gerbil should prepend "Gerbil " to its version string, which would make it easier to distinguish Gerbil from GhostScript.
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.
Oops, indeed this is a Gambit issue. I opened: https://github.com/gambit/gambit/issues/410
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.
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.
Is this configurable? On Arch Linux, gambit-scheme compiler's name is gambit-c
Nevermind I didn't read the comments
you can set the GERBIL_GSC
env variable.
Should this be close or left open?
well, we probably should still check on configure for this, so lets leave it open.
No longer an issue; We are in the Future, and Gambit has been integrated.