lein bootstrap: stable release of leiningen - clojure

Whenever I try to run lein bootstrap in the leiningen-core/ directory I always get the following message:
Please run "lein bootstrap" in the leiningen-core/ directory
with a stable release of Leiningen. See CONTRIBUTING.md for details.
I have the 2.2.0 script (which is a stable release). I have placed lein in my path. I am using
Linux (CentOS)

bootstrap is only necessary if you are building lein from source. If you downloaded a stable release, it Just Works. So you can do things like lein new, lein jar, etc, with no further setup. See the excellent README for details.
Set your path correctly. For example, put the lein script in your ~/bin and then add ~/bin to your path environment variable.

Related

Cannot get Leiningen commands to work with figwheel

After following the instruction set on https://leiningen.org/ to install Leiningen, I have managed to download the batch file and save it within a folder located in: C:\Users\Dylan\Bin\Lein.bat.
I then ran lein.bat self-install in CMD, which created the folder .lein:
At this point the Leiningen is added. I am then able to create a new project called tictactoe using the command lein new figwheel tictactoe -- --reagent in CMD and it creates the folder fine. However, the problem arises when I try to compile the tictactoe project, see below:
When I issue the lein new figwheel tictactoe -- --reagent command, it says
Generating fresh 'lein new' figwheel project.
Change into your 'tictactoe' directory
Install npm dependencies via 'npm install'
Then run 'lein figwheel'
Did you do the npm install?

Leiningen not working MacOs Mojave due to Caused by: java.io.FileNotFoundException: Could not locate clojure/tools/nrepl/server__init.class

I am on Mojave and can't get leiningen to work.
I was using java 8, and then tried upgrading to 11 to no avail. Currently using:
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (buildb11.0.7+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.7+10, mixed mode)
I have tried copying lein to my /usr/local/bin and brew install but in both cases I get the error:
Caused by: java.io.FileNotFoundException: Could not locate clojure/tools/nrepl/server__init.class, clojure/tools/nrepl/server.clj or clojure/tools/nrepl/server.cljc on classpath.
I had a similiar problem recently on macOS Mojave (10.14.6). The following command did the trick for me:
rm -rf .lein
However, before you run this line, please make sure that...
... you are in your home directory.
... .lein is a directory associated with your leiningen installation and nothing else!
... that you have a backup of any config files, custom packages, etc. that are associated with your leiningen installation.
Once you hit enter the .lein directory will be deleted. The directory will be rebuild when you start the repl via leinigen lein repl.

how to start lein with an existing clojure jar

I am trying to download/install/run clojure/lein and facing some initial problems. I am using cygwin on windows-7.
After downloading the latest clojure (1.8.0), the following step works fine:
java -cp clojure-1.8.0.jar clojure.main
Now I installed lein using the following steps (thanks to stackoverflow/18711805 for help):
download lein script into ~/bin , set filetype=unix
install wget and deps (see stackoverflow/18711805)
setenv HTTP_CLIENT "wget --no-check-certificate -O"
lein self-install
Now when I run "lein repl", I find that lein has downloaded another clojure version (1.7.0) and using that.
So, how can I ask lein to use my version of clojure (ie 1.8.0) and not the 1.7.0 ? Are there any extra environment variables to be set before the lein run?
Also, where does lein install its extra downloads, and how do I clean up that area?
"lein upgrade" did the trick, I got the hint from stackoverflow/24094597. Now when I run lein again I can see 1.8.0 (not my own install, but lein has installed this new version). But since I installed lein just a few minutes ago from scratch anyway, I am not sure why it did not install the latest version in the first place.

Installing leiningen 2 on Ubuntu

