Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I use this gem with backbone-rails gem ? #30

Closed
milushov opened this issue Feb 29, 2012 · 27 comments
Closed

Can I use this gem with backbone-rails gem ? #30

milushov opened this issue Feb 29, 2012 · 27 comments

Comments

@milushov
Copy link

I just add two gems in my Gemfile and create one template to test and.. it doesn't work
Gemfile

ExecJS::ProgramError in Main#index

Showing C:/preject/app/views/layouts/application.html.haml where line #6 raised:

TypeError: Object doesn't support this property or method
(in C:/preject/app/assets/javascripts/backbone/templates/profile/index.jst.hamlc)

In index.jst.hamlc just:
.qwe test123

@netzpirat
Copy link
Collaborator

I've used both gems in a project without problems. What JS runtime are you using? I suggest to test with the Ruby racer by uncomment gem 'therubyracer' or install NodeJS.

@milushov
Copy link
Author

I tried to install therubyracer gem: error
I think it's because my platform is windows.

@netzpirat
Copy link
Collaborator

According to the error message it needs Python for building libv8. The other option is to use install NodeJS, they have a windows installer. You can verify the ExecJS runtime in the console:

$ irb
> require 'execjs'
> ExecJS.runtime
=> #<ExecJS::RubyRacerRuntime:0x007fae2b0ba6b8>

@milushov
Copy link
Author

Ok, I installed NodeJS
verify the ExecJS
But, error is still exist.

@netzpirat
Copy link
Collaborator

Somehow the output here is missing the info, but I got it in the notification email:

irb(main):001:0> require 'execjs'
=> true
irb(main):002:0> ExecJS.runtime
=> #<ExecJS::ExternalRuntime:0x2386db8 @name="JScript", @command="cscript //E:jscript //Nologo //U", @runner_path="C:/Ruby193/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs/support/jscript_runner.js", @test_args=nil, @test_match=nil, @encoding="UTF-16LE", @binary="cscript //E:jscript //Nologo //U">
irb(main):003:0> ExecJS.runtime

You still have JScript as engine selected. Make sure Node is in your path, so it can be detected.

@milushov
Copy link
Author

Node is in your path
How to realize it? I'am newbie =)

@netzpirat
Copy link
Collaborator

%PATH% is a list of directories where Windows will search for executables, so you have to add the location where the node command can be found.

@milushov
Copy link
Author

But there already is a reference to nodeJS: Files \ Git \ cmd; C: \ Users \ roma \ AppData \ Roaming \ npm; C: \ Program Files \ nodejs \

@netzpirat
Copy link
Collaborator

How do you start your server? From the command line or an editor?

@milushov
Copy link
Author

From the command line

@netzpirat
Copy link
Collaborator

Make sure the path is right in Ruby and the node runtime is available:

$ pry
[1] pry(main)> ENV['PATH']
=> "/usr/local/bin:/usr/local/share/npm/bin:/Users/michi/node_modules/.bin:/Users/michi/.bin:/Users/michi/.rvm/gems/ruby-1.9.3-p125/bin:/Users/michi/.rvm/gems/ruby-1.9.3-p125@global/bin:/Users/michi/.rvm/rubies/ruby-1.9.3-p125/bin:/Users/michi/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/share/npm/bin"
[2] pry(main)> require 'execjs'
=> true
[3] pry(main)> ExecJS::Runtimes::Node.available?
=> true

According to ExecJS, JScript is the least desired runtime, guess they have good reason to do so.

If you still have problem getting the node runner recognized, have a look at the relevant lines for locating it in ExecJS.

@netzpirat
Copy link
Collaborator

Have you found a solution?

@milushov
Copy link
Author

milushov commented Mar 1, 2012

ExecJS::Runtimes::Node.available? return true
but libv8 gem is not established

appears not just me: 1 2 3

@netzpirat
Copy link
Collaborator

You're mixing the runtimes. libv8 is a dependency for the Ruby racer, but when you've NodeJS as runtime, you don't need the Ruby racer, so you can uncomment gem "therubyracer" in your Gemfile.

@milushov
Copy link
Author

milushov commented Mar 1, 2012

uncomment gem "therubyracer" ? it's uncommented

@netzpirat
Copy link
Collaborator

Have you run bundle after uncommenting? You can see which Gem has it as dependency within Gemfile.lock.

@milushov
Copy link
Author

milushov commented Mar 1, 2012

Have you run bundle after uncommenting? yes and Gemfile.lock

@netzpirat
Copy link
Collaborator

It still tries to install the Ruby Racer. Try bundle update.

@milushov
Copy link
Author

milushov commented Mar 1, 2012

same shit

@netzpirat
Copy link
Collaborator

Sorry, you should comment it, since it's not needed.

@milushov
Copy link
Author

milushov commented Mar 1, 2012

lol =)

@netzpirat
Copy link
Collaborator

There should be no .hamlc extension anymore after it has been compiled. How did you name your template?

@milushov
Copy link
Author

milushov commented Mar 1, 2012

Template why it is transformed into index.hamlc.js
How did you name your template? index.jst.hamlc

@netzpirat
Copy link
Collaborator

You may have a unicorn in between your browser and the server, that dislocates the template with a space-time bending. It's just a guess, since I don't have more information.

@netzpirat
Copy link
Collaborator

Since I don't have the patience anymore to ask thousand of questions to get all the needed information that let me help you, I suggest that you put the project on GitHub and send me the link, so I can have a quick look.

@milushov
Copy link
Author

milushov commented Mar 1, 2012

ok, i wrote you private message

@netzpirat
Copy link
Collaborator

Thanks, I cloned your repo and found the problem: You had the templates index.jst.ejs and index.jst.hamlc in the same folder. This is not possible, since both files will be compiled to index.js. I renamed index.jst.hamlc simply to index2.jst.hamlc and the template was compiled fine and server through the asset pipeline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants