Fork me on GitHub
#clojure
<
2018-02-02
>
tatyana00:02:53

is there a specific directory where I should be executing the lein script from: https://github.com/technomancy/leiningen#installation ? I did brew uninstall leiningen. Now I downloaded the script and ran it in the terminal. It outputted some available tasks but I can't get "lein" command to be recognized by the system after it supposedly installed.

Leiningen is a tool for working with Clojure projects.

Several tasks are available:
change              Rewrite project.clj by applying a function.
check               Check syntax and warn on reflection.
classpath           Print the classpath of the current project.
clean               Remove all files from project's target-path.
compile             Compile Clojure source into .class files.
deploy              Build and deploy jar to remote repository.
deps                Download all dependencies.
do                  Higher-order task to perform other tasks in succession.
help                Display a list of tasks or help for a given task.
install             Install the current project to the local repository.
jar                 Package up all the project's files into a jar file.
javac               Compile Java source files.
new                 Generate project scaffolding based on a template.
plugin              DEPRECATED. Please use the :user profile instead.
pom                 Write a pom.xml file to disk for Maven interoperability.
release             Perform :release-tasks.
repl                Start a repl session either with the current project or standalone.
retest              Run only the test namespaces which failed last time around.
run                 Run a -main function with optional command-line arguments.
search              Search Central and Clojars for published artifacts.
show-profiles       List all available profiles or display one if given an argument.
test                Run the project's tests.
trampoline          Run a task without nesting the project's JVM inside Leiningen's.
uberjar             Package up the project files and dependencies into a jar file.
update-in           Perform arbitrary transformations on your project map.
upgrade             Upgrade Leiningen to specified version or latest stable.
vcs                 Interact with the version control system.
version             Print version for Leiningen and the current JVM.
with-profile        Apply the given task with the profile(s) specified.

Run `lein help $TASK` for details.

Global Options:
  -o             Run a task offline.
  -U             Run a task after forcing update of snapshots.
  -h, --help     Print this help or help for a specific task.
  -v, --version  Print Leiningen's version.

These aliases are available:
downgrade, expands to upgrade

See also: readme, faq, tutorial, news, sample, profiles, deploying, gpg,
mixed-source, templates, and copying.
[tlomberg@tlomberg-mac /Users/tlomberg/workspace] $ lein install
-bash: lein: command not found

the2bears00:02:12

@tlomberg did you add it to your path?

tatyana00:02:29

how do I do that?

the2bears00:02:52

Depending on your OS, I'd Google it. Typically there's an environment variable, PATH, where you add directories. If you're on Linux/Mac type 'echo $PATH' in a shell and you can install lein into something found in the result. I have mine in /usr/local/bin.

the2bears00:02:28

There's also a #leiningen channel that is better suited for these questions.

tatyana00:02:26

i'm on a mac

tatyana00:02:00

[tlomberg@tlomberg-mac /usr/local/bin] $ echo $PATH /Users/tlomberg/:/usr/local/mysql/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/kerberos/sbin:/usr/kerberos/bin

tatyana00:02:14

i have the script under /usr/local/bin

tatyana00:02:21

seeing same behavior

the2bears00:02:15

Did you follow the instructions in the link you posted above? Have you made the script executable? What behavior do you see?

tatyana00:02:49

[tlomberg@tlomberg-mac /usr/local/bin] $ . lein-install-script.sh
dirname: illegal option -- b
usage: dirname path
dirname: illegal option -- b
usage: dirname path
Leiningen is a tool for working with Clojure projects.

Several tasks are available:
change              Rewrite project.clj by applying a function.
check               Check syntax and warn on reflection.
classpath           Print the classpath of the current project.
clean               Remove all files from project's target-path.
compile             Compile Clojure source into .class files.
deploy              Build and deploy jar to remote repository.
deps                Download all dependencies.
do                  Higher-order task to perform other tasks in succession.
help                Display a list of tasks or help for a given task.
install             Install the current project to the local repository.
jar                 Package up all the project's files into a jar file.
javac               Compile Java source files.
new                 Generate project scaffolding based on a template.
plugin              DEPRECATED. Please use the :user profile instead.
pom                 Write a pom.xml file to disk for Maven interoperability.
release             Perform :release-tasks.
repl                Start a repl session either with the current project or standalone.
retest              Run only the test namespaces which failed last time around.
run                 Run a -main function with optional command-line arguments.
search              Search Central and Clojars for published artifacts.
show-profiles       List all available profiles or display one if given an argument.
test                Run the project's tests.
trampoline          Run a task without nesting the project's JVM inside Leiningen's.
uberjar             Package up the project files and dependencies into a jar file.
update-in           Perform arbitrary transformations on your project map.
upgrade             Upgrade Leiningen to specified version or latest stable.
vcs                 Interact with the version control system.
version             Print version for Leiningen and the current JVM.
with-profile        Apply the given task with the profile(s) specified.

