Fork me on GitHub
#calva
<
2021-10-31
>
roelof11:10:26

When working with clojurescript , sometimes when I do clojure -A:fig:build sometimes I see a message to open a browser when doing that the repl do not show up and I do not see any error messages. I see this on FF and Chrome

roelof11:10:56

This is the output I see

4676ms to org.eclipse.jetty.util.log.StdErrLog
[Figwheel] Validating figwheel-main.edn
[Figwheel] figwheel-main.edn is valid \(ツ)/
[Figwheel] Compiling build dev to "target/public/cljs-out/dev-main.js"
[Figwheel] Successfully compiled build dev to "target/public/cljs-out/dev-main.js" in 1.526 seconds.
[Figwheel] Outputting main file: target/public/cljs-out/dev-main-auto-testing.js
[Figwheel] Watching paths: ("src") to compile build - dev
[Figwheel] Starting Server at 
[Figwheel] Starting REPL
Prompt will show when REPL connects to evaluation environment (i.e. a REPL hosting webpage)
Figwheel Main Controls:
          (figwheel.main/stop-builds id ...)  ;; stops Figwheel autobuilder for ids
          (figwheel.main/start-builds id ...) ;; starts autobuilder focused on ids
          (figwheel.main/reset)               ;; stops, cleans, reloads config, and starts autobuilder
          (figwheel.main/build-once id ...)   ;; builds source one time
          (figwheel.main/clean id ...)        ;; deletes compiled cljs target files
          (figwheel.main/status)              ;; displays current state of system
Figwheel REPL Controls:
          (figwheel.repl/conns)               ;; displays the current connections
          (figwheel.repl/focus session-name)  ;; choose which session name to focus on
In the cljs.user ns, controls can be called without ns ie. (conns) instead of (figwheel.repl/conns)
    Docs: (doc function-name-here)
    Exit: :cljs/quit
 Results: Stored in vars *1, *2, *3, *e holds last exception object
[Rebel readline] Type :repl/help for online help info
Opening URL 
Failed to open browser: 
No X11 DISPLAY variable was set, but this program performed an operation which requires it.

pez11:10:44

Failed to open browser and the X11 DISPLAY thing… So if the app is never opened in the browser you will not get a REPL connection, since that is where the REPL runs. Can you open http://localhost:9500 manually in a browser and see if you get a REPL then?

roelof11:10:22

I do that and normally I see the repl but not today

roelof11:10:20

I see the html appeat and nothing else seems to happen

roelof11:10:04

and no error messages in my console or the dev browser

roelof11:10:19

maybe put the project on github so you can try and see what happens ? @U0ETXRFEW

pez11:10:24

Do you have an earlier commit you can try, when things worked? The answer should be in the changes since then.

roelof11:10:22

nope, I deleted it and start all over again

roelof12:10:30

I have only changed this method

(defn update-output [_]
    (prn "event fired")
    (cond
      (and (= \C (get-input-target))
           (= \F (get-output-target)))
      (do (set-output-temp (c->f (get-input-temp)))
          (gdom/setTextContent display-unit-target "F"))
      (and (= \F (get-input-target))
           (= \C (get-output-target)))
      (do (set-output-temp (f->c (get-input-temp)))
          (gdom/setTextContent display-unit-target "C"))
      :else
      (do (set-output-temp (get-input-temp))
          (gdom/setTextContent display-unit-target(get-input-target)))))

roelof12:10:46

but i think there is nothing wrong with

pez12:10:15

It is probably something else, but you can rule out this function by making the function body empty. Seem only to be side-effecting, so already returns nil, I think…

roelof12:10:57

I rule it out and it is not that

roelof12:10:12

bummer, not even close to the solution

pez12:10:14

Try shortcurcuit the app so that it does nothing at all. Somewhere where it starts, do as little as possible to just ensure that you can see if it starts or not.

roelof12:10:00

hmm, I have to think how to do that here

(ns learn-cljs.temp-converter
  (:require [goog.dom :as gdom]
            [goog.events :as gevents]))

(defn f->c [deg-f]
  (/ (- deg-f 32) 1.8))

(defn c->f [deg-c]
  (+ (* deg-c 1.8) 32))

(def input-target (gdom/getElement "selectInputDegreeType"))
(def temp-input (gdom/getElement "inputDegree"))
(def output-target (gdom/getElement "convertedDegree"))
(def output-unit-target (gdom/getElement "selectConversionType"))
(def display-unit-target (gdom/getElement "convertedUnit"))

(defn get-input-temp []
  (js/parseInt (.-value temp-input)))

(defn set-output-temp [temp]
  (gdom/setTextContent output-target
                       (.toFixed temp 2)))

(defn get-input-target []
  (.-value input-target))

(defn get-output-target []
 (.-value output-target))

(defn update-output [_]
    (prn "event fired")
    (cond
      (and (= \C (get-input-target))
           (= \F (get-output-target)))
      (do (set-output-temp (c->f (get-input-temp)))
          (gdom/setTextContent display-unit-target "F"))
      (and (= \F (get-input-target))
           (= \C (get-output-target)))
      (do (set-output-temp (f->c (get-input-temp)))
          (gdom/setTextContent display-unit-target "C"))
      :else
      (do (set-output-temp (get-input-temp))
          (gdom/setTextContent display-unit-target(get-input-target)))))

(gevents/listen output-unit-target "change" update-output)

pez12:10:40

Commenting out the listener registration maybe…

roelof12:10:44

Tried and nothing changes

roelof13:10:13

is there another way we can find the culprit?

pez13:10:46

Do you have another, similar, project that works? Otherwise create one from scratch. If that works, you know that the infrastructure works. Then “lifting” over things from the broken project, piece by small piece, should find you the problem.

roelof13:10:49

I can make this project again with the original code

pez13:10:22

It’s awful that you don’t get any errors anywhere. I don’t understand why that happens. I haven’t used figwheel in a long time so am not the best person to advice on that particular thing. I can only offer general advice and that I share your frustration of getting stuck like that. It’s never fun when that happens!

pez13:10:58

> I can make this project again with the original code Yeah, it is like when you are lost during orienteering. Try find your way back to the last place where you could make the map match your surroundings. To keep running while lost only gets you more lost.

pez13:10:11

A trusty friend to quickly get you back to a working state is Git. commit often.

roelof13:10:47

that is wierd

roelof13:10:08

as soon as i copy my html to a new fresh project I see the same problem

roelof13:10:28


<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Convert Temperature</title>
    <link rel="icon" type="image/png" href="./assets/icon.png" />
    <link
      rel="stylesheet"
      href=""
    />

    <!-- -----------------------------Bootstrap 4.6----------------------------------------- -->
    <link
      rel="stylesheet"
      href=""
      integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l"
      crossorigin="anonymous"
    />

    <!-- -------------------------------Custom CSS Style---------------------------------------- -->
    <link rel="stylesheet" href="css/style.css" />
  </head>

  <body class="d-flex justify-content-center align-items-center min-vh-100">
    <div class="container">
      <div class="row">
        <div class="card-group col-12 col-md-10 offset-md-1 my-md-auto">
          <div class="card inputSection col-12 col-md-6">
            <div class="card-body">
              <form>
                <div class="row px-3">
                  <div class="col-12 col-md-11 px-4">
                    <span class="card-title d-block">Enter Temperature</span>
                    <label for="degreeInput" class="py-sm-2">Degree</label>
                    <div class="input-group">
                      <input
                        type="number"
                        class="form-control"
                        id="inputDegree"
                        name="inputDegree"
                        placeholder="Enter Degree"
                        value="0"
                      />
                      <div class="input-group-append">
                        <select class="form-control" id="selectInputDegreeType">
                          <option value="C" selected>&deg;C</option>
                          <option value="F">&deg;F</option>
                          <option value="K">K</option>
                        </select>
                      </div>
                    </div>
                    <label for="selectConversionType" class="py-sm-2"
                      >Convert In</label
                    >
                    <div class="input-group d-inline-block">
                      <div class="input-group-append">
                        <select class="form-control" id="selectConversionType">
                          <option value="F" selected>
                            Fahrenheit (&deg;F)
                          </option>
                          <option value="C">Celcius (&deg;C)</option>
                          <option value="K">Kelvin (K)</option>
                        </select>
                      </div>
                    </div>
                    <button
                      type="submit"
                      class="convertBtn btn btn-lg col-12 col-md-6 offset-md-3 mt-4 rounded-pill d-flex justify-content-center align-items-center text-white"
                    >
                      Convert
                    </button>
                  </div>
                </div>
              </form>
            </div>
          </div>
          <div class="card resultSection col-12 col-md-6">
            <div
              class="card-body d-flex justify-content-center align-items-center"
            >
              <div id="resultValueSection">
                <div id="convertedDegree">32</div>
                <h3 id="degree">&deg;</h3>
                <h3 id="convertedUnit">F</h3>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- -----------------------------JQuery Plugins------------------------------------------ -->
    <script
      src=""
      integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
      crossorigin="anonymous"
    ></script>
    <script
      src=""
      integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns"
      crossorigin="anonymous"
    ></script>

    <!-- -------------------------------Custom JS Script---------------------------------------- -->
  </body>
