Welcome! Please see the About page for a little more info on how this works.

0 votes
in REPL by
recategorized by

I installed clojure following instructions from
https://clojure.org/guides/getting_started#_installation_on_linux

However, when i launch the repl staying in ~, I get following

Exception in thread "main" java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.main/main

    at clojure.lang.Var$Unbound.throwArity(Var.java:45)
    at clojure.lang.AFn.invoke(AFn.java:28)
    at clojure.lang.AFn.applyToHelper(AFn.java:152)
    at clojure.lang.AFn.applyTo(AFn.java:144)
    at clojure.lang.Var.applyTo(Var.java:705)
    at clojure.main.main(main.java:40)

And if i change the directory to any other location, it runs ok

:~/src$ clj
Clojure 1.10.3
user=>

My OS is a Debian Buster (Minimal)... I tried looking up, but to no avail...

Not sure if the following is of any help...

:~$ mvn --version
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 11.0.11, vendor: Debian, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "4.19.0-17-amd64", arch: "amd64", family: "unix"

:~$ java --version
openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-post-Debian-1deb10u1)
OpenJDK 64-Bit Server VM (build 11.0.11+9-post-Debian-1deb10u1, mixed mode, sharing)

4 Answers

+1 vote
by
selected by
 
Best answer

Do you have a src folder in ~? If so, what it is in it? (I'm wondering if you have src/user.clj and something in that script is causing the crash)

by
:~$ ls -al src/
total 48
drwxr-xr-x 12 nalin nalin 4096 Jul 11 16:15 .
drwxr-xr-x 29 nalin nalin 4096 Jul 15 11:32 ..
drwxr-xr-x  2 nalin nalin 4096 Jul 14 17:23 clojure
drwxr-xr-x  3 nalin nalin 4096 Jun 27 20:44 elm
drwxr-xr-x  2 nalin nalin 4096 Jul 11 21:36 erlang
drwxr-xr-x  2 nalin nalin 4096 Jun 30 14:51 haskell
drwxr-xr-x 12 nalin nalin 4096 Jul  9 23:03 klipse
drwxr-xr-x  4 nalin nalin 4096 Feb 14 22:19 lfe
drwxr-xr-x  2 nalin nalin 4096 Mar 25 14:43 lisp
drwxr-xr-x  5 nalin nalin 4096 Jul  3 17:42 mongodb
drwxr-xr-x  2 nalin nalin 4096 Jul 10 20:58 ocaml
drwxr-xr-x  3 nalin nalin 4096 Jul 13 20:53 sml
by
:~$ ls -al /usr/local/lib/clojure/
total 20
drwxr-xr-x  3 root root 4096 Jul 13 18:09 .
drwxr-xr-x 15 root root 4096 Jul  9 22:45 ..
-rw-r--r--  1 root root  458 Jul 13 18:09 deps.edn
-rw-r--r--  1 root root 1489 Jul 13 18:09 example-deps.edn
drwxr-xr-x  2 root root 4096 Jul 13 18:09 libexec
by
:~$ ls -al /usr/local/lib/clojure/libexec/
total 14596
drwxr-xr-x 2 root root     4096 Jul 13 18:09 .
drwxr-xr-x 3 root root     4096 Jul 13 18:09 ..
-rw-r--r-- 1 root root 14932202 Jul 13 18:09 clojure-tools-1.10.3.855.jar
-rw-r--r-- 1 root root     2955 Jul 13 18:09 exec.jar
by
This one may help understand... i hope.... And if you do, help me also understand...

:~$ su
Password:
root@ranjan-t410:/home/nalin# cd ~
root@ranjan-t410:~# clj
Clojure 1.10.3
user=>
root@ranjan-t410:~# cd /home/nalin/
root@ranjan-t410:/home/nalin# clj
root@ranjan-t410:/home/nalin#
by
What's in src/clojure? That's what is causing you problems.

By default, clj/clojure will look in src for namespaces, and since you have src/clojure, that will correspond to a namespace that begins with clojure.something.

Rename that src folder to source, and I bet your problem with go away (you may need to use clj -Sforce to get a REPL, to force the classpath cache etc to be recomputed).
by
edited by
I keep my practices under ~/src.. so mostly ~/src/clojure will have my clojure related practice programs..

And you are right... I renamed "src" to "source" and indeed a REPL is on...

:~$ clj
Clojure 1.10.3
user=>

Kudos....

Just a little curiosity though, can this happen in any directory which has a "src" folder in it and I try to launch clj in that directory?? I have asked the same question on stackoverflow, and would like to link your reply as answer there...
by
Well, it can happen wherever you have a src folder and there's a path to a Clojure source file in it that corresponds to a namespace that you are trying to run.

For example, if you had src/elm/test.clj then if you started a REPL and did (require '[elm.test]) Clojure would try to load that file.

If you had src/haskell/project/Stuff.hs and you started a REPL and tried (require '[haskell.project.foo]) Clojure would look for a file called foo.clj (or foo.cljc) in src/haskell/project/

This is because Clojure projects normally have a src folder (and, often, a test folder -- but you generally add that to your path via an alias, e.g., clj -A:test and the :test alias will have :extra-paths ["test"] -- and now Clojure will look in both the src AND test folders.
0 votes
by

Hello,

  • Can you provide the output of which clj in both ~ directory and ~/src directory ?

  • Can you provide the output of env ?

by
:~$ which clj
/usr/local/bin/clj

:~/src$ which clj
/usr/local/bin/clj


******* output of env in ~ **********************
SHELL=/bin/bash
WINDOWID=6291469
XTERM_VERSION=XTerm(344)
LANGUAGE=en_IN:en
XTERM_SHELL=/bin/bash
XDG_SEAT=seat0
PWD=/home/nalin
LOGNAME=nalin
XDG_SESSION_TYPE=tty
XAUTHORITY=/home/nalin/.Xauthority
WINDOWPATH=1
HOME=/home/nalin
LANG=en_IN
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
INVOCATION_ID=7de1bed7edfb43d2989c032722a9aab6
XTERM_LOCALE=en_IN
XDG_SESSION_CLASS=user
TERM=xterm
USER=nalin
DISPLAY=:0.0
SHLVL=2
XDG_VTNR=1
XDG_SESSION_ID=1
XDG_RUNTIME_DIR=/run/user/1000
JOURNAL_STREAM=9:21181
HUSHLOGIN=FALSE
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
MAIL=/var/mail/nalin
_=/usr/bin/env
OLDPWD=/home/nalin/src

***********************************************

***********************************output of env in ~/src **************************
SHELL=/bin/bash
WINDOWID=6291469
XTERM_VERSION=XTerm(344)
LANGUAGE=en_IN:en
XTERM_SHELL=/bin/bash
XDG_SEAT=seat0
PWD=/home/nalin/src
LOGNAME=nalin
XDG_SESSION_TYPE=tty
XAUTHORITY=/home/nalin/.Xauthority
WINDOWPATH=1
HOME=/home/nalin
LANG=en_IN
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
INVOCATION_ID=7de1bed7edfb43d2989c032722a9aab6
XTERM_LOCALE=en_IN
XDG_SESSION_CLASS=user
TERM=xterm
USER=nalin
DISPLAY=:0.0
SHLVL=2
XDG_VTNR=1
XDG_SESSION_ID=1
XDG_RUNTIME_DIR=/run/user/1000
JOURNAL_STREAM=9:21181
HUSHLOGIN=FALSE
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
MAIL=/var/mail/nalin
_=/usr/bin/env
OLDPWD=/home/nalin
0 votes
by

Can you create new directories in ~? (in particular, ~/.cpcache) We have a known issue that not being able to do that can cause problems, not sure if that's the case here. https://clojure.atlassian.net/browse/TDEPS-119

by
try it without the exec
by
silent exit...
by
exec replaces the current process (your terminal shell) with the launched java process, so you don't want to do that from the command line. But, you do get a repl there.

I can't explain what you're seeing. Might be something to do with bash itself or permissions in the home directory, but I'm not sure what it is or how to debug more.
by
It's not that the repl is not usable on my machine.. Any directory other than ~ is fine. Even able to run things in Emacs... so it is not a blocker for me...

I thought to share to let you guys know... In case you feel like more steps need to be executed, do let me know and i can share the results of execution if that helps... it just felt awkward...

Any other shell do you want me to try, apart from bash ?? By the way I tried "sh -x clojure", but it gave me this...
:~$ sh -x clojure
sh: 0: Can't open clojure
by
And I think it's not shell... But that's just a hunch...
0 votes
by

I'd also be interested in knowing the output of clj -Spath in ~. Clearly, Clojure itself is not getting put on the classpath. If you have a ~/.clojure/deps.edn, you could also try moving that aside.

by
:~$ clj -Spath
src:/home/nalin/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar:/home/nalin/.m2/repository/org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.jar:/home/nalin/.m2/repository/org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.jar

should i try deleting ~/.clojure/deps.edn ??
by
Not sure if the following is of any help...

:~$ mvn --version
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 11.0.11, vendor: Debian, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "4.19.0-17-amd64", arch: "amd64", family: "unix"


:~$ java --version
openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-post-Debian-1deb10u1)
OpenJDK 64-Bit Server VM (build 11.0.11+9-post-Debian-1deb10u1, mixed mode, sharing)
...