I'm trying to learn clojurescript.
In my terminal (on Mac) I typed
lein new mies js-practice
cd ~/js-practice
scripts/repl
Then I get this error:
Exception in thread "main" java.io.IOException: Cannot run program "node": error=2, No such file or directory,
I'm confused, because I'm following a tutorial line by line and I don't understand what I did wrong. Am I missing some simple command? Is there something I don't have downloaded?? I'm a total beginner so I really can use any pointers.
Thank you!!
I figured out my problem! I didn't have Node.js installed. I did
brew install node
And now scripts/repl works.
I feel kinda silly but as a beginner these basic things drive me crazy! :)
I will also look into shadow cljs at some point since that seems to be more commonly used. Thanks!
Related
Recently, I started learning Clojure. I have been using Emacs, and cider (REPL). Also, I have NixOS as OS.
I have been able to successfully program in Clojure using this environment. Usually, I create the files, then I go to the directory where the .clj are, I execute cider-jack-in, a REPL is created, and interactive programming magic happens. Thus, I am able to load the file, load new versions of old functions, etc.
It also works if I just start Emacs and execute `cider-jack-in. The mini-buffer asks:
Are you sure you want to run `cider-jack-in' without a Clojure project? (y or n)
After answering y, everything works fine.
While reading the book Clojure for the Brave and True, I have also successfully used:
$ lein run
For learning purposes, I decided to explore some open source projects. Thus, I did a git clone of this open-source project.
Being on the folder, I decided to reproduce the steps that have worked so far. However, it does not work. After executing cider-jack-in, the mini-buffer echoes the following:
The clojure executable isn’t on your ‘exec-path
Also, if I try with lein I get:
[pedro#system:~/projects/http-cron]$ lein run
No :main namespace specified in project.clj.
Obs.: If I type clojure on the shell, this is what I get:
[pedro#system:~]$ clojure
The program 'clojure' is not in your PATH. You can make it available in an
ephemeral shell by typing:
nix-shell -p clojure
Why is this happening?
How can I solve this (considering that I am using NixOS)?
Going the imperative route, depending on whether you use NixOS with channels (default) or flakes, you can permanently install clojure into your environment with:
channels: nix-env -f '<nixpkgs>' -iA clojure
flakes: nix profile install nixpkgs#clojure
The preferred (declarative) way would however be adding clojure to environment.systemPackages in /etc/nixos/configuration.nix and running sudo nixos-rebuild switch.
I have a problem and hope someone can help me. I am currently trying to write a script for Termux or Termux:Task. My script currently looks like this:
#!/data/data/com.termux/files/usr/bin/bash
cd /./sdcard/www/public/
wp post list sleep 5
Every time I load the script I get the following error message:
/data/data/com.termux/files/usr/bin/wp: /usr/bin/env: bad interpreter: No such file or directory.
I've been looking for a solution to my problem for hours, unfortunately without success.
I am using an extension for Termux called "WordPress CLI". When I start termux and enter the commands individually, everything works. But as soon as I write the commands into a sh script and start it doesn't work anymore. :(
Can anyone help me?
Thanks a lot
This is simple error you can fix it by replacing !/data/data/com.termux/files/usr/bin/bash. With #!/data/data/com.termux/files/usr/bin/bash
Please tell if you get error again
Try with #!/usr/bin/env bash in the shebang line.
Termux-exec allows you to execute scripts with shebangs for traditional Unix file structures. So shebangs like #!/bin/sh and #!/usr/bin/env python should be able to run without termux-fix-shebang.
From https://wiki.termux.com/wiki/Termux-exec
According to doc:
Why do I keep getting a '/bin/sh bad interpreter' error?
This error is thrown due to access script interpreter at nonexistent
location.
Termux does not have common directories like /bin, /sbin, /usr/bin at
their standard place. There is an exception for certain devices where
/bin is a symbolic link to /system/bin, but that does not make a
difference.
Interpreters should be accessed at this directory only:
/data/data/com.termux/files/usr/bin
There are three ways to fix this:
Install termux-exec by using pkg install termux-exec. It won’t affect the current session, but after a restart should work without
any setup. Not needed if your Termux is up to date. If still not
working, try the next workaround.
Use command termux-fix-shebang to fix the shebang line of specified file.
Use termux-chroot from package proot to setup a chroot environment mimicking a normal Linux file system in Termux.
termux-fix-shebang my_script.py of second method work for me, which it modify the shebang(first line of my_script.py) from #!/usr/bin/env python to #!/data/data/com.termux/files/usr/bin/env python. Since /usr/bin/ is not exist in Android, that's why it throws the error /usr/bin/env: bad interpreter: No such file or directory. The other solution is run with python my_script.py, neither of my_script.py nor ./my_script.py.
In my test, termux-exec of the first method only work if I added correct shebang in main script(child OR child of child script no need) and ran command export LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so.
And for the issue of this question, error shows /usr/bin/env in the middle with /data/data/com.termux/files/usr/bin/wp even though the shebang of script #!/data/data/com.termux/files/usr/bin/bash looks ok, it means that wp command (located at /data/data/com.termux/files/usr/bin/wp) used inside the script contains shebang #!/usr/bin/env wp and should modify it to #!/data/data/com.termux/files/usr/bin/env wp too. termux-exec of first method should fix this specific case too(already has correct shebang in main script).
I downloaded Clojure 1.2 https://github.com/downloads/clojure/clojure/clojure-1.2.0.zip , extracted it under /Library directory, created CLOJURE_HOME, added $CLOJURE_HOME/script to my $PATH.
When I'm trying to run clj or repl scripts that are located under script directory, I'm getting this error:
Exception in thread "main" java.lang.NoClassDefFoundError: jline/
ConsoleRunner
Caused by: java.lang.ClassNotFoundException: jline.ConsoleRunner
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)
Ok, jline.jar isn't in the CLASSPATH so I checked clj and repl scripts:
CLASSPATH=src/clj:test:test-classes:classes/:script/jline-0.9.94.jar:../clojure-contrib/target/clojure-contrib-1.2.0-SNAPSHOT.jar
if [ -z "$1" ]; then
exec java -server jline.ConsoleRunner clojure.main
else
SCRIPT=$(dirname $1)
export CLASSPATH=$SCRIPT/*:$SCRIPT:$CLASSPATH
exec java -Xmx3G -server clojure.main "$1" "$#"
fi
I downloaded jline.jar under $CLOJURE_HOME/script but I'm still getting the same error.
This lead me to the question:
What is the role of https://github.com/downloads/clojure/clojure/clojure-1.2.0.zip anyway?
Is it supposed to be used to install Clojure? or just to to build and get clojure.jar?
I noticed no one is talking about installing Clojure this way.
Am I missing something?
Clojure, being a JVM language, has to deal with the JVM classpath. This makes 'installing' it a bit unwieldy and confusing. Rather than install it yourself like this, try out some tools like cljr and cake. I wrote a blog post about this that might be helpful: http://blog.raynes.me/?p=48
In summary: Check out cljr, cake, and leiningen.
The majority of people in the Clojure community don't have Clojure 'installed'. Most people use a build tool and/or cljr. It doesn't make a lot of sense to install Clojure to a central place when, inevitably, you're going to need dependency management, and jars will be copied around everywhere anyway. In any case, it's much easier to let a tool handle the classpath for you.
the clojure.zip file exists so people who write tools will have a place for their tools to get the parts they need ;)
For people not writing tools they are either working on/with the latest branch from github and so they get Clojure with a git pull or they are using the above mentioned liningen, cake, cljr , counterclockwise(eclipse), la clojure (intellij), or netbeans.
I installed and run lein, but it seems to slow on My Mac (10.6.4).
Running 'time lein help' gives me
real 11m8.674s
user 0m54.297s
sys 1m32.621s
I tried once more.
real 15m25.560s
user 1m36.087s
sys 2m52.745s
What's wrong with this? Is anyone experiencing similar problem? Is there anyway to check what's the problem?
Added
When I install, I used 'sudo lein deps', as I got some errors using 'lein deps'. I guess it caused some problem accessing files. When I run 'sudo lein SOMETHING', it works as usual.
One thing to note is that it will put the src directory on the classpath. If you run it from $HOME and have a 54GB ~/src directory like I do, the JVM will slow to a crawl just trying to find the basic things.
It's because of how it looks for hooks. It's explained here: http://groups.google.com/group/clojure/browse_thread/thread/e04ab3f6e17f85c4.
You could give cake a try. It worked out of the box for my simple project.clj without any changes, and is blazing fast because of the persistent JVM it uses.
Found solution
sudo lein uses different CLASSPATH than that with just lein. I guess my CLASSPATH that contains clojure or clojure-contrib conflicted with the lein.
When I added this code at line 126 of lein, the problem is gone.
CLASSPATH="/Users/smcho/.m2/repository/leiningen/leiningen/1.2.0/leiningen-1.2.0-standalone.jar:lib/dev/swank-clojure-1.2.1.jar::src/:"
For uninstalling/installing, I asked and got an answer here.
For all those who don't know what I am talking about, it's glTail from Fudgie.
On my Mac at home, I have never been able to get glTail to work. I have gotten it to work on my work Mac. This is just a last resort, as the past 2 days have been nothing but seems like wasted time.
I have the same libraries installed: Ruby 1.8.6, Gem 1.3.1, net-ssh 1.1.4, Chipmunk 2D, ruby-opengl 0.60.0 and file-tail 1.0.3.
Here is the command that I run to try to start it up:
./gl_tail configfile config.yaml
It says right off the bat (almost instantaneously):
-macbook:bin Garrett$ ./gl_tail configfile config.yaml
./../lib/gl_tail/engine.rb:300: [BUG] Bus Error
ruby 1.8.6 (2008-03-03) [universal-darwin9.0]
Abort trap
If you look at engine.rb, it's the first line:
def start
glutInit() # Line 300
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE)
glutInitWindowPosition(0, 0)
glutInitWindowSize(#config.screen.window_width, #config.screen.window_height)
glutCreateWindow('glTail')
I have a feeling it's something along the lines of GLUT not being installed properly. I am not expecting too much help, as the code it self has very little documentation as it is. But seeing as it's being killed right away I have a feel maybe it's something that isn't updated all the way, most likely OpenGL.
I'm not sure if this is at all helpful to you coming from a linux user, but here goes...
I think you are missing the libglut-headers, indeed. If you are installing through gems, that's the only external thing you would need. On linux, I only have to install the libglut3-dev package, then gem install gltail it can build ruby-opengl with that.
So, try to find the libglut development headers on your platform. Hope that helps!