</html>

pez14:10:46

There is nothing in there bringing in your figwheel app, I think.

roelof14:10:44

you mean this part : <script src="cljs-out/dev-main.js" type="text/javascript"></script>

pez16:10:20

Yes, that part. Can’t see it in the html you pasted.

roelof16:10:31

Thanks, that was it

roelof16:10:42

finnaly the challenge solved

pez16:10:48

Awesome. I guess the silence from any error messages is explained as well. 😃

roelof16:10:59

sorry for the noise on this channel then

pez16:10:00

No problem. I am happy I could help! I don’t think it is noisy when we keep it in a thread.

roelof16:10:17

good Sunday

pez16:10:44

To you as well! ☀️

roelof16:10:48

here almost time for supper/dinner and then maybe see kids for halloween

pez16:10:55

Our smallest ones hope we will get some monsters visiting. We’ll see.

roelof16:10:32

exactly Where do you live. I live in the Netherlands

pez17:10:33

I live in a suburb south of Stockholm, Sweden. In a residential area by a lake. It’s pitch dark outside. We don’t have any street lights on the strip outside our house. Because I like to see the stars and planets better. But it has the downside that the small monsters think it is a bit scary to visit the house, so my youngest ones don’t get many (or even any) monster visits. 😃

roelof17:10:30

oke, I live in a small town in the east of the Netherlands

roelof19:10:31

today 3 kids ;'(

pez18:10:27

Dear Calva friends. Here’s a fun VSIX to put to some testing: https://15632-125431277-gh.circle-artifacts.com/0/tmp/artifacts/calva-2.0.223-689-clojuredocs-command-c09c9e54.vsix. It adds: • ClojureDocs examples in the hover-lookup of symbols. So that you can at a glance see neat ways and caveats about Clojure core-ish symbols. Each example have two buttons/links: ◦ To Rich Comment, prints the example to a rich comment below the top level form you are editing/viewing ◦ To Output Window, prints the example to the REPL/Output window • A command for printing all clojuredocs examples for the symbol under the cusror to a Rich Comment, default bound to ctrl+alt+r d (to go well with the command for opening a new rich comment block). • A command for printing all clojuredocs examples for the symbol under the cursor to the Output/REPL window, ctrl+alt+o d You can see earlier versions of this change in these tweets: • https://twitter.com/pappapez/status/1452325865933746185https://twitter.com/pappapez/status/1452409528511762444 Please help test this. This VSIX will work even better (more coverage) when the next version of clojure-lsp is released, but I like to test that it works and doesn’t misbehave with the current clojure-lsp as well, so please don’t wait with your testing! 🙏 ❤️

🎉 3
Pratik05:11:46

Just checked it out, the clojureDocs integration is awesome! is there any way to increase the hover space(or maybe have the docs in a new file itself?)

pez09:11:12

The hover are a bit tiny and flickery for this, unfortunately. You can use the commands for printing the examples to rich comments or the output window to get more room, and also play with the examples in the REPL.

pez09:11:08

If you haven’t upgraded Calva to 2.0.223, you should. Because this is now released, and there are some improvements since this VSIX. See #announcements