Hi. It's not a solution for a problem. But when you use Cygwin it's quite easy to adapt linux version of scripts.
install_dir=`realpath.exe --relative-to=. /usr/local/lib/clojure`
after installation find a line in /usr/local/bin/clojure
which defines install_dir
and change to the above one.
oops, also line where config-path is set
config_dir="`realpath --relative-to=. $HOME`/.clojure"
maybe it's good to set them conditionally based on OSTYPE env variable?
I don’t think that’s enough to make everything work
The only issue is to have relative paths in the script to ensure that Java and Cygwin/bash see the same. I found only two places which are $HOME
and install_dir
. Of course you may be right since I didn't test every case.
there are also paths inside deps.edn and paths to the various deps.edn
and ultimately we're making a classpath which is made of paths
I've looked at this and others have as well and my memory is that it fell apart, but I don't remember where exactly
I'm working through the guide from the clojure site and I'll let you know if something is wrong
if classpaths are created only by a make-classpath
it should be ok, since bash script doesn't rely on it.
they are. tools.deps.alpha uses Java platform file and path separators so not sure if that's good or bad for cygwin
from what I see, bash script does not manipulate with files from classpath so it doesn't matter (separators etc.). The only point is when bash produces path for java it should be relative one. And when java produces any path for bash file operations it should be translated to cygwin one.
anyway, I checked almost all examples from the guide
the last one doesn't work, I'm getting following error
ubuntu@ml1:~$ vim deps.edn
ubuntu@ml1:~$ vim src/my_class.clj
ubuntu@ml1:~$ vim src/hello.clj
ubuntu@ml1:~$ clj -e "(compile 'hello)"
hello
ubuntu@ml1:~$ clj -m hello
Exception in thread "main" clojure.lang.ArityException: Wrong number of args (1) passed to: my-class/-hello
at clojure.lang.AFn.throwArity(AFn.java:429)
at clojure.lang.AFn.invoke(AFn.java:32)
at my_class.MyClass.hello(Unknown Source)
at hello$_main.invokeStatic(hello.clj:7)
at hello$_main.doInvoke(hello.clj:5)
the same under cygwin and under linux (ubuntu)
my deps.edn
consists of single line {:paths ["src" "classes"]}
so it's not cygwin related problem
if you add -Spath it will dump the classpath it's using
src:classes:/home/ubuntu/.m2/repository/org/clojure/clojure/1.10.0/clojure-1.10.0.jar:/home/ubuntu/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar:/home/ubuntu/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar
classes are there (in both: ubuntu and cygwin)
the error implies that the hello class is being called with something after it as args, when it expects no args
content is copied from the guide
ubuntu@ml1:~/cljt/src$ cat hello.clj
(ns hello
(:require [my-class])
(:import (my_class MyClass)))
(defn -main [& args]
(let [inst (MyClass.)]
(println (.hello inst))))
ubuntu@ml1:~/cljt/src$ cat my_class.clj
(ns my-class)
(gen-class
:name my_class.MyClass
:methods [[hello [] String]])
(defn -hello []
"Hello, World!")
the code looks ok
it should basically be running java -cp src:classes:/home/ubuntu/.m2/repository/org/clojure/clojure/1.10.0/clojure-1.10.0.jar:/home/ubuntu/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar:/home/ubuntu/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar clojure.main -m hello
the same exception
this seems like some mismatch in this code (which I'm not seeing), not a path error
I get the same
maybe something is wrong with class generation
yeah, I think there is some bug in the genclass
compilation produces bunch of internal classes for MyClass
I don't know compilation process though
anyway, regardless this case, after aformentioned modifications cygwin version works with all provided examples
yeah, should be
(defn -hello [this]
"Hello, World!")
while I don't think we want cygwin to be "the" way to do things, would be happy to make it work for people that want to go that path
would be happy to consider os-targeting changes to install script
patch welcome...
ah this
, ok, now works 🙂
cygwin is always kind of workaround
fixed the example on the site, will redeploy later
great
for patch, I assume I have to be contributor, right?
yes
if you're not up for that, even filing a jira ticket so someone else can do so would be great (don't need to be a contributor to file tickets)
I think I can do this.
cool
@alexmiller where can I find clj/clojure scripts?
I mean which github repo?
thanks