yokolet / clementine

Gem for ClojureScript on Rails Asset Pipeline
MIT License
123 stars 20 forks source link

Uncaught Error: No protocol method IWriter.-write defined for type undefined #4

Open evjan opened 11 years ago

evjan commented 11 years ago

When I try to follow the instructions at http://yokolet.blogspot.com.au/2012/10/clementine-gem-clojurescript-on-rails.html for my existing Rails site, I get the following error popping up in the Chrome console:

Uncaught Error: No protocol method IWriter.-write defined for type undefined:

Any ideas what can be done about this?

yokolet commented 11 years ago

Hmmm, I'm not sure what's happening.

Do you have any other exception messages? What options did you set? I'm guessing you tried on CRuby, right?

evjan commented 11 years ago

I switched to running on JRuby and the problem still persists.

I had no options set. When I set the following option

Clementine.options[:optimizations] = :whitespace

the problem seems to go away.

andrewvc commented 11 years ago

+1 on this, the cljs I'm running is straight from an example: (ns hello) (defn ^:export greet [n](str "Hello " n))

andrewvc commented 11 years ago

Oddly enough this doesn't seem to prevent execution shrugs (for the record I'm on jruby as well).

konrad-garus commented 11 years ago

Guys, I don't know what Clementine is, but I found this issue report while I was googling for the same error message. I found the solution, so I thought I should share.

In advanced compilation, among other things Closure renames functions. I was using jQuery, and Closure redefined $ - thus breaking code calling jQuery. The solution for me was to include jQuery externs in the compilation and make sure that my CLJS files actually use $.

I'm not sure if you're having issues with jQuery or something else, but your scenario is likely the same. You can catch the error in Firebug and see stacktrace to find it.