Is there a way to get raco to install and setup the dependencies of a package but not the package itself? For development purposes I don’t want to setup my package, I want to just link it. However, if I do raco pkg install --auto --link --no-setup --name s10
, then I get the dependencies but they have not been setup which means for example that rosette
does not install z3
. On the other hand, I can install and setup everything including my pkg and then remove the zos for my package but that’s a sad workaround and I would prefer to have a better solution.
@willghatch a question on rash, I have skimmed the documentation but haven’t found a reference to this, can I write a rash file with bash like command lines and require this into a racket file to execute it when I want? Maybe the rash lang automatically provides a function that executes the commands in the file?
@pocmatos I don’t know an elegant way, but just spitballing: How about making a dummy project that’s just an info.rkt
with the deps
and build-deps
values from the real project? (Might even work to symlink the real info.rkt
, so no copypasta.)
@pocmatos can you just run raco setup rosette
after that command?
@samth I have this same problem, and I suspect it’s for the same use case: docker layer caching. If you setup dependency code and your packages code in the same command, you have to rebuild your dependencies whenever your package’s source changes
I think a new flag to install
would be reasonable to add
I’ve also wondered about a raco build
command that worked on the local directory without it being installed (and installed needed deps)
like, where it figured out what packages to install based on what modules are used in the local directory?
no, based on an info.rkt file
but didn’t require installing the directory as a package
which seems to be something people avoid for reasons I don’t always understand
ah yes, that would be helpful
@notjack I only have one Racket Dockerfile
worth of experience, and haven’t tweaked this in many months. But: I have something like this Dockerfile
snippet: WORKDIR /app/
# First just copy over Makefile and info.rkt, and run make install.
# This way we get a docker layer with our Racket dependencies cached,
# that remains valid until/unless Makefile or info.rkt is changed.
COPY Makefile info.rkt /app/
RUN make install
# Finally this layer adds our actual application files. So long as
# info.rkt hasn't changed, this can reuse the previous layer.
COPY . /app/
RUN make setup
and this Makefile
snippet: DEPS-FLAGS=--check-pkg-deps --unused-pkg-deps
# Installs dependencies as well as linking this as a package.
install:
raco pkg install --deps search-auto
# Primarily for day-to-day dev.
# Note: Also checks deps.
# Note: Does NOT build docs.
setup:
raco setup --no-docs --tidy $(DEPS-FLAGS) --pkgs $(PACKAGE-NAME)
And the deps layer doesn’t get rebuilt unless I change Makefile
or info.rkt
.
(This is for https://deals.extramaze.com and the repo is private, is why I’m just sharing snippets)
(I guess you could also just inline those Makefile
commands into the Dockerfile
, but I have a Makefile
usually for a variety of things anyway.)
Take this with a big grain of salt. When it comes to Docker I’m just at a “it works” stage.
@greg that’s about what I end up doing too, and it seems to work okay so far
Thanks for the replies.
I have about 9 packages my application/package depends on therefore doing something like @samth suggested doesn’t work very well. I would need to end up reading the info.rkt
file and issuing raco pkg install
for each of them.
I need this because my package has a few compile time configuration options passed through environment variables. I cannot raco install --auto --link ...
my package without passing the compile time options, however it’s too soon to do it when I am doing CI. I would like to delay the setup of my application and just install the dependencies.
Maybe we need an alternative to --link
like --deps-only
.
With this I could install the deps. Then I could do raco pkg install --no-setup --link ...
on my package and later I could issue the compilation script with the options. This would also allow me to cache my project dependencies during CI between pipeline runs.
ok… let me take a look at the raco pkg install
code, maybe it’s not even that hard to implement. :slightly_smiling_face:
@pocmatos What about setting PLTADDONDIR to a directory which becomes the new location for user scope packages. raco pkg install
will install your packages and all of its dependencies into the addon directory. Then you can delete your package from that directory. You can either then leave it as-is or unset PLTADDONDIR and rerun raco pkg install
again over each package directory already in the formerly addon directory to ensure they are installed into the standard user scope location.
@pocmatos the pkg/lib
module provides a racket API to all of raco pkg
- you might have better luck writing a racket script to install things just right
When creating a Maybe
type, how do I pull the value out of the Some
struct? (struct None ())
(struct (a) Some ([v : a]))
(define-type (Maybe a) (U None (Some a)))
With a function like the following: (: div (-> Integer Integer (Maybe Exact-Rational)))
(define (div x y)
(if (equal? 0 y)
(None)
(Some (/ x y))))
I get the following result, but I cant crack it open. If it were (Some 12345)
, I could do (Some-v (Some 12345))
to get 12345
. What can I do to get to the value? I also tried (Some-v (cast (div 3 4) (Some Exact-Rational))
but no luck: (div 3 4)
- : (U (Some Exact-Rational) None)
#<Some>
@david.alkire try using Some? or pattern matching
@abmclin that solution looks like it could work but way too complex, racket should really offer something easier but as a workaround it seems doable. thanks.
@notjack didn’t know about pkg/lib
, will take a look, thnaks.
@samth i should point out that I totally agree on a raco build
that builds your application and compiles dependencies without forcing you to install
your package.