Eitaro Fukamachi
fukamachi tech notes

fukamachi tech notes

Day 1: Roswell, as a Common Lisp implementation manager

Eitaro Fukamachi's photo
Eitaro Fukamachi

Published on Oct 19, 2021

4 min read

This is my first public article in English. I’ve been sending out newsletters about what I’ve been doing only to sponsors, but there have been requests to publish my know-how on my blog, so I’m writing this way.

However, my English skills are still developing, so I can’t suddenly deliver a lot of information at once. So instead, I’m going to start writing fragments of knowledge in the form of technical notes, little by little. The articles may not be in order. But I suppose each one would help somehow as a tip for your Common Lisp development.

When I thought of what I should start from, “Roswell” seemed appropriate, because most of the topics I want to tell depends on it.

It’s been six years since Roswell was born. Although its usage has been expanding, I still feel that Roswell is underestimated, especially among the English community.

Not because of you. I think a lot of the reason for this is that the author is Japanese, like me, and has neglected to send out information in English.

If you are not familiar with Roswell or have tried it before but didn’t get as much use out of it as you wanted, I hope this article will make you interested.

What’s Roswell

Roswell has the following features:

  • Install Common Lisp implementations of specific versions and switch between them as needed
  • Install libraries from GitHub
  • Common Lisp scripting (aka. Roswell script)
  • Enthusiastic CI support

It would be too much work to explain everything in a single article, so I will explain from the first one today: installation of Common Lisp implementations.

Installation

See the official installation guide.

Installation of Common Lisp implementations

To install implementations with Roswell, use its “install” subcommand.

$ ros help install
Usage:

To install a new Lisp implementaion:
   ros install impl [options]
or a system from the GitHub:
   ros install fukamachi/prove/v2.0.0 [repository… ]
or an asdf system from quicklisp:
   ros install quicklisp-system [system… ]
or a local script:
   ros install ./some/path/to/script.ros [path… ]
or a local system:
   ros install ./some/path/to/system.asd [path… ]

For more details on impl specific options, type:
   ros help install impl

Candidates impls for installation are:
abcl-bin
allegro
ccl-bin
clasp-bin
clasp
clisp
cmu-bin
ecl
mkcl
sbcl-bin
sbcl-head
sbcl
sbcl-source

For instance, SBCL, currently the most popular implementation, can be installed with sbcl-bin or sbcl.

# Install the latest SBCL binary
$ ros install sbcl-bin

# Install the SBCL 2.1.7 binary
$ ros install sbcl-bin/2.1.7

# Build and install the latest SBCL from the source
$ ros install sbcl

Since Roswell author builds and hosts its own SBCL binaries, it can install more versions of binaries than the official binary support. So in most cases, you can just run ros install sbcl-bin/<version> to install a specific version of SBCL.

After installing a new Lisp, it will automatically be in the active one. To switch implementations/versions, ros use command is available.

# Switch to SBCL 2.1.7 binary version
$ ros use sbcl-bin/2.1.7

# Switch to ECL of the latest installed version
$ ros use ecl

To see what implementations/versions are installed, ros list installed is available.

$ ros list installed
Installed implementations:

Installed versions of ecl:
ecl/21.2.1

Installed versions of sbcl-bin:
sbcl-bin/2.1.7
sbcl-bin/2.1.9

Installed versions of sbcl-head:
sbcl-head/21.9.21

To check the active implementation, run ros run -- --version.

# Print the active implementation and its version
$ ros run -- --version
SBCL 2.1.7

Run REPL with Roswell

To start a REPL, execute ros run.

# Start the REPL of the active Lisp
$ ros run

# Start the REPL of a specific implementation/version
$ ros -L sbcl-bin/2.1.7 run

"sbcl" command needed?

For those of you who have been installing SBCL from a package manager, the lack of the sbcl command may be disconcerting. Some people are relying on the "sbcl" command in your editor settings. As a workaround to install the "sbcl" command, such as the following command would help.

# Installation of "sbcl" command at /usr/local/bin/sbcl
$ printf '#!/bin/sh\nexec ros -L sbcl-bin run -- "$@"\n' | \
    sudo tee /usr/local/bin/sbcl \
  && sudo chmod +x /usr/local/bin/sbcl

Though once you get used to it, I'm sure you'll naturally start using ros run.

Conclusion

I introduced the following subcommand/options in this article.

  • Subcommand
    • install <impl>
      • Install a new Lisp implementation
    • use <impl>
      • Switch another installed Lisp implementation
    • run
      • Start a REPL
  • Options
    • -L
      • Specify the Lisp implementation to run a command

(Rough) Troubleshooting

If you have a problem like “Roswell worked fine at first but won’t work after I updated SBCL,” simply delete ~/.roswell .

Roswell writes all related files under the directory, like configurations, Lisp implementations, and Quicklisp libraries, etc. When the directory doesn’t exist, Roswell creates and initializes it implicitly. So it’s okay to delete ~/.roswell.

 
Share this