Community Packages

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#21091 - [clojure] cannot start shell using sudo (sudo clj)

Attached to Project: Community Packages
Opened by Sergey (Prikrutil) - Tuesday, 05 October 2010, 18:02 GMT
Last edited by Thomas Dziedzic (tomd123) - Thursday, 07 October 2010, 22:26 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Thomas Dziedzic (tomd123)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:

When I'm trying to start clojure shell using "sudo" I see the following error in console:

[sergey@myhost setup]$ sudo clj
Exception in thread "main" java.lang.NoClassDefFoundError: clojure/main
Caused by: java.lang.ClassNotFoundException: clojure.main
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: clojure.main. Program will exit.

"sudo scala" works fine.

Also it isn't possible to run clojure script with root privileges by issuing "sudo script.clj" for the same reason.

Additional info:

* package version(s)

clojure 1.2.0-2
jdk 6u21-1
This task depends upon

Closed by  Thomas Dziedzic (tomd123)
Thursday, 07 October 2010, 22:26 GMT
Reason for closing:  Fixed
Additional comments about closing:  fixed in -3
Comment by Sergey (Prikrutil) - Tuesday, 05 October 2010, 18:16 GMT
"sudo java -cp /usr/share/clojure/clojure.jar clojure.main" works fine, so problem is likely to be in /usr/bin/clj
Comment by Thomas Dziedzic (tomd123) - Wednesday, 06 October 2010, 15:39 GMT
The problem here is that sudo starts with a clean environment and doesn't define CLOJURE_HOME which is in /etc/profile.d/clojure.sh
I'm not exactly sure how to attack this because it does work under su, since it sources the clojure.sh file.
Comment by Sergey (Prikrutil) - Wednesday, 06 October 2010, 20:25 GMT
Putting

CLOJURE_HOME=/usr/share/clojure

at the beginning of the /usr/bin/clj fixes the problem. Do we really need to have CLOJURE_HOME defined in /etc/profile.d/clojure.sh? It may be used by some PKGBUILDs

Also there is a ticket "Multiplatform command-line clojure launcher" in Clojure's bug-tracker: http://www.assembla.com/spaces/clojure/tickets/366-multiplatform-command-line-clojure-launcher
Comment by Sergey (Prikrutil) - Wednesday, 06 October 2010, 20:42 GMT
If having $CLOJURE_HOME defined is common among clojurians [1], we can redefine $CLOJURE_HOME inside clj when started using sudo:

#####################################
#!/bin/sh

# If $CLOJURE_HOME isn't defined take it from clojure.sh

if [ ! "$CLOJURE_HOME" ]; then
. /etc/profile.d/clojure.sh
fi
#####################################

[1] "Let's respect CLOJURE_HOME"
http://groups.google.com/group/clojure/browse_thread/thread/b0745c73579bac6c/38a4b76320805b32?lnk=gst&q=clojure_home#38a4b76320805b32

Loading...