How can I install Leiningen self-install from behind a firewall? - clojure

Is there a full download I can use which downloads leiningen and all related stuff in one go? I am not able to change the proxy settings on my local network, and this is the error I get:
"DownloadFile" with "2" argument(s): "The remote server returned an error: (407) Proxy Authentication Required."
Update
You need to download the Leiningen standalone jar and then point LEIN_JAR to it:
set LEIN_JAR=full path to leiningen standalone jar

For me - setting the proxies didn't work (and downloading the jar was unsatisfactory)
I got:
the wget binary, and
the wget dependencies
and put them on my PATH - ie h:\util contains:
wget.exe
libssl32.dll
libintl3.dll
libiconv2.dll
libeay32.dll
(where H:\util was already on my path. )
and then got a new terminal cmd.exe - and then lein self-install worked.
Assumptions:
Downloading the jar was unsatisfactory because the point of lein is to be a dependency manager (like maven). You need to keep downloading stuff. If you manually download the first jar - then when you add some more jar dependencies to your project you'll have to manually download those as well. Might as well chuck out lein and go back to doing things on the Java classpath.
In my view - in a windows environment proxy settings should be automatically detected. Lein can't do this (yet) - but the wget version I downloaded could. So you solve the problem of needing to explicitly specify the proxy. (In addition - manually setting the proxy just didn't work for me)

This should help:
https://github.com/technomancy/leiningen/wiki/HTTP-Proxies
You should work on your googling skills ;)

I want to post this as a comment to #hawkeye, but I dont have enough reputation. This work for me only when I set environment variable.
set HTTP_CLIENT=wget --no-check-certificate -O

Related

How to patch and recompile axis2_1.6.1.wso2v14.jar in wso2esb 4.9.0

If I modify manually axis2_1.6.1.wso2v14.jar, wso2esb 4.9.0 crashes at startup with the following message:
Could not start: null(reference:file:../plugins/axis2_1.6.1.wso2v14.jar:17). It's state is uninstalled.
In my case, I want to apply the following patch : https://github.com/wso2/wso2-axis2/commit/0f826cbf230b8c855b041ea1db3a751319cd3e91 that was released for wso2esb 5.0.0
Note:
This happens even if I only unzip the jar, and then recreate it as it with
$ jar cf *
How can I patch and recompile axis2_1.6.1.wso2v14.jar in wso2esb 4.9.0 ?
You can basically follow the below steps. But before that check if the same fix was issued using a WUM update. If not
You need to download the relevant tag first v1.6.1-wso2v14
Cherry-pick the commit that you wanna include. (This may be straightforward in some cases, but there might be issues in some scenarios since there can be a lot of changes or dependency classes been changed. So be careful on that)
Build the tag with the fix
Get the build axis2_1.6.1-wso2v14.jar
Create a new patch directory with a higher number inside <ESB-Home>/repository/component/patches directory
Copy the jar file to that directory e.g. patch1000/axis2_1.6.1-wso2v14.jar (Check the jar file name, it should be same as in plugins directory)
Restart the server
You can refer to Doc1, Doc2 for more info
Edited
Don't try to package it using jar cf command. Run mvn clean install. This is not a standard jar but an OSGi bundle. So copy the jar file you get from mvn clean install. If the name differs just rename the jar name (- to _)

Leiningen raises "Tried to use insecure HTTP repository without TLS." but for which dependency?

