One thing that's awesome about Go is that you can use the go tool to import libs directly from say github. Jocker is awesome and I really want to be able to use it for all of my scripting needs (especially ops / orchestration), so I'm wondering if there's something convenient like the go imports for clojure. The thing that's blocking us is having dependency / package management... so I was thinking if there would be a suitable "require" that would download a file if (cacheing if necessary) and then using that file so that the script can leverage packages that are provided externally but still remain standalone. Has anyone gone down this path?
@charlesg3 With add-lib
(in a branch of tools.deps.alpha
) you can add Git deps dynamically at run time...
Here's an example that lets you add the master
of any Git project to your classpath https://github.com/seancorfield/dot-clojure/blob/master/deps.edn#L103-L116
How do I get access to tools.deps.alpha
in joker?
@charlesg3 so you want a dependency system for joker scripts?
Basically yeah, but since it's for scripts I'm just trying to think through what's the most lightweight way of resolving external dependencies (which may reside on the web)
you can fetch those using joker’s http client?
since joker has eval, it should be possible to fetch an external script and execute it
Yep... I can build it all up using the existing utilities
I was just curious if anyone had gone down the path of something more managed
Furthermore, if I start writing the code to do it using existing utilities I have a chicken-and-egg problem. Of course I can simply download the dependency manager first and then use it to get any other dependencies, but if it were included somehow I would avoid that
you can probably re-use clojars for this? and fetch the deps using tools.deps or something?
I guess I could, but I'm not looking to download jars...I'm looking to require joker files
That seems a little heavyweight TBH
you can also use git deps with tools.deps, that way you can avoid clojars
and git deps can probably declare deps on other git deps
Right, but how do I get tools.deps
in joker?
why would you need to run the resolving/downloading of deps inside joker?
Because I'm just using joker as a scripting language for ops management. Perhaps on a separate machine, simply to avoid jvm memory / startup reqs
once tools.deps has downloaded the deps needed, it caches the necessary stuff, so it’s very fast the next time
(hence why I'm asking in this channel... I can certainly manage deps using regular clojure np)
or maybe you can rip out a part of tools.deps and re-implement that in joker. something I certainly wouldn’t do because I see it as wasted time 🙂
Ah, I misunderstood what you were trying to do. All of what I'm suggesting assumes the JVM, sorry. I can't imagine living in a world where I don't have the JVM on every system 🙂
but I guess you can piggie back on some other dependency system that also supports git deps. npm maybe?
No worries... I can figure something out. It seems pretty easy to simply implement a fetch if I don't have this dep functionality (e.g. caching) in some lib that I download. I was just curious if anyone had done such a thing with joker alone so I could leverage that or gain some insights.
The main trade-off is that I have to bootstrap such a system, so having that support embedded into joker would avoid that bootstrapping step. So I wanted to check to make sure that I wasn't missing something that even easier than what I'm thinking of
I've been thinking about deps management for Joker, but it's a hard problem and I have not had the bandwidth lately to take this on. I want deps to be specified in the code itself, rather than in a separate file processed by a separate tool. Something like (require '<namespace> :from <url>)
, but obviously there is a lot to think about here.
Yeah -- I agree something like this is a nice direction to go and the go tool does a pretty good job of this.