Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Dependencies in script mode #291

Closed
skynet-gh opened this issue Oct 5, 2017 · 6 comments
Closed

Dependencies in script mode #291

skynet-gh opened this issue Oct 5, 2017 · 6 comments
Labels

Comments

@skynet-gh
Copy link

Using lumo 1.8.0-beta

$ lumo --version
1.8.0-beta

I have a utility script that I've been executing directly with the shebang functionality. However, I want to start using tools.cli to parse script parameters. I tried just adding the :require but of course it doesn't work:

#!/usr/bin/env lumo
(ns my.script
  (:require
    [clojure.tools.cli :refer [parse-opts]]))

(println "hello world")

Now when I try to run the script I get

$ ./script.cljs 
No such namespace: cljs.tools.cli, could not locate cljs/tools/cli.cljs, cljs/tools/cli.cljc, or Closure namespace "cljs.tools.cli"
	 (new)
	 Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:1937:200)
	 Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:2484:92)
	 Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$2 (NO_SOURCE_FILE <embedded>:2483:92)
	 (NO_SOURCE_FILE <embedded>:5239:92)
	 Object.lumo.repl.load_other (NO_SOURCE_FILE <embedded>:6123:380)
	 lumo.repl.load (NO_SOURCE_FILE <embedded>:6127:106)
	 Function.cljs.js.require.cljs$core$IFn$_invoke$arity$5 (NO_SOURCE_FILE <embedded>:5229:528)
	 Function.cljs.js.require.cljs$core$IFn$_invoke$arity$4 (NO_SOURCE_FILE <embedded>:5223:88)
	 (NO_SOURCE_FILE <embedded>:5252:423)

I know I can run the script using

$ lumo -D org.clojure/tools.cli:0.3.5 script.cljs
hello world

Is it possible to get this working in script mode? Like a default package.clj that is read for dependencies?

Thanks!

@anmonteiro
Copy link
Owner

This is a difficult problem with not so good solutions.

My personal favorite way that doesn't suck to work around this is the following:

#!/bin/sh
"exec" "lumo" "-D" "org.clojure/tools.cli:0.3.5" "$0" "$@"

;; Your code here

@anmonteiro
Copy link
Owner

I think @SevereOverfl0w has also had some insight on this in the past

@arichiardi
Copy link
Collaborator

Also, is tools.cli bootstrap compatible?

@anmonteiro
Copy link
Owner

Yes, I've used it before

@anmonteiro
Copy link
Owner

Closing as this is not a bug. Let me know if you have further questions.

@skynet-gh
Copy link
Author

@anmonteiro that shell trick is just what I was looking for, thanks!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants