babashka / bbin

Install any Babashka script or project with one command
MIT License
134 stars 9 forks source link

bbin install <non raw gist link> does not work #56

Open chase-lambert opened 1 year ago

chase-lambert commented 1 year ago

bbin install currently does not seem to work with non-raw gist links. It might be a nice convenience feature to add such capability.

I tried to run bbin with a non-raw gist link: bbin install https://gist.github.com/chase-lambert/c5533d8e8fbb71268a25e83ecf8e3cc6 but got the following error:

----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  Invalid script coordinates.
If you're trying to install from the filesystem, make sure the path actually exists.
Data:     {:script/lib "https://gist.github.com/chase-lambert/c5533d8e8fbb71268a25e83ecf8e3cc6", :procurer :http, :artifact :unknown-artifact}
Location: /home/chase/.babashka/bbin/bin/bbin:629:11

----- Context ------------------------------------------------------------------
625:           [:local :dir] (install-deps-git-or-local cli-opts' summary)
626:           [:local :file] (install-local-script cli-opts')
627:           [:local :jar] (install-local-jar cli-opts')
628:           [:maven :jar] (install-deps-maven cli-opts')
629:           (throw (ex-info "Invalid script coordinates.\nIf you're trying to install from the filesystem, make sure the path actually exists."
               ^--- Invalid script coordinates.
If you're trying to install from the filesystem, make sure the path actually exists.
630:                           {:script/lib (:script/lib cli-opts')
631:                            :procurer procurer
632:                            :artifact artifact})))))))
633:
634: (defn uninstall [cli-opts]

----- Stack trace --------------------------------------------------------------
babashka.bbin.scripts  - /home/chase/.babashka/bbin/bin/bbin:629:11
babashka.bbin.cli/run  - /home/chase/.babashka/bbin/bin/bbin:657:5
babashka.bbin.cli/run  - /home/chase/.babashka/bbin/bin/bbin:654:1
babashka.bbin.cli      - /home/chase/.babashka/bbin/bin/bbin:671:10
babashka.bbin.cli/bbin - /home/chase/.babashka/bbin/bin/bbin:706:5
babashka.bbin.cli/bbin - /home/chase/.babashka/bbin/bin/bbin:703:1
babashka.bbin.cli      - /home/chase/.babashka/bbin/bin/bbin:709:3
clojure.core/apply     - <built-in>
babashka.bbin.cli      - /home/chase/.babashka/bbin/bin/bbin:713:3
babashka.bbin.cli      - /home/chase/.babashka/bbin/bin/bbin:711:1

Everything worked as expected when I used the raw link: https://gist.githubusercontent.com/chase-lambert/c5533d8e8fbb71268a25e83ecf8e3cc6/raw/9cc7b4208f9bed2609f4736c4f469e1828273af5/chatgpt-cli.clj

rads commented 1 year ago

I agree that it would be convenient but the implementation may be tricky. Gists can contain more than one file so there would be some logic needed to handle different cases. This issue is relatively low priority for me to implement myself but PRs are welcome.