I'm using Leiningen to run a Clojure project on my Raspberry Pi 3 (running stretch), previously I used version 2.7.1 with no problems, but upgrading to the latest version on lein (2.8.1) I now get this error for some of the dependencies (but not others):
Tried to use insecure HTTP repository without TLS
However, lein doesn't tell me which dependencies are causing problems, so how do I discover which ones cause this error?
Also is it possible to disable this security feature for certain dependencies? I'm only running on a home network so consider this acceptable.
Answer edited after a comment correctly pointed out that the first method was showing only the immediate dependencies.
Generate the Maven POM:
lein pom
Wrote .../pom.xml
Following this answer for Java https://stackoverflow.com/a/3270067/561422, use the Maven dependency plugin:
mvn dependency:purge-local-repository > raw.txt
Open raw.txt in an editor and search for the string http:, that should point you on the right track.
For example with Unix command-line tools:
Unsafe repos (searching for http:):
grep http: raw.txt
Downloading from example: http://unsafe.example.org
[Note: this is not my preferred solution, but it got my project working again].
Use Leiningen 2.7.1, which doesn't have such strict security checks. Download from:
https://raw.githubusercontent.com/technomancy/leiningen/2.7.1/bin/lein
It's a bit difficult to see which extension causes the problem as they can include other deps as well.
You can still download the extension though.
From the lein FAQ;
This is very insecure and exposes you to trivially-executed man-in-the-middle attacks. In the rare event that you don't care about the security of the machines running your project, you can re-enable support for unprotected repositories by putting this at the top of your project.clj file:
;; allow insecure downloads
(require 'cemerick.pomegranate.aether)
(cemerick.pomegranate.aether/register-wagon-factory!
"http" #(org.apache.maven.wagon.providers.http.HttpWagon.))
For me this worked on several older project that were not updated. In the logs you can easily track which package was downloaded via http.
So this answers the : "Is it possible to disable the security" feature question from the OP.
The other question seems to have an answer on StackOverflow already. Display complete dependency tree with Leiningen

Nexus 3.5.1 proxies from snapshot repo nothing but maven metadata files

I have upgraded nexus repository from 2.x to 3.x through following path:
2.4.14 -> 3.4.0 -> 3.5.1
All nexus services were packed in docker with data directory mapped from host's. For all services I use default either sonatype/nexus or sonatype/nexus3 containers. Nexus web interface is hidden behind nginx with simple reverse proxying.
I use the nexus service with boot-cj (with no credentials) tools which manages dependencies the same way as maven. Anyway the tool first downloads nexus-maven.xml with relevant sha1 files and tries to download jars. It works fine with all 2.x I had.
I created a proxy repository against remote sonatype-snapshots repo. When I start compilation I have Could not find artifact error. I found that the meatdata files are cached but all poms and jars.
I have tried to fix it by cleaning cache with the clean_cache file trick and more rough rm -rfv /srv/nexus3/nexus-data/cache/* with no success. There are no any logs about error. Also I have checked manually that required artefact exists in the remote repository. More obvious Rebuild index button gave no solution. I do not thing it is a problem with nginx, but who knows? Also leaving overnight to run the scheduled tasks did not help.
The expected artifact is org.eclipse.rdf4j:rdf4j:pom:2.3-20170901.145510-11.

Trouble installing Leiningen on Windows 7 behind firewall

I'm having trouble installing and configuring Leiningen on a Windows 7 work computer. I'm assuming that my company's firewall prevents the GitHub security certificate from authenticating.
I've tried to use the standalone jar but had trouble using it will several development tools Id like to use to work on Clojure projects.
What is the best way to get Leiningen set up given these circumstances? Is there a way to install curl or wget on Windows and call them from the batch file?
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
The error Im getting is:
Downloading Leiningen now...
'powershell' is not recognized as an internal or external command,
operable program or batch file.
Failed to download https://github.com/technomancy/leiningen/releases/download/2.
7.1/leiningen-2.7.1-standalone.zip
It is possible that the download failed due to "powershell",
"curl" or "wget"'s inability to retrieve GitHub's security certificate.
The suggestions below do not check certificates, so use this only if
you understand the security implications of not doing so.
The PowerShell failed to download the latest Leiningen version.
Try to use "curl" or "wget" to download Leiningen by setting up
the HTTP_CLIENT environment variable with one of the following
values:
a) set HTTP_CLIENT=wget --no-check-certificate -O
b) set HTTP_CLIENT=curl -f -L -k -o
NOTE: Make sure to not add double quotes when setting the value
of HTTP_CLIENT
Thanks!
I would suggest downloading and installing Git Bash (aka "Git for Windows), which includes not only Git but a nice linux-like environment (a leaner version of Cygwin). At that point you will avoid any Powershell-related problems, which your error msg seems to imply.
https://git-scm.com/download/win

How does one start programming with Clojure in Windows?

I know it is possible to use CounterClockwise inside Eclipse, but I have been trying to get Leiningen to work so that I could use ClojureScript.
I downloaded leiningen using git clone. It then says run the script. I have tried lein self-install from inside PowerShell and inside the git bash environment.
In each I get an error about failing to download leiningen (which I thought I had with the git clone? hmm). It is interesting because one reads instructions that include things that don't make sense to Windows.
For example, inside Powershell, Windows doesn't understand export HTTP_CLIENT. It was only inside the git bash that I got a message that it is possible my HTTP client's certificate store does not have the correct certificate authority.
It then suggests this command, which runs ok, export HTTP_CLIENT="curl --insecure -f -L -o"
but it doesn't fix the problem.
The most recommended method AFAIK is to download the script lein.bat and putting it on the PATH environment variable. I've tested this method on several systems (XP, Windows 7). There is no need to build leiningen from a git checkout yourself. If you have a Windows with Powershell installed lein self-install should download the core .jar file inside a directory .lein in your user directory. Else, make sure you install either wget.exe or curl.exe and put it on the PATH.
There is an installer for Leiningen on Windows. You just need to install Java SE 7 JDK and Leiningen for Windows. This page has detailed instructions with screen shots: http://leiningen-win-installer.djpowell.net/
Leiningen for Windows creates a PATH variable and Clojure REPL shortcut among other things. From the REPL you can create, build, and automate your Clojure project.