# Wrong Clojurescript REPL URL

**URL:** https://clojureverse.org/t/wrong-clojurescript-repl-url/10852
**Category:** Beginners
**Tags:** clojurescript
**Created:** [July 27, 2024, 10:17am UTC](https://clojureverse.org/t/wrong-clojurescript-repl-url/10852 "2024-07-27T10:17:05Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![KDr2](https://clojureverse.org/user_avatar/clojureverse.org/kdr2/32/3070_2.png) [@KDr2](https://clojureverse.org/u/KDr2)
#### Post date: [July 27, 2024, 10:17am UTC](https://clojureverse.org/t/wrong-clojurescript-repl-url/10852/1 "2024-07-27T10:17:05Z")

</div>

I was following [ClojureScript - Quick Start](https://clojurescript.org/guides/quick-start) and just started a small clojurescript project.

But, my REPL and browser were on different machines, I started the REPL by:

```auto
$ clj -M --main cljs.main --repl-opts "{:launch-browser false :port 8091 :host \"100.64.0.32\"}" --compile cljs01.core --repl
Waiting for browser to connect to http://100.64.0.32:8091 ...
ClojureScript 1.11.54
cljs.user=>                                        

```

And on the other machine, I opened `http://100.64.0.32:809`1 with my browser, I could see the webpage, but there was a request directing to `http://localhost:9000/repl?xpc=%7B...`, I think this URL may be the default URL listened by the server side? Why didn’t the `--repl-opts` change it?

Waiting for replies in eagerness, Thanks.

---

<div class="post-metadata">

### Author: ![p-himik](https://clojureverse.org/user_avatar/clojureverse.org/p-himik/32/4137_2.png) [@p-himik](https://clojureverse.org/u/p-himik)
#### Post date: [July 27, 2024, 10:36am UTC](https://clojureverse.org/t/wrong-clojurescript-repl-url/10852/2 "2024-07-27T10:36:20Z")

</div>

Can’t reproduce it with 1.11.132.

I’d try refreshing the browser page with removing all cache (in Chrome you can do it by opening the DevTools and then holding the Refresh button in the main browser panel, then selecting the Empty Cache and Hard Reload option).

---

<div class="post-metadata">

### Author: ![KDr2](https://clojureverse.org/user_avatar/clojureverse.org/kdr2/32/3070_2.png) [@KDr2](https://clojureverse.org/u/KDr2)
#### Post date: [July 27, 2024, 10:42am UTC](https://clojureverse.org/t/wrong-clojurescript-repl-url/10852/3 "2024-07-27T10:42:31Z")

</div>

I disabled the cache in the browser dev tools and upgraded clojurescrpt from 1.11.54 to 1.11.132, but the issue is still there…

---

<div class="post-metadata">

### Author: ![KDr2](https://clojureverse.org/user_avatar/clojureverse.org/kdr2/32/3070_2.png) [@KDr2](https://clojureverse.org/u/KDr2)
#### Post date: [July 27, 2024, 10:47am UTC](https://clojureverse.org/t/wrong-clojurescript-repl-url/10852/4 "2024-07-27T10:47:50Z")

</div>

and the query string of the request to `http://localhost:9000/repl` is:

```auto
xpc={"cn":"JjBpKU5zry","tp":null,"osh":null,"ppu":"http://100.64.0.32:8091/robots.txt","lpu":"http://localhost:9000/robots.txt"}

```

I am not sure if this helps for solving the issue.

---

<div class="post-metadata">

### Author: ![p-himik](https://clojureverse.org/user_avatar/clojureverse.org/p-himik/32/4137_2.png) [@p-himik](https://clojureverse.org/u/p-himik)
#### Post date: [July 27, 2024, 11:02am UTC](https://clojureverse.org/t/wrong-clojurescript-repl-url/10852/5 "2024-07-27T11:02:38Z")

</div>

Ah, wait - I actually _can_ reproduce it but only if I also provide the `--compile` option. Starting a plain REPL works just fine and uses the specified host/post.

---

<div class="post-metadata">

### Author: ![KDr2](https://clojureverse.org/user_avatar/clojureverse.org/kdr2/32/3070_2.png) [@KDr2](https://clojureverse.org/u/KDr2)
#### Post date: [July 27, 2024, 11:05am UTC](https://clojureverse.org/t/wrong-clojurescript-repl-url/10852/6 "2024-07-27T11:05:49Z")

</div>

Thank you, so it’s a bug? If so, could you or someone else help create an issue? I have no permission to file an issue on JIRA.

Also, I get this:

```bash
$ ag 9000 out/
out/clojure/browser/repl.cljs
32:(goog-define PORT 9000)

out/clojure/browser/repl.js
27:clojure.browser.repl.PORT = goog.define("clojure.browser.repl.PORT",(9000));

$ ag localhost out/
out/clojure/browser/repl.cljs
31:(goog-define HOST "localhost")

out/clojure/browser/repl.js
22:clojure.browser.repl.HOST = goog.define("clojure.browser.repl.HOST","localhost");

```

---

<div class="post-metadata">

### Author: ![KDr2](https://clojureverse.org/user_avatar/clojureverse.org/kdr2/32/3070_2.png) [@KDr2](https://clojureverse.org/u/KDr2)
#### Post date: [July 27, 2024, 11:11am UTC](https://clojureverse.org/t/wrong-clojurescript-repl-url/10852/7 "2024-07-27T11:11:08Z")

</div>

> [@p-himik](#):
>
> Starting a plain REPL works just fine and uses the specified host/post.

Same on my boxes, REPL without `--compile xxx` works.

---

<div class="post-metadata">

### Author: ![p-himik](https://clojureverse.org/user_avatar/clojureverse.org/p-himik/32/4137_2.png) [@p-himik](https://clojureverse.org/u/p-himik)
#### Post date: [July 27, 2024, 11:16am UTC](https://clojureverse.org/t/wrong-clojurescript-repl-url/10852/8 "2024-07-27T11:16:22Z")

</div>

I think I figured it out. This is what I’ve [reported on Slack](https://clojurians.slack.com/archives/C07UQ678E/p1722078685379039) in the `#cljs-dev` channel:

> What I assume is going on is that without the `--compile` option, the third `cond` branch in `cljs.repl.browser/send-static` gets executed, the one with the `;; "/main.js" doesn't exist, provide our own` comment, and it sets a custom `CLOSURE_UNCOMPILED_DEFINES` .  
> But with the `--compile` option, the first branch gets executed, and it doesn’t use `:host` /`:port` by itself. Perhaps, those parameters also don’t get compiled into `main.js` , which results in the issue.

As a workaround, you can add these arguments to the CLI, in addition to `--repl-opts`:

```bash
--compile-opts '{:closure-defines {clojure.browser.repl.HOST "100.64.0.32" clojure.browser.repl.PORT 8091}}'

```

(Note that you don’t have to escape `"` if the outer quotes are `'`.)

---

<div class="post-metadata">

### Author: ![KDr2](https://clojureverse.org/user_avatar/clojureverse.org/kdr2/32/3070_2.png) [@KDr2](https://clojureverse.org/u/KDr2)
#### Post date: [July 27, 2024, 11:20am UTC](https://clojureverse.org/t/wrong-clojurescript-repl-url/10852/9 "2024-07-27T11:20:47Z")

</div>

> [@p-himik](#):
>
> `--compile-opts '{:closure-defines {clojure.browser.repl.HOST "100.64.0.32" clojure.browser.repl.PORT 8091}}'`

That works, thank you in advance!

---

<div class="post-metadata">

### Author: ![p-himik](https://clojureverse.org/user_avatar/clojureverse.org/p-himik/32/4137_2.png) [@p-himik](https://clojureverse.org/u/p-himik)
#### Post date: [July 29, 2024, 1:57pm UTC](https://clojureverse.org/t/wrong-clojurescript-repl-url/10852/10 "2024-07-29T13:57:45Z")

</div>

It’s tracked under [[CLJS-3416] - JIRA](https://clojure.atlassian.net/browse/CLJS-3416).

---

<div class="post-metadata">

### Author: ![system](https://clojureverse.org/uploads/default/original/2X/5/51079bf9e4b7d9466242c06cf1e43b9f8bd6da14.png) [@system](https://clojureverse.org/u/system)
#### Post date: [January 28, 2025, 1:58am UTC](https://clojureverse.org/t/wrong-clojurescript-repl-url/10852/11 "2025-01-28T01:58:13Z")

</div>

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