I have followed the instructions here:
leiningen.org
To install from the lein script. I now have:
~/.lein/self-installs/leiningen-2.4.3-standalone.jar
How do I now run leiningen? The instructions are not clear.
On ubuntu, its quite easy. Download executable file, make it executable and place it in system path.
$ wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
$ chmod +x lein
$ sudo mv lein /usr/local/bin
You can also move it any directory which is in system path.
$ lein -v
Leiningen 2.6.1 on Java 1.8.0_77 Java HotSpot(TM) 64-Bit Server VM
Posting this as it might help other users.
Follow the install instructions.
Please make sure the leiningen script that the install instructions is on your executable PATH.
The script is the entry point to leiningen commands, so it's still needed after the downloads are complete.
It takes care of setting up environmental variables, paths and everything else required to run leiningen, so you can use
lein <command>
instead of
java -cp <whatever>:~/.lein/self-installs/leiningen-2.4.3-standalone.jar ... clojure.main -m leiningen.core.main <command>
I got the same doubt. Solved it. By following the instructions everything will be set for you. Next run the previously used script lein.sh in bin for creating projects as below.
suppose ~/bin/lein.sh is your script location ,then
$ ~/bin/lein.sh new test-project
$ ~/bin/lein.sh --help
It will create the project in your bin folder it self.If you wish to access that lein.sh globally then include it in $PATH.
If you are using a linux distribution you can just download the leiningen script and move it to your /bin folder. Once you've done that you can execute lein command and it will be installed for you.
So from your terminal you can run:
$ curl https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > ~/lein
to download lein script to your root path. Then you set it as executable and move to your /bin folder
$ chmod x+a lein
$ sudo mv ~/lein /bin
$ lein
After you run the command lein from anywhere on your terminal the lein script will install leininge for your and you'll be able to use it normally.

Setting up Yesod on Ubuntu 13.10

