# \[SOLVED\] Can't run REPL with Leinengen

**URL:** https://clojureverse.org/t/solved-cant-run-repl-with-leinengen/9225
**Category:** Beginners
**Tags:** clojure, leiningen, repl
**Created:** [August 10, 2022, 1:45pm UTC](https://clojureverse.org/t/solved-cant-run-repl-with-leinengen/9225 "2022-08-10T13:45:58Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![steakoverflow-me](https://clojureverse.org/user_avatar/clojureverse.org/steakoverflow-me/32/4613_2.png) [@steakoverflow-me](https://clojureverse.org/u/steakoverflow-me)
#### Post date: [August 10, 2022, 1:45pm UTC](https://clojureverse.org/t/solved-cant-run-repl-with-leinengen/9225/1 "2022-08-10T13:45:58Z")

</div>

Hi all! I have a problem. Leiningen runs my application instead of REPL.

project.clj:

```auto
(defproject patients "0.1.0-SNAPSHOT"
  :description "Test app"
  :url ""
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :dependencies [[org.clojure/clojure "1.9.0"]

                 [ring/ring-core "1.9.5"]
                 [ring/ring-jetty-adapter "1.9.5"]

                 [compojure "1.7.0"]]

  :main patients.app

  :profiles {:dev {:plugins []
                   :dependencies []
                   :source-paths ["dev"]}})

```

src/patients/app.clj:

```auto
(ns patients.app)

(require '[ring.adapter.jetty :refer [run-jetty]])
(require '[compojure.core :refer [GET ANY defroutes]])

(defn page-index [request]
  {:status 200
   :headers {"content-type" "text/plain"}
   :body "Application index!"})

(defn page-404 []
  {:status 404
   :headers {"content-type" "text/plain"}
   :body "Page not found."})

(defroutes app
  (GET "/" request (page-index request))
  (ANY "/ping" _ {:status 200 :headers {"content-type" "text/plain"} :body "pong"})
  page-404)

(run-jetty app {:port 8080 :join? true})

```

Terminal output:

```auto
lania-kea@lania-kea-macbook-pro patients % (main) 
▸ lein --version
Leiningen 2.9.9 on Java 11.0.13 OpenJDK 64-Bit Server VM
lania-kea@lania-kea-macbook-pro patients % (main) 
▸ lein repl
2022-08-10 19:13:23.958:INFO::main: Logging initialized @5437ms to org.eclipse.jetty.util.log.StdErrLog
2022-08-10 19:13:25.549:INFO:oejs.Server:main: jetty-9.4.44.v20210927; built: 2021-09-27T23:02:44.612Z; git: 8da83308eeca865e495e53ef315a249d63ba9332; jvm 11.0.13+8
2022-08-10 19:13:25.598:INFO:oejs.AbstractConnector:main: Started ServerConnector@71f437d7{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2022-08-10 19:13:25.602:INFO:oejs.Server:main: Started @7081ms
REPL server launch timed out.

```

Server works well, all routes and 404 page are correctly available in browser. But I need REPL.  
Please help, because I can’t go on my education process =(

---

<div class="post-metadata">

### Author: ![ronin78](https://clojureverse.org/user_avatar/clojureverse.org/ronin78/32/1937_2.png) [@ronin78](https://clojureverse.org/u/ronin78)
#### Post date: [August 10, 2022, 2:22pm UTC](https://clojureverse.org/t/solved-cant-run-repl-with-leinengen/9225/2 "2022-08-10T14:22:18Z")

</div>

I’m not entirely sure about this, but I think your “(run-jetty…)” process is locking up the REPL connection. When I run programs like this I usually start the REPL independently, from the command line, run my “run whatever” or (-main), and “jack in” from my editor to work with the REPL.

---

<div class="post-metadata">

### Author: ![marcofiset](https://clojureverse.org/user_avatar/clojureverse.org/marcofiset/32/4611_2.png) [@marcofiset](https://clojureverse.org/u/marcofiset)
#### Post date: [August 10, 2022, 2:58pm UTC](https://clojureverse.org/t/solved-cant-run-repl-with-leinengen/9225/3 "2022-08-10T14:58:44Z")

</div>

Yeah, this is pretty much what is happening.

You should move the `run-jetty` call to a function, and invoke that function manually once the REPL gets going.

---

<div class="post-metadata">

### Author: ![steakoverflow-me](https://clojureverse.org/user_avatar/clojureverse.org/steakoverflow-me/32/4613_2.png) [@steakoverflow-me](https://clojureverse.org/u/steakoverflow-me)
#### Post date: [August 10, 2022, 3:53pm UTC](https://clojureverse.org/t/solved-cant-run-repl-with-leinengen/9225/4 "2022-08-10T15:53:12Z")

</div>

Thank you all for answers!  
Helped to move server invocation to `-main` function.

---

<div class="post-metadata">

### Author: ![jr0cket](https://clojureverse.org/user_avatar/clojureverse.org/jr0cket/32/670_2.png) [@jr0cket](https://clojureverse.org/u/jr0cket)
#### Post date: [January 24, 2023, 12:42pm UTC](https://clojureverse.org/t/solved-cant-run-repl-with-leinengen/9225/5 "2023-01-24T12:42:01Z")

</div>

Use `:join false` when starting jetty app server to return to the REPL terminal prompt after the server starts

```auto
(run-jetty app {:port 8080 :join? false}

```

Otherwise with true the jetty sever keeps hold of the execution thread and blocks the REPL prompt from showing

---

<div class="post-metadata">

### Author: ![system](https://clojureverse.org/uploads/default/original/2X/5/51079bf9e4b7d9466242c06cf1e43b9f8bd6da14.png) [@system](https://clojureverse.org/u/system)
#### Post date: [July 26, 2023, 12:42am UTC](https://clojureverse.org/t/solved-cant-run-repl-with-leinengen/9225/6 "2023-07-26T00:42:10Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
