Search code examples
linuxgforth

Gforth can't find script it's supposed to start


I tried to execute a cgi script written in Gforth through the terminal by ./myscript.cgi, however it throws an error: No such file or directory. Executing the same code as a .fs file throws the same error message-text. I believe the problem is that Gforth fails to open the file.

I'm running Arch Linux and had to install Gforth through snapd. The Gforth binary/executable thus lies in var/lib/snapd/snap/bin/gforth which I found out through $ whereis gforth.

Simplifying the problem: I'm trying to execute a test.fs file with Gforth with $ gforth /path/to/file in the terminal, however not successful:

$ gforth /srv/http/cgi-bin/mytest.fs

*in file included from *the terminal*:0:-94635140744367:
*the terminal*:-1:1: error: No such file or directory
>>>/srv/http/cgi-bin/mytest.fs<<<
Backtrace:
...*

The image shows the backtrace of the error message. The trace points to files inside the directory /snap/gforth/27/usr/share/gforth/0.7.9_20230130/...

However the file directory is correct.

The Gforth documentation looks like:

You can easily start Gforth with some files loaded like this:

gforth file1.fs file2.fs

so I think I am typing the correct command. And all permissions for the file are given.

The test script in gforth looks as following - nothing complicated

." Hello World"
bye

Solution

  • Deinstalling snapd Gforth and reinstalling it via Arch AUR seems to be the solution. Thus your problem was that Gforth wasn't correctly installed.

    To install AUR packages you should see here and this is the Gforth package

    First create a build directory. I created mine under /home/<user>/builds (creating dir by $ mkdir <dirname>) and than in there download Gforth by $ git clone https://aur.archlinux.org/gforth.git.

    Check if you have permissions for that folder by $ ls -al and looking for gforth. Here is a guide. If not all users have write permissions do: $ chmod o=rwx gforth.

    Go into Gforth ($ cd gforth) and build the package by $ makepkg -si.

    After following the installation, Gforth should run correct. Try it out with $ gforth and you should be welcomed by the gforth terminal.