How to distribute programs that require Gregor?

Hello there,

I had asked a question related to Gregor, and the fact that it is not currently possible to run a Racket program compiled on one system with Gregor on another system, if Gregor and Racket haven't been installed on that system. There had been a discussion on the fact that Gregor requires something to be configured on the system before it can run correctly (something to do with localization...), but I never got a clear answer on how to do this manually so programs that require Gregor on a virgin system run without having it installed prior.

Steps to reproduce:

If you run the binary distribution of my small invoicing tool Invoicer:
GitHub - DexterLagan/invoicer: A dead-simple, easy-to-use minimalist billing application.

...you'll get a quick error in a console window that closes instantly. If you install Racket, then install the Gregor package, magically the same binary runs fine.

Another way to reproduce the problem: download the Invoicer source, install Gregor, compile Invoicer, copy the resulting binary to a system without Racket or Gregor ever installed. Run the binary.

My question: what is it that Gregor does when installing its package that I could do myself on the target system to make sure my binaries run without having Racket/Gregor installed?

Thanks a bunch!

Dex

I can't say anything specifically about Gregor, but I have ideas.

I assume you're using raco exe to create the binary. Are you using the command line option --embed-dlls?

It seems you don't have an info.rkt file in your repository, which should list the required packages. I don't know if raco exe relies on that or if it's enough to follow the requires in the "main file."

I see several different pages about info.rkt in the Racket documentation, but I think it's easiest to run raco pkg new <dummy_project_directory> on the command line and derive your info.rkt from the one in the generated dummy project, possibly also consulting the Racket documentation.

Hi, I do use --embed-dlls, and gregor seems to be packaged up with everything else. The problem is that Gregor requires some settings to be 'installed' on a system before it can function. I did try creating a proper package, to no avail. I believe it's a matter of finding out which localization (registry?) settings are installed when Gregor is installed through the package manager, and replicating these settings before attempting to run the binary.

Dex

Is this the error you get?

Unable to locate the zoneinfo database on this computer. We searched for it in the following places:
  - tzdata/zoneinfo
  - /usr/share/zoneinfo
  - /usr/share/lib/zoneinfo
  - /etc/zoneinfo

Most likely, you need to install a package for your operating system that contains the zoneinfo database. If the zoneinfo database is already installed on your computer, please file a bug report at https://github.com/97jaz/tzinfo/issues and mention where on your filesystem it is installed.

I'm not sure how this is solved on Windows or Macs, but on Ubuntu installing the tzdata Ubuntu package resolves the issue for me for this simple program:

#lang racket/base

(require gregor)
(now)

On a Windows platform, the time zone database is installed from the tzdata Racket package, which is a dependency of gregor. You need to use raco dist to package these files with the distributed executable, the --embed-dlls option will not help here, since these files are not DLLs.

In general, you cannot skip the raco dist step when distributing stand-alone Racket applications, on any platform, since other libraries might contain files which are not Racket source files or shared libraries.

See also: Bundling external libraries with Raco Distribute - #6 by alexh

I find that a lot of people are confused by the --embed-dlls option, and they think they can ship just the executable file that it produces, but this only works in very limited cases.

Alex.

5 Likes

Thanks Alex I'll give it another try. I could swear I had tried the distribute option (which is what I use by default to distribute executables).

Dex

Alex, you were absolutely right, raco dist does work and it packages the tzdata. I had a doubt since I've been distributing another program through its .exe alone, yet it uses http-easy. Thanks again for your help, and my apologies for asking a question you had already answered ! I believe the confusion comes from the fact that many people (me included) mostly use the compilation option available inside DrRacket, which might not actually use dist, but only generates a .exe. I'll experiment and make a script to automate this.

Dex

1 Like

Hi Dex-- did you find the "Racket|Create Executable..." menu option? It has some radio boxes and some commentary there. If your experience suggests an improvement, I'd be interested to hear it.

Thanks,
Robby