After following the instructions on the QuickStart, I'm seeing some errors in Yesod when bringing up a webpage. The errors end in:
...
cannot satisfy -package-id wai-extra-1.3.4.6-62543d69d10941dae1d9b206c3eb3067:
wai-extra-1.3.4.6-62543d69d10941dae1d9b206c3eb3067 is unusable due to missing or recursive dependencies:
blaze-builder-conduit-1.0.0-1053545317cd68e3d51439dd9a0e622d zlib-conduit-1.0.0-b51dc7daf506ea4c5ecd031c5101d96a
(use -v for more information)
Build failure, pausing...
Hopefully related, the referenced tutorial has me run
cabal-dev install
on a fresh Yesod project, however that also gives me errors:
...
[1 of 1] Compiling Control.Monad.Logger ( Control/Monad/Logger.hs, dist/build/Control/Monad/Logger.o )
Control/Monad/Logger.hs:63:39:
Module System.Log.FastLogger' does not exportpushLogStr'
Control/Monad/Logger.hs:63:72:
Module System.Log.FastLogger' does not exportLoggerSet'
Control/Monad/Logger.hs:63:83:
Module System.Log.FastLogger' does not exportnewLoggerSet'
Control/Monad/Logger.hs:63:97:
Module System.Log.FastLogger' does not exportdefaultBufSize'
Failed to install monad-logger-0.3.3.0
...
On this later set of errors, I came across a page suggesting the issue has been fixed (SO won't let me post more than 2 links, but Google the error and it comes right up).
Any ideas?
Thanks in advance!
I'd suggest using cabal sandbox for each Yesod project, rather than installing the Yesod platform as part of your system libraries. Think of a cabal sandbox as a localized collection of Haskell packages in a single project, so you could have different versions of a package, say Data.Text, in 2 different cabal sandboxes. Using cabal sandbox takes longer time for compilation but it makes things simpler for dependency resolution (read more here: (read more here: http://coldwa.st/e/blog/2013-08-20-Cabal-sandbox.html). cabal sandbox requires a cabal version of at least 1.18 if I'm not mistaken.
Alright, enough of the talk. Let's get started.
To get the latest cabal, it's easier if you have cabal installed through a package manager, even if the package manager installs a cabal without cabal sandbox. Since you are on Ubuntu, just:
sudo apt-get install cabal
Once you have some version of cabal installed, run:
cabal sandbox
If you see something along the lines of this:
cabal: Please specify a subcommand (see 'help sandbox')
Then congratulations, the version of cabal that you have supports cabal sandbox, just move on Once you have a Cabal with cabal sandbox section of the answer.
If instead you see something like:
cabal: unrecognised command: sandbox (try --help)
Then you will need a more modern version of cabal. Simply clone the cabal repository on github:
git clone https://github.com/haskell/cabal.git
Go to the directory, and checkout the branch Cabal-v1.18.1.2, like so:
git checkout Cabal-v1.18.1.2
Then execute:
cabal install Cabal/ cabal-install/
This should install cabal in the $HOME/.cabal/bin folder. Be sure to prepend $HOME/.cabal/bin to your PATH environment variable, before the folder where the system's cabal is located.
Once you have a Cabal with cabal sandbox
Based on what I read from the Yesod quick start guide, you will want to install the yesod-bin package. It's hackage page is here. Basically, yesod-bin provides you with a yesod binary that allows you to initialize a scaffolded site. The latest version of yesod-bin is 1.2.5.6, and that's what we're going to install.
Create a directory named yesod-bin:
mkdir yesod-bin
Go into that directory, and set up a cabal sandbox in that it, like so:
cabal sandbox init
Fetch the latest package list from hackage using:
cabal update
Now, we are going to install the latest version of yesod-bin, 1.2.5.6, in a cabal sandbox. However, yesod-bin has a dependency on the mmorph package, which defaults to install version 1.01, and trying to install mmorph-1.01 will result in an error message like the following:
src/Control/Monad/Morph.hs:76:8:
Could not find module `Control.Applicative.Backwards'
Use -v to see a list of the files searched for.
Failed to install mmorph-1.0.1
cabal: Error: some packages failed to install:
mmorph-1.0.1 failed during the building phase. The exception was:
ExitFailure 1
and installing yesod-bin without specifiy the mmorph package version defaults to installing mmorph-1.0.1, resulting in the following error:
cabal: Error: some packages failed to install:
base64-conduit-1.0.0 depends on mmorph-1.0.1 which failed to install.
blaze-builder-conduit-1.0.0 depends on mmorph-1.0.1 which failed to install.
conduit-1.0.10 depends on mmorph-1.0.1 which failed to install.
http-client-conduit-0.2.0.1 depends on mmorph-1.0.1 which failed to install.
http-conduit-2.0.0.3 depends on mmorph-1.0.1 which failed to install.
http-reverse-proxy-0.3.0 depends on mmorph-1.0.1 which failed to install.
mmorph-1.0.1 failed during the building phase. The exception was:
ExitFailure 1
network-conduit-1.0.1 depends on mmorph-1.0.1 which failed to install.
project-template-0.1.3.2 depends on mmorph-1.0.1 which failed to install.
resourcet-0.4.10 depends on mmorph-1.0.1 which failed to install.
wai-2.0.0 depends on mmorph-1.0.1 which failed to install.
wai-logger-2.1.1 depends on mmorph-1.0.1 which failed to install.
warp-2.0.2 depends on mmorph-1.0.1 which failed to install.
yaml-0.8.5.3 depends on mmorph-1.0.1 which failed to install.
yesod-bin-1.2.5.6 depends on mmorph-1.0.1 which failed to install.
which seems to be related to these 2 issues in the mmorph github repo:
https://github.com/Gabriel439/Haskell-MMorph-Library/issues/8
https://github.com/Gabriel439/Haskell-MMorph-Library/pull/10
However, mmorph version 1.0.0 works fine. As such, we will have to specify the version of mmorph to be 1.0.0 when we install yesod-bin, like this:
cabal install mmorph-1.0.0 yesod-bin-1.2.5.6
This will take quite some time. cabal sandbox creates a directory named .cabal-sandbox inside the yesod-bin directory, and the yesod binary (along with several other binaries from the yesod-bin package) can be found in the .cabal-sandbox/bin folder. Simply add that folder into your PATH, and you should be able to do the yesod init and yesod devel as seen at the end of the quick start.
As an quick update to #yanhan great answer, since I have tried to follow his guidelines on Ubuntu 14.04 LTS and get stuck a bit.
If you don't have cabal executable preinstalled, you can also do:
git clone https://github.com/haskell/cabal.git
Then of course:
git checkout Cabal-v1.20.0.2
And then you can use the bootstrap.sh script to install cabal executable and Cabal package:
cd cabal-install && ./bootstrap.sh
It will take some time, but soon after you can check the version of newly installed cabal executable:
$HOME/.cabal/bin/cabal --version