This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-19
Channels
- # alda (1)
- # announcements (2)
- # babashka (14)
- # beginners (30)
- # biff (12)
- # clerk (2)
- # clj-kondo (18)
- # clj-on-windows (1)
- # clojure (98)
- # clojure-europe (9)
- # clojure-gamedev (4)
- # clojurescript (39)
- # conjure (1)
- # data-science (1)
- # emacs (25)
- # events (1)
- # fulcro (1)
- # hyperfiddle (13)
- # lsp (3)
- # malli (1)
- # membrane (10)
- # off-topic (12)
- # reagent (7)
- # scittle (21)
- # shadow-cljs (10)
Hi team,
I'm new to clojure and started learning it via practicing syntax and problems online.
I'm trying to setup clojure in my project in windows system, I've set path variable of lein.bat file in environment variable but it seems not working,
I have to add lein.bat file in every project folder to get run it.
Error:
LSP classpath lookup failed when running lein with-profile +test,+dev classpath
. Some features may not work properly if ignored. Error: Cannot run program "lein" (in directory "C:\Users\DEEPAK KUMAR\tutorial"): CreateProcess error=2, The system cannot find the file specified Choose an option:
Please, If anyone knows what I am missing let me know.
You should use https://scoop.sh/ to install clojure (https://github.com/littleli/scoop-clojure) as well as https://scoop.sh/#/apps?q=lein&s=0&d=1&o=true (also, can install jdk if haven't via scoop scoop install temurin-lts-jdk
), as it sets environment variables on it own, works like apt in unix.
Then, it will work, without any issues.
Another option is to use the (fairly new) MSI installer: https://github.com/casselc/clj-msi/releases/tag/1.11.1.1252 -- this will give you the Clojure CLI, without needing to install a package manager like Scoop.
Big fan here Sir @U04V70XH6 of your blog (https://corfield.org/). I just wanna say the https://github.com/casselc/clj-msi#clojure-installer installs the same https://github.com/borkdude/deps.clj, so choose either way @U04UD707R62 it will work, package manager version is more recent updated 1.11.1.1257 and updates are easy and automated via cli, whereas in msi you gotta do the manual work to download and install.
@U04V70XH6 It worked sir, thanks a lot.
into Environment variable right? if it is this, I've added.
I've added it in c drive inside a lein folder, folder name : lein contains lein.bat file.
Do you have C:\lein
in your PATH
variable? That's where it needs to be added. You don't need a variable called lein
.
in c drive I have made a new folder named lein, inside that I have inserted lein.bat file, sir.
Anyone who is learning and building in clojure in windows operating system. I need some help in setting it up the environment for clojure.
✋ I replied in your first message, uninstall all your clojure setup and follow those steps, it will work.
Thank you buddy, will update after doing the stuffs.
I’d like to use the LangChain TypeScript library in ClojureScript, and get useful typehints. Has anyone written or created a guide to interop? I know about JavaScript interop, but I’d like to still use the types.
How do I get current year and month?
(.getYear (new java.util.Date))
; => 123
Year 123
? Have we gone to the past? Besides the method seems to be deprecated https://docs.oracle.com/javase/8/docs/api/java/util/Date.html
I don't speak Java and the Java documentation is appalling. Can someone please point me in the right direction?
(Obviously I'd prefer Clojure, but I don't believe there's anything that'd be built-in, correct me if I'm wrong.)To explain that result see this in your link: > A year y is represented by the integer y - 1900.
Build in? no, but take a look at: https://github.com/juxt/tick or https://github.com/dm3/clojure.java-time
That's horrifying that you need to read doc for something like "get me current year". It should just give the current year as int, what else? Glad I never did Java 🙈
tick and java-time are nice Clojure wrappers if you work a lot with time (or plan to target multiple runtimes) but you don't need a middle-man for simple stuff like this imho. Just interop with java.time.
(.getValue (Year/now))
works, but I can't figure out how to get month from it.
I found there's also java.time.Month
, but it has no now
.
What are you trying to achieve? Perhaps there's a better way
(defn current-month []
#?(:clj
(let [date (new java.util.Date)]
(make-date (.getValue (java.time.Year/now)) (+ (.getMonth date) 1)))
:cljs
(let [date (new js/Date)]
(make-date (.getFullYear date) (+ (.getMonth date) 1)))))
Essentially make-date
just returns {:year y :month m}
and I use that map (and a few fn to manage it to work with dates, since I have no need for days, TZs etc.
Besides it makes it platform-independent.
(import [java.time LocalDate])
(defn current-month []
#?(:clj
(let [date (LocalDate/now)]
(make-date (.getYear date) (.getMonthValue date)))
:cljs
(let [date (new js/Date)]
(make-date (.getFullYear date) (inc (.getMonth date))))))
This is one way to do it
edit: fixed month; java.time doesn't need the +1 adjustment1. java.util
uses Joda time which is deprecated, you should avoid it
2. Can't tell from this snippet but if you want to extensively target JVM and browsers you should take a look at cljc.java-time or tick
3. if make-date builds a date string, you can use a formatter to build it, there's probably no need to write your own function
Oh that's brilliant, cheers @UEQPKG7HQ!
It doesn't build a string, it just returns that map and I have various simple methods to do (current-month {:year 2023 :month 12})
etc, also converting it to an int so you can do arithmetics on it or comparison etc.
Nothing fancy, just wanted to get rid of the complexity of dates.