Run `lein help $TASK` for details.

Global Options:
  -o             Run a task offline.
  -U             Run a task after forcing update of snapshots.
  -h, --help     Print this help or help for a specific task.
  -v, --version  Print Leiningen's version.

These aliases are available:
downgrade, expands to upgrade

See also: readme, faq, tutorial, news, sample, profiles, deploying, gpg,
mixed-source, templates, and copying.

[Process completed]

tatyana00:02:54

i made it executable

gonewest81800:02:25

what you downloaded and named lein-install-script.sh is literally the lein command. You would copy that script to /usr/local/bin/lein (for example) and chmod +x /usr/local/bin/lein

gonewest81800:02:57

and at that point if you type which lein in your shell, it should respond /usr/local/bin/lein

the2bears00:02:32

Right, I see that now 🙂 Change the file to 'lein' as @gonewest818 says.

gonewest81800:02:18

In your transcript above, I see you are also sourcing the file (`. lein-install-script.sh`) but when all is said and done you will just run lein at the prompt.

gonewest81800:02:56

The “installation” they are referring to is really just downloading the leiningen jar. By default the jar is placed in ~/.lein/self-installs/leiningen-$(VERSION)-standalone.jar. Because in general different projects may use different versions of leiningen you could end up with more than one jar in the self-installs directory and that’s fine. You shouldn’t really need to worry about that.

caleb.macdonaldblack04:02:28

How could I turn [0 1 2 3] into [[0 1] [1 2] [2 3]]? kind of like joining them.

caleb.macdonaldblack04:02:00

@seancorfield Awesome thanks! (partition 2 1 [0 1 2 3]) => ((0 1) (1 2) (2 3))

qqq14:02:58

I can't believe (def a-?-2 30) is valid code.

Alex Miller (Clojure team)14:02:25

- ? are both valid constituent characters for symbols

tatyana14:02:52

Still having leiningen problems, after I installed lein script in /usr/local/bin and started using it, I’m seeing strange behavior: When I try to package a jar, I see the following:

[tlomberg@tlomberg-mac /Users/tlomberg/workspace/recruit-app] $ lein deploy
Tried to use insecure HTTP repository without TLS.
This is almost certainly a mistake; however in rare cases where it's
intentional please see `lein help faq` for details.Tried to use insecure HTTP repository without TLS.
This is almost certainly a mistake; however in rare cases where it's
intentional please see `lein help faq` for details.

tatyana14:02:38

i get it in different projects

tatyana14:02:11

[tlomberg@tlomberg-mac /Users/tlomberg/workspace/gardner] $ lein deploy
Created /Users/tlomberg/workspace/gardner/target/gardner-0.4.9-SNAPSHOT.jar
Wrote /Users/tlomberg/workspace/gardner/pom.xml
Tried to use insecure HTTP repository without TLS.
This is almost certainly a mistake; however in rare cases where it's
intentional please see `lein help faq` for details.

chris14:02:37

where are you trying to deploy?

noisesmith14:02:06

This is something that leiningen 2.8.1 does if you are using http repositories in your setup. If you can't switch from http to https you can run lein upgrade 2.7.1 for a temporary workaround

noisesmith14:02:53

if all you want is to make a jar, you don't need to use deploy, just use lein jar or even lein install to put it in your local cache (in case you literally meant "package a jar" and not put a jar in a repo)

chris14:02:46

you can use jar, install or uberjar, depending on what you want, if you actually just want to package it

tatyana14:02:56

we use nexus

tatyana14:02:46

i need to package it and import it into another project as a dep

noisesmith14:02:55

