bhauman / lein-figwheel

Figwheel builds your ClojureScript code and hot loads it into the browser as you are coding!
Eclipse Public License 1.0
2.88k stars 209 forks source link

Warning when running Figwheel without cleaning #511

Open raxod502 opened 7 years ago

raxod502 commented 7 years ago

Relocated from https://github.com/reagent-project/reagent-template/issues/132

In short, if I run lein figwheel twice, without cleaning in between, then in the second session I get a compiler warning any time I try to access a variable—even though the variable is defined, and its value is correctly printed.

Here are the precise steps to reproduce, along with my version and OS information:

Temporary % neofetch
                -/+:.           raxod502@Radon-MBP-New.local
               :++++.           ----------------------------
              /+++/.            OS: OS X El Capitan 10.11.6 15G1212 x86_64
      .:-::- .+/:-``.::-        Model: MacBookPro11,3
   .:/++++++/::::/++++++/:`     Kernel: 15.6.0
 .:///////////////////////:`    Uptime: 23 hours, 36 minutes
 ////////////////////////`      Packages: 365
-+++++++++++++++++++++++`       Shell: zsh 5.2
/++++++++++++++++++++++/        DE: Aqua
/sssssssssssssssssssssss.       WM: Quartz Compositor
:ssssssssssssssssssssssss-      Terminal: iTerm2
 osssssssssssssssssssssssso/`   CPU: Intel i7-4980HQ (8) @ 2.80GHz
 `syyyyyyyyyyyyyyyyyyyyyyyy+`   GPU: Intel Iris Pro, NVIDIA GeForce GT 750M
  `ossssssssssssssssssssss/     Memory: 3187MB / 16384MB
    :ooooooooooooooooooo+.      ​
     `:+oo+/:-..-:/+o+/-        ████████████████████████
                                ​

Temporary % rm ~/.lein/profiles.clj
Temporary % lein --version
Leiningen 2.7.1 on Java 1.8.0_112 Java HotSpot(TM) 64-Bit Server VM
Temporary % lein new reagent funk
Generating fresh 'lein new' Reagent project.
Temporary % cd funk
funk % lein figwheel
Figwheel: Cutting some fruit, just a sec ...
Figwheel: Validating the configuration found in project.clj
Figwheel: Configuration Valid :)
Figwheel: Starting server at http://0.0.0.0:3449
Figwheel: Watching build - app
Figwheel: Cleaning build - app
Compiling "target/cljsbuild/public/js/app.js" from ["src/cljs" "src/cljc" "env/dev/cljs"]...
Successfully compiled "target/cljsbuild/public/js/app.js" in 9.21 seconds.
Figwheel: Starting CSS Watcher for paths  ["resources/public/css"]
Figwheel: Starting nREPL server on port: 7002
Launching ClojureScript REPL for build: app
Figwheel Controls:
          (stop-autobuild)                ;; stops Figwheel autobuilder
          (start-autobuild [id ...])      ;; starts autobuilder focused on optional ids
          (switch-to-build id ...)        ;; switches autobuilder to different build
          (reset-autobuild)               ;; stops, cleans, and starts autobuilder
          (reload-config)                 ;; reloads build config and resets autobuild
          (build-once [id ...])           ;; builds source one time
          (clean-builds [id ..])          ;; deletes compiled cljs target files
          (print-config [id ...])         ;; prints out build configurations
          (fig-status)                    ;; displays current state of system
  Switch REPL build focus:
          :cljs/quit                      ;; allows you to switch REPL to another build
    Docs: (doc function-name-here)
    Exit: Control+C or :cljs/quit
 Results: Stored in vars *1, *2, *3, *e holds last exception object
