This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-04
Channels
- # announcements (3)
- # aws (13)
- # babashka (10)
- # beginners (30)
- # biff (1)
- # calva (59)
- # chlorine-clover (11)
- # cider (3)
- # circleci (2)
- # clojars (22)
- # clojure (21)
- # clojure-europe (2)
- # clojurescript (10)
- # core-typed (2)
- # fulcro (8)
- # girouette (12)
- # graphql (1)
- # helix (6)
- # inf-clojure (4)
- # joyride (6)
- # leiningen (7)
- # off-topic (3)
- # pathom (44)
- # polylith (13)
- # shadow-cljs (44)
- # tools-deps (1)
Hi,
I'm in corporate net and I don't have access to clojars or any outside repo.
We have a local repository and after configuring ~\.lein\profiles.clj
to use these repos, I am able to get stuff working.
But this doesn't work for lein templates. example: lein new luminus newproj
fails:
Failed to resolve version for luminus:lein-template:jar:RELEASE: could not find metadata luminus:lein-template:maven-metadata.xml in local...
What can I do here?
Due to corporate restrictions, I can't manually download jars either so everything sucks.Templates are maven artifacts, if your maven repo doesn't have them you cannot use them
I see inside each version two files: lein-template-2.9.10.71.pom lein-template-2.9.10.71.pom.asc
There are cases where there's jars. Example lein-template-3.10.6.jar lein-template-3.10.6.pom
The template code appears to be hard coded to use https://github.com/technomancy/leiningen/blob/master/leiningen-core/src/leiningen/core/project.clj#L310
@UC1DTFY1G Have you tried specifying the version of one that you have in your corporate repo, rather than letting it use RELEASE? I can't remember how you do that with lein new
tho' (I haven't used Leiningen for years).
@U04V70XH6 Tried this with specifying --template-version
parameter with lein new luminus service --template-version 3.10.6
.
However, it looks like lein is trying to download from outside repos only:
Could not transfer artifact luminus:lein-template:jar:3.10.6 from/to central (
Could not transfer artifact luminus:lein-template:jar:3.10.6 from/to clojars (
Could not transfer artifact luminus:lein-template:jar:3.10.6 from/to central (
(Errors might have typos as I'm typing manually - can't access slack from corp either)
Oh, I added [:user :plugin-repositories]
section and added local repos there and that seems to do the trick
Thanks @U0NCTKEV8
What's the rationale for plugin repos to be different from repositories in profiels.clj?
Probably just because plugins have separate dependencies to the regular project dependencies -- so it's makes sense for them to be able to have separate repo specifications.
Such a nice example that gets right to the point:
https://clojurians.slack.com/archives/C053AK3F9/p1587697593451800?thread_ts=1587696826.448300&cid=C053AK3F9
Made a similar mistake in the map returned by a handler. That is, in the map the handler returns have :body {}
as opposed to :body ""
. You end up with this error message:
java.lang.IllegalArgumentException: No implementation of method: :write-body-to-stream of protocol: #'ring.core.protocols/StreamableResponseBody found for class: clojure.lang.PersistentArrayMap
Thanks @dpsutton!
Sorry if this is dumb. I want to import the class TDistribution from org.apache.commons/commons-math3, so I added this to project.clj:
:dependencies [ ;; other deps
[org.apache.commons/commons-math3 "3.6.1"]]
At the repl, I type:
(require '[org.apache.commons.math3.distribution.TDistribution :refer :all])
and get this:
Execution error (FileNotFoundException) at clojure-trade-bot-2.core/eval1605 (form-init6615340479110970914.clj:1).
Could not locate org/apache/commons/math3/distribution/TDistribution__init.class, org/apache/commons/math3/distribution/TDistribution.clj or org/apache/commons/math3/distribution/TDistribution.cljc on classpath.
The part that is strange to me is that the REPL completes the names when I press tab.
What am I doing wrong?You import
Java classes
require
is for Clojure namespaces
I tried this:
(import '[org.apache.... :refer :all])
and I get this:
Syntax error macroexpanding clojure.core/import at (/tmp/form-init6615340479110970914.clj:1:1).
:refer - failed: simple-symbol? at: [:package-list :quoted-spec :spec :classes] spec: :clojure.core.specs.alpha/package-list
[org.apache.commons.math3.distribution.TDistribution :refer :all] - failed: simple-symbol? at: [:class :quoted-spec :spec] spec: :clojure.core.specs.alpha/quotable-import-list
[org.apache.commons.math3.distribution.TDistribution :refer :all] - failed: simple-symbol? at: [:package-list :spec :classes] spec: :clojure.core.specs.alpha/package-list
(quote [org.apache.commons.math3.distribution.TDistribution :refer :all]) - failed: simple-symbol? at: [:class :spec] spec: :clojure.core.specs.alpha/quotable-import-list
import doesn't support modifiers as require. https://clojuredocs.org/clojure.core/import
Tried this:
(import org.apache....)
(no []'s) and it worked. Thanks!Now that I have successfully imported org.apache.commons.math3.distribution.TDistribution (http://haifengl.github.io/api/java/smile/stat/distribution/TDistribution.html#cdf-double-) I am trying to access the cdf method:
(def x (new TDistribution 1))
(.cdf x 42)
and I get this error:
Execution error (IllegalArgumentException) at clojure-trade-bot-2.core/eval1652 (form-init6615340479110970914.clj:1).
No matching method cdf found taking 1 args for class org.apache.commons.math3.distribution.TDistribution
Why can't Clojure find that method? I thought to access a method you do something like this:
(.method-name instance-name &whatever-parameters)
Because you import wrong class Your link goes to smile.stat.distribution.TDistribution
The import statement is:
(import org.apache.commons.math3.distribution.TDistribution)
But cdf method is in another class
I feel like an idiot
I went to documentation for class I did import and magically it works! Thanks @U04V4KLKC 🙂