either upgrade your nexus to use https, or downgrade to 2.7.1

mpenet14:02:14

could be as simple as replacing http with https in your profile/config

noisesmith14:02:18

https is the better option, though I know that isn't always under your control

mpenet14:02:23

if it's already setup for https

chris14:02:41

are you doing this on the same machine? Unless you need this go through nexus you can just use lein install

chris14:02:27

but yes, upgrading/reconfiguring nexus to use TLS is the correct answer, even if that means badgering IT to do an upgrade

husain.mohssen14:02:26

what's the most modern way to quickly bring in a dependency for an experiment without doing a project? I'm trying to use Clojure like a scripting language. Ie. Do lein repl run a few commands and then be done with it. lein-try seems to be an option (https://github.com/rkneufeld/lein-try) seems to be an option but it's kinda old and not sure if it's best practice

husain.mohssen14:02:52

is the clj command that came with 1.9 a path I should consider?

robert-stuttaford14:02:14

@husain.mohssen lein-try should totally work, it’s using a very slow-moving part of the ecosystem. did you try it? they used it to verify all the recipes in the Clojure Cookbook. clj command will be a fun learning experience, if it doesn’t work 🙂 i know @mfikes has already got a lot of practice putting these one-liners together

husain.mohssen14:02:01

@robert-stuttaford thanks! what does the last line mean? Can I bring external dependencies using the new clj from the command line?

robert-stuttaford14:02:31

ah - i don’t know - i was kinda going on the idea that you knew 🙂

robert-stuttaford14:02:10

ok. seems you need a deps.edn @husain.mohssen. you’ll probably win through in 10 minutes if you try it out

husain.mohssen15:02:24

yes that works, but in that case Im better off using lein try since that does not require an external file. btw is there a reason to prefer clj over lein repl in 1.9?

sundarj15:02:26

@husain.mohssen @robert-stuttaford you do not need a deps.edn:

~$ clj -Sdeps "{:deps {org.clojure/core.async {:mvn/version \"0.4.474\"}}}"
Clojure 1.9.0
user=> (require '[clojure.core.async :as async])
nil
user=> (async/chan)
#object[clojure.core.async.impl.channels.ManyToManyChannel 0x276b68af "clojure.core.async.impl.channels.ManyToManyChannel@276b68af"]

robert-stuttaford15:02:39

if you don’t want to use lein any more, that’d be one great reason 🙂

sundarj15:02:52

clj starts a lot faster than lein/boot repl

robert-stuttaford15:02:15

and tools.deps allows you to use git repos and local directories as deps, first-class. no more lein install / checkouts shenanigans

sundarj15:02:47

(i deliberately chose a dep i had downloaded before)

sundarj15:02:13

you can open a cljs repl with it too:

clj -Sdeps "{:deps {org.clojure/clojurescript {:mvn/version \"1.9.946\"}}}" -m cljs.repl.node
ClojureScript Node.js REPL server listening on 49391
To quit, type: :cljs/quit
cljs.user=> (.log js/console "hello node")
hello node
nil

robert-stuttaford15:02:12

@sundarj where did you find -Sdeps in the docs? rather, where is it documented

Alex Miller (Clojure team)15:02:23

It’s new if you don’t have the latest

robert-stuttaford15:02:29

thanks - i don’t know how i missed it on there 🙈

rcustodio15:02:31

in deps, is git gonna be able to use ssh?

Alex Miller (Clojure team)15:02:47

yes, it talks to your local ssh-agent

Alex Miller (Clojure team)15:02:05

so works with github private repos for example

Alex Miller (Clojure team)15:02:31

yeah (presuming you register your identity with your ssh agent)

rcustodio15:02:48

instead of I must use

rcustodio15:02:55

I have the identity

Alex Miller (Clojure team)15:02:56

with github, most people use the [email protected]:user/project.git url

Alex Miller (Clojure team)15:02:44

the thing it gives you on a project page under the “clone or download” button

rcustodio15:02:15

I tried that url and it didnt work, but under gitlab

rcustodio15:02:33

UnknownHostKey: http://gitlab.com. RSA key fingerprint is b6:03:0e:39:97:9e:d0:e7:24:ce:a3:77:3e:01:42:09

ghadi15:02:34

@alexmiller most people do not use ssh at github

rcustodio15:02:42

UnknownHostKey: . RSA key fingerprint is b6:03:0e:39:97:9e:d0:e7:24:ce:a3:77:3e:01:42:09

ghadi15:02:11

@rcustodio to avoid that issue, first do ssh and accept the host key -- then try again with clj

rcustodio15:02:15

This helps in company provate repositories

rcustodio15:02:51

Okey, thanks

rcustodio15:02:23

@ghadi I did it, still the error

ghadi15:02:54

one sec -- there is a way to force a particular algorithm for the host key, digging it up

Alex Miller (Clojure team)15:02:10

the other thing that has come up is host keys in non-rsa keys, which the current path doesn’t handle by default

ghadi15:02:08

ed25519 keys do work, it's JSch's key order that bungles things up

ghadi15:02:32

(through an ssh-agent it does the right thing, but not if you have entries in .ssh/config)

rcustodio15:02:16

It worked, but I had to use it like

ghadi15:02:42

oh, cool. Did you mess with known_hosts at all?

rcustodio15:02:52

Nope, just changed the URL

ghadi15:02:59

what was the URL before?

rcustodio15:02:10

:user/project.git

ghadi15:02:21

interesting x2

Alex Miller (Clojure team)15:02:32

yeah, that’s interesting

tatyana15:02:33

@chris @noisesmith @mpenet Thank you! downgrading to 2.7.1 worked for me

rcustodio15:02:53

I use Mac if that makes any diff

Alex Miller (Clojure team)15:02:18

eventually we will uncover and document all of the complexities around using git deps :)

rcustodio15:02:21

Now, I dunno what this error means

Error building classpath. Manifest type not detected when finding deps for vikingmakt/njord in coordinate {:git/url "", :tag "0.3.0", :sha "862c1f6d91293e5ba7b621a6db2a07149c90eab7"}
Because its not a jar? Not released?

Alex Miller (Clojure team)15:02:34

it’s trying to understand the dependencies of that project

Alex Miller (Clojure team)15:02:53

by detecting a manifest file like deps.edn or pom.xml

ghadi15:02:54

Right now the latest tools.deps reads through maven poms, and deps.edn

rcustodio15:02:56

So the project should have deps.edn as well?

Alex Miller (Clojure team)15:02:59

it does not (yet) understand project.clj

rcustodio15:02:09

I see, good to know

Alex Miller (Clojure team)15:02:24

so yes, you’ll need a deps.edn to declare deps for now

rcustodio15:02:28

I will talk with ppl in the company to start doing the deps.edn

Alex Miller (Clojure team)15:02:11

if it doesn’t have any deps, you could add :deps/manifest :deps to force deps.edn and it will tolerate the missing manifest file

rcustodio15:02:30

I see, thanks!!!

husain.mohssen16:02:15

@alexmiller Any chance future versions of clj will have syntactic sugar for dependencies that make it less verbose to quickly test something (a-la lein try) ?

ghadi16:02:25

you can already do that through clj -Sdeps @husain.mohssen

ghadi16:02:47

(if you single quote the outer argument, then you don't have to escape the inner string)

rnagpal18:02:29

In maven we have -U to download the repositories to the internal repository if its not present there -U,--update-snapshots Forces a check for missing releases and updated snapshots on remote repositories

rnagpal18:02:52

What is the similar option in Leiningen ?

noisesmith18:02:24

but also, in case there's any miscommunication - every dep leiningen uses is put in the local cache, -U is for checking for a newer snapshot even if you have one that's been fetched within the last 24 hours

rnagpal18:02:32

@noisesmith -U doesn’t have any affect

noisesmith18:02:54

what do you expect that isn't happening/

rnagpal18:02:06

but if I declare the same dependency in pom.xml and run mvn -U

rnagpal18:02:34

it will download the dependencies missing in the internal repository

noisesmith18:02:45

leiningen always does this

noisesmith18:02:58

unless you mean some actual repo other than the .m2 cache?

rnagpal18:02:47

yeah not the local .m2

rnagpal18:02:50

but internal

noisesmith18:02:56

mvn -U just checks for new snapshots, according to the man page

noisesmith18:02:20

which is what lein -U does

rnagpal18:02:24

Forces a check for missing releases and updated snapshots on remote repositories

rnagpal18:02:34

so it checks the releases also

rnagpal18:02:44

on the remote repository

noisesmith18:02:52

are you expecting auto version upgrading?

noisesmith18:02:18

you need a different kind of dep version tag for that, it's the same syntax used for maven though

noisesmith18:02:35

the leiningen team and community are highly opinionated against version ranges

noisesmith18:02:44

so yo uwont' see many examples of that in the wild

noisesmith18:02:00

but if you ask for a version range, you get compatible behavior

rnagpal18:02:32

nopes, I dont want auto version upgrades. I just want to pull the missing release jars in the internal repo if they are missing there

noisesmith18:02:18

I have no idea what's going on here or what you are expecting, maybe someone else can help, sorry

rnagpal18:02:36

Thanks for trying to help @noisesmith

akhudek19:02:25

Does anyone know of a tool that will scan a clojure project dependencies and collect the license information from clojars? There are several tools that will do the java libraries, but they don’t seem to know about clojars.

akhudek19:02:28

yeah, I’ll probably have to resort to writing my own crawler against the clojars api. Was hoping someone already did. 🙂

tcrawley19:02:30

I think it would be fairly straightforward to add the license to https://github.com/clojars/clojars-web/wiki/Data#useful-extracts-from-the-poms

noisesmith19:02:30

you could also visit each pom.xml accompanying each jar on the classpath, and extract the license data

akhudek19:02:18

ah, interesting, thanks!

arrdem20:02:17

You could probably crib some code from lein-ancient for doing the Maven scan…

trptcolin21:02:07

so… let’s say i’ve got a java dependency i’d like to bring in that requires jvm 1.8. what are my options, if i want to support 1.6/1.7 users in some way (across lein, boot, tools.deps.alpha, maven)? spitballing ideas so far: - use a “provided” dependency and require the consumer to decide whether to pull it in; have the code see if the relevant classes are available at runtime (similar to what clojure.core.reducers does) - abandon pre-jvm-1.8; require consumers to upgrade is there anything else?

danielcompton21:02:55

- Create two variants of the JAR for consumers to pick ?

gklijs21:02:53

There are some options, I new of some java collogues using some library where they could use lambda's, and still compile to 1.7. but when the incompatibilities are in libraries, and not in your own code, it might be more challenging.

ghadi21:02:28

at this point... abandon < 1.8

ghadi21:02:01

Java 9 has Multi-Release JARs, but that doesn't help you yet @trptcolin

chris21:02:01

7 is long EOLed

gklijs21:02:42

Yes, but some companies are very conservative unfortunately.

chris21:02:52

yeah, including mine, unfortunately

chris21:02:16

I would say unless you are supporting something specific for, say, enterprise you can safely say sayonara

trptcolin21:02:00

so if we go non-hypothetical: this is for reply (which is the leiningen / boot repl). i don’t think abandoning < 1.8 is realistic [could be wrong]

trptcolin21:02:16

maybe the 2018 clojure survey results will have a different answer than i expect 🙂

trptcolin21:02:40

:thinking_face: > After April 2015, Oracle will no longer post updates of Java SE 7 to its public download sites.

ghadi21:02:42

2017 survey results had minimal java 7 (sorry not trying to make your life hard @chris simple_smile)

Alex Miller (Clojure team)21:02:33

I’m ready to abandon java 7 for clojure :)

Alex Miller (Clojure team)21:02:51

2018 results so far are showing ~6% of people still using java 7 and <0.4% still using java 6

trptcolin21:02:48

iiiiinteresting…

Alex Miller (Clojure team)21:02:53

the new clj tool requires 1.8

Alex Miller (Clojure team)21:02:31

java 1.8 is set to end public updates in Jan 2019

juhoteperi22:02:23

Google is only testing Closure-compiler using 1.8 and is using 1.8 features on tests at least (it might still be possible to run Closure, and Cljs, on Java 1.8, but probably not for long)

trptcolin22:02:06

thanks y’all, good stuff. seems like there’s a pretty reasonable case for abandoning pre-1.8, good news

akhudek22:02:00

for anyone else looking to enumerate licenses, https://github.com/technomancy/lein-licenses does the trick!