Prompt will show when Figwheel connects to your application
To quit, type: :cljs/quit
cljs.user=> funk.core/home-page
#object[funk$core$home_page "function funk$core$home_page(){
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"div","div",1057191632),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"h2","h2",-372662728),"Welcome to funk"], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"div","div",1057191632),new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"a","a",-2123407586),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"href","href",-793805698),"/about"], null),"go to about page"], null)], null)], null);
}"]
cljs.user=> ^D
funk % lein figwheel
Figwheel: Cutting some fruit, just a sec ...
Figwheel: Validating the configuration found in project.clj
Figwheel: Configuration Valid :)
Figwheel: Starting server at http://0.0.0.0:3449
Figwheel: Watching build - app
Compiling "target/cljsbuild/public/js/app.js" from ["src/cljs" "src/cljc" "env/dev/cljs"]...
Successfully compiled "target/cljsbuild/public/js/app.js" in 1.323 seconds.
Figwheel: Starting CSS Watcher for paths  ["resources/public/css"]
Figwheel: Starting nREPL server on port: 7002
Launching ClojureScript REPL for build: app
Figwheel Controls:
          (stop-autobuild)                ;; stops Figwheel autobuilder
          (start-autobuild [id ...])      ;; starts autobuilder focused on optional ids
          (switch-to-build id ...)        ;; switches autobuilder to different build
          (reset-autobuild)               ;; stops, cleans, and starts autobuilder
          (reload-config)                 ;; reloads build config and resets autobuild
          (build-once [id ...])           ;; builds source one time
          (clean-builds [id ..])          ;; deletes compiled cljs target files
          (print-config [id ...])         ;; prints out build configurations
          (fig-status)                    ;; displays current state of system
  Switch REPL build focus:
          :cljs/quit                      ;; allows you to switch REPL to another build
    Docs: (doc function-name-here)
    Exit: Control+C or :cljs/quit
 Results: Stored in vars *1, *2, *3, *e holds last exception object
Prompt will show when Figwheel connects to your application
To quit, type: :cljs/quit
cljs.user=> funk.core/home-page
----  Compiler Warning on   <cljs form>   line:1  column:1  ----

  Use of undeclared Var funk.core/home-page

  1  funk.core/home-page
     ^---

----  Compiler Warning  ----
#object[funk$core$home_page "function funk$core$home_page(){
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"div","div",1057191632),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"h2","h2",-372662728),"Welcome to funk"], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"div","div",1057191632),new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"a","a",-2123407586),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"href","href",-793805698),"/about"], null),"go to about page"], null)], null)], null);
}"]
cljs.user=>

Additional info:

raxod502 commented 7 years ago

See https://github.com/reagent-project/reagent-template/issues/132#issuecomment-272031671.

bhauman commented 7 years ago

This is really a clojurescript analysis caching thing. Somehow you are getting an clojurescript anaylsis cache that is stale and doesn't include your symbol. But this is not a figwheel problem per se.

A couple of things can happen to where your javascript runtime env and your anaylsis cache get out of sync.

One thing to remember is to do a hard shift reload even if your browser devtools have caching disabled. The sucker caches anyway.

If you save the said file its symbols will get into the analysis and this will go away.

On Wed, Jan 11, 2017 at 7:17 PM, Radon Rosborough notifications@github.com wrote:

See reagent-project/reagent-template#132 (comment) https://github.com/reagent-project/reagent-template/issues/132#issuecomment-272031671 .

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bhauman/lein-figwheel/issues/511#issuecomment-272037916, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAKQHmdttW8rJ3oVI_sgCKtiFocn2Xnks5rRXE1gaJpZM4LhMwQ .

raxod502 commented 7 years ago

It seems like this is definitely a bug somewhere, though. Should I attempt to reproduce the issue without Figwheel? I'm not sure how to do that.

bhauman commented 7 years ago

I understand that it's strange and can be disconcerting but I would ask that you get some more experience before tracking this down. It may in fact be a bug but there is a bunch of knowledge you need to understand so that you actively help us determine what's going on.

For example reproduce the behavior with a lein new figwheel test-repl project.

But if you are new to clojurescript I would let this go for now and just know that this is entirely normal and not necessarily a bug and it is very dependent on how you set up your project.

Sent from my iPhone

On Jan 11, 2017, at 8:49 PM, Radon Rosborough notifications@github.com wrote:

It seems like this is definitely a bug somewhere, though. Should I attempt to reproduce the issue without Figwheel? I'm not sure how to do that.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.