# Get version from info.rkt

**URL:** <https://racket.discourse.group/t/get-version-from-info-rkt/3843>\
**Category:** Questions & Answers\
**Created:** [July 9, 2025, 10:29am UTC](https://racket.discourse.group/t/get-version-from-info-rkt/3843 "2025-07-09T10:29:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [July 9, 2025, 10:29am UTC](https://racket.discourse.group/t/get-version-from-info-rkt/3843/1 "2025-07-09T10:29:08Z")

</div>

hello,

i have an info.rkt file in my package, that contains the version number, how can i retrieve it from my code?.

```scheme
#lang info
....
(define version "10.3")
.....

```

i can require the info.rkt file but the definition are not available when i do that:

i only get the version procedure of Racket that return the version of racket (8.14 here)

Regards,

Damien

---

<div class="post-metadata">

**Author:** ![joeld](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joeld/32/38_2.png) [@joeld](https://racket.discourse.group/u/joeld)\
**Post date:** [July 10, 2025, 5:31pm UTC](https://racket.discourse.group/t/get-version-from-info-rkt/3843/2 "2025-07-10T17:31:01Z")

</div>

See [API for reading `info.rkt` files](https://docs.racket-lang.org/raco/getinfo.html) — you probably want to use the procedure returned by `get-info` for your collection:

```scheme
(require setup/getinfo)

(define info-getter (get-info '("my-collection"))) ; note collection, not package name!

(cond
  [(procedure? info-getter) (info-getter 'version)]
  [else info-getter])

```

This will result in `"1.0"` (e.g.) if all goes well, or `#f` if the info.rkt could not be found, or an exception if it is found but `version` isn’t defined in it.

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [July 10, 2025, 7:27pm UTC](https://racket.discourse.group/t/get-version-from-info-rkt/3843/3 "2025-07-10T19:27:20Z")

</div>

thank, this worked exactly.

```scheme
(require setup/getinfo)
(define info-getter (get-info '("Scheme+")))
(cond ((procedure? info-getter) (info-getter 'version)) (else info-getter))
"10.3"

```

---

<div class="post-metadata">

**Author:** ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)\
**Post date:** [July 10, 2025, 8:49pm UTC](https://racket.discourse.group/t/get-version-from-info-rkt/3843/4 "2025-07-10T20:49:07Z")

</div>

See also the technique for doing it at compile time: [https://github.com/benknoble/frosthaven-manager/blob/8c69323bddc1b7b5c576d1fe42a446b91ab408d3/gui/common-menu.rkt#L30](https://github.com/benknoble/frosthaven-manager/blob/8c69323bddc1b7b5c576d1fe42a446b91ab408d3/gui/common-menu.rkt#L30), where [https://github.com/benknoble/frosthaven-manager/commit/acf849311ecc4d5247b71e64e1370fbf4ebceafc](https://github.com/benknoble/frosthaven-manager/commit/acf849311ecc4d5247b71e64e1370fbf4ebceafc) _might_ look right but exhibits some subtle problems (see [https://github.com/benknoble/frosthaven-manager/commit/deae4ac544ef0b7be09a9cd11001e54a4609de21](https://github.com/benknoble/frosthaven-manager/commit/deae4ac544ef0b7be09a9cd11001e54a4609de21)).

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [July 10, 2025, 9:31pm UTC](https://racket.discourse.group/t/get-version-from-info-rkt/3843/5 "2025-07-10T21:31:43Z")

</div>

if i understand (?) the advantage of your solution, and i only use version number to display as info (not critical in code), and as my releases are spaced by months generally, the actual solution should be enough to have version number , not hard coded in text string but retrieved from info.rkt file.  
thank.

---

<div class="post-metadata">

**Author:** ![LiberalArtist](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/liberalartist/32/151_2.png) [@LiberalArtist](https://racket.discourse.group/u/LiberalArtist)\
**Post date:** [July 10, 2025, 9:59pm UTC](https://racket.discourse.group/t/get-version-from-info-rkt/3843/6 "2025-07-10T21:59:45Z")

</div>

The advantage of @benknoble's solution is that, for some ways of building an executable, the `info.rkt` file might not actually be present at runtime. Doing the lookup at compile time makes that work seamlessly.

Another caveat is that, if you have a multi-collection package, the _package_ `info.rkt` file is not part of any collection. (In a single-collection package, the package `info.rkt` file is also a collection `info.rkt` file.) The APIs are there to find such a file, too, it just has to be done differently.

This all reminds me that I've wished for something like PLaneT's [`(this-package-version)`](https://docs.racket-lang.org/planet/Utility_Libraries.html#%28form._%28%28lib._planet%2Fprivate%2Fversion..rkt%29._this-package-version%29%29) for non-PLaneT packages, particularly to use as the [`#:version` argument to `@title{}`](https://docs.racket-lang.org/scribble/base.html#%28def._%28%28lib._scribble%2Fbase..rkt%29._title%29%29). To be useful, it should probably allow providing a package name or a module path to look up, since documentation is often in a different package with an irrelevant version number.

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [July 10, 2025, 10:13pm UTC](https://racket.discourse.group/t/get-version-from-info-rkt/3843/7 "2025-07-10T22:13:19Z")

</div>

thank you for the explanation. I think it could take sense in one of two release of my Scheme+ and SRFI-105 because at some point i will made a lot of the job from Scheme+ to SRFI-105 reader and i will melt the 2 projects (collection/package) in a single one (package with perheaps 2 collections) and the 2 info.rkt will be only one (and only one common version number at this time) but will be in a place in the package at an upper level than the collection place where info.rkt files are now.

note about API doc: i had read the doc before posting but can not figure out how to make the code, some examples like this would be useful for user to understand the APIs
