jbangdev / jbang

Unleash the power of Java - JBang Lets Students, Educators and Professional Developers create, edit and run self-contained source-only Java programs with unprecedented ease.
https://jbang.dev
MIT License
1.43k stars 159 forks source link

jbang alias to url does not seem to check if url has changed #132

Open maxandersen opened 4 years ago

maxandersen commented 4 years ago

create a gist.

jbang --alias xyz https://gist...

see it run.

jbang xyz

now runs the same.

edit the gist.

jbang xyz

runs the same cached content

jbang https://gist...

actually fethes.

alias should do the same imo

quintesse commented 4 years ago

Weird, alias doesn't do much more than replace what you typed with the URL that was configured. No caching was added or anything.

quintesse commented 4 years ago

Btw, this is related to other discussions we've had, but I IMO we should do as little auto-updating (without user interaction) as possible. My reasoning is that I think Scripts will generally be more volatile than full-fledged projects, people will think and care less about "productization" and maintaining backward compatibility etc. So the risk that a script you installed a month ago has suddenly been changed to work very differently than before is much higher IMO.

I think we should just make it very easy to tell Jbang to ignore any caches. Eg. jbang --nocache xyz would redownload and recompile. (We could also be more explicit and introduce 2 options, eg: --rebuild would ignore the JAR cache, I just don't knwo what to call the option to ignore the URL cache :-) )

In general having this/these option(s) would be good, because jbang cache clear is the proverbial cannon to kill flies.

maxandersen commented 4 years ago

i'm currently on the opposite belief :) since it is about scripts and they do move fast it should be the easiest to get the latest and NOT be caught in bad caches... hence why I would say we auto-update as efficient (use http head 200's to check if changed) as possible and if you don't want changes you use a specific tag or run with --offline.

quintesse commented 4 years ago

Dunno, I think it easier, and safer, to run jbang --nocache xyz and be explicit that you want the latest version. Than using this in some script and be surprised that things suddenly don't work anymore. Then the onus is on all script writers to remember to use --offline... oh no, but then their script won't work on a fresh system ;-)

And yes, tagging could be used, but I honestly don't see that happening much for repos full of little hacked together utility scripts. And if the maintainer of the repo doesn't create tags there's nothing you can do about it. (I had been thinking about commit IDs but that's really not a useful solution). So that would mean that for a script author to be really safe they'd have to forget about using Catalogs.