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

Problem with Erubis #347

Closed
expez opened this issue Feb 25, 2014 · 17 comments
Closed

Problem with Erubis #347

expez opened this issue Feb 25, 2014 · 17 comments

Comments

@expez
Copy link

expez commented Feb 25, 2014

Upon syntax checking a .erb file I get the following error:

Checker eruby-erubis returned non-zero exit code 1, but no errors from output: An exception occurred running /home/expez/.rvm/gems/rbx-head@flix/bin/ruby_executable_hooks:

    no such file to load -- compiler (LoadError)

Backtrace:

�[0;31m       Rubinius::CodeLoader#load_error at kernel/common/code_loader.rb:447�[0m
�[0;34m  Rubinius::CodeLoader#resolve_require_path at kernel/common/code_loader.rb:431�[0m
�[0;34m   { } in Rubinius::CodeLoader#require at kernel/common/code_loader.rb:103�[0m
�[0;34m                  Rubinius.synchronize at kernel/bootstrap/rubinius.rb:137�[0m
�[0;34m          Rubinius::CodeLoader#require at kernel/common/code_loader.rb:102�[0m
�[0;34m          Rubinius::CodeLoader.require at kernel/common/code_loader.rb:237�[0m
�[0;34m          Kernel(Erubis::Main)#require at kernel/common/kernel.rb:705�[0m
            Erubis::Main#check_syntax at /home/expez/.rvm/gems/rbx-head@flix
                                         /gems/erubis-2.7.0/lib/erubis
                                         /main.rb:490�[0m
               Erubis::Main#do_action at /home/expez/.rvm/gems/rbx-head@flix
                                         /gems/erubis-2.7.0/lib/erubis
                                         /main.rb:195�[0m
          { } in Erubis::Main#execute at /home/expez/.rvm/gems/rbx-head@flix
                                         /gems/erubis-2.7.0/lib/erubis
                                         /main.rb:173�[0m
�[0;34m                            Array#each at kernel/bootstrap/array.rb:66�[0m
                 Erubis::Main#execute at /home/expez/.rvm/gems/rbx-head@flix
                                         /gems/erubis-2.7.0/lib/erubis
                                         /main.rb:168�[0m
                    Erubis::Main.main at /home/expez/.rvm/gems/rbx-head@flix
                                         /gems/erubis-2.7.0/lib/erubis
                                         /main.rb:43�[0m
                    Object#__script__ at /home/expez/.rvm/gems/rbx-head@flix
                                         /gems/erubis-2.7.0/bin/erubis:10�[0m
�[0;34m                   Kernel(Object)#load at kernel/common/kernel.rb:447�[0m
             { } in Object#__script__ at /home/expez/.rvm/gems/rbx-head@flix/bin
                                         /erubis:23�[0m
�[0;34m Rubinius::BlockEnvironment#call_on_instance at kernel/common
                                                /block_environment.rb:53�[0m
�[0;34m                   Kernel(Object)#eval at kernel/common/eval.rb:176�[0m
                    Object#__script__ at /home/expez/.rvm/gems/rbx-head@flix/bin
                                         /ruby_executable_hooks:15�[0m
�[0;34m      Rubinius::CodeLoader#load_script at kernel/delta/code_loader.rb:66�[0m
�[0;34m      Rubinius::CodeLoader.load_script at kernel/delta/code_loader.rb:152�[0m
�[0;34m               Rubinius::Loader#script at kernel/loader.rb:649�[0m
�[0;34m                 Rubinius::Loader#main at kernel/loader.rb:831�[0m

Checker definition probably flawed.

It looks like Erubis is called correctly but a require statement during execution fails?

@swsnr
Copy link
Contributor

swsnr commented Feb 25, 2014

You seem to be using RVM. Did you setup Emacs to use your RVM environment?

@expez
Copy link
Author

expez commented Feb 25, 2014

  (rvm-activate-corresponding-ruby)

in my ruby-mode-hook. rvm--current-ruby is set to "rbx-head". It looks to me like this part is working correctly as the stacktrace indicates that the erubis that is used is the one for the correct gemset.

@swsnr
Copy link
Contributor

swsnr commented Feb 25, 2014

@expez I have no idea then. I do not use Ruby, and have no clue of its inner workings.

@yasuyk Can you comment?

@expez
Copy link
Author

expez commented Feb 25, 2014

The problem is with erubis itself. The latest version, version 2.7, is from 2011. In the Ruby world where stuff changes just for the sake of novelty that's a long time. If anyone stumbles upon this problem here's the diff that solved it:

diff -u -L /home/expez/.rvm/gems/rbx-head\@flix/gems/erubis-2.7.0/lib/erubis/main.rb -L \#\<buffer\ main.rb\> /home/expez/.rvm/gems/rbx-head\@flix/gems/erubis-2.7.0/lib/erubis/main.rb /tmp/buffer-content-15168ngi
--- /home/expez/.rvm/gems/rbx-head@flix/gems/erubis-2.7.0/lib/erubis/main.rb
+++ #<buffer main.rb>
@@ -487,12 +487,12 @@

     if defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx"
       def check_syntax(filename, src)
-        require 'compiler'
+        require 'rubinius/compiler'
         verbose = $VERBOSE
         msg = nil
         begin
           $VERBOSE = true
-          Rubinius::Compiler.compile_string(src, filename)
+          Rubinius::ToolSet.current::TS::Compiler.compile_string(src, filename)
         rescue SyntaxError => ex
           ex_linenum = ex.line
           linenum = 0

I also had to install the rubinius-compiler gem.

I tried looking for another erb syntax checker, but couldn't find one. Does others exist, @yasuyk? I think Flycheck should have checkers that work out of the box for all the major ruby implementations (MRI, JRuby and Rubinius)

@yasuyk
Copy link
Contributor

yasuyk commented Feb 25, 2014

@expez Hi,

AFAIK, there is no other erb syntax checker. IMO, It is the bug of erubis, so erubis should fix it.

@yasuyk
Copy link
Contributor

yasuyk commented Feb 25, 2014

By the way, why doesn't anyone send above patch to erubis?

@yasuyk
Copy link
Contributor

yasuyk commented Feb 25, 2014

@expez @lunaryorn I have to go to work from now. I will participate in this discussion again after half a day. Sorry.

@swsnr
Copy link
Contributor

swsnr commented Feb 26, 2014

@yasuyk Take all the time you need.

@swsnr swsnr added bug and removed invalid labels Feb 26, 2014
@expez
Copy link
Author

expez commented Feb 26, 2014

Pull request with fix opened here: kwatch/erubis#3

The tests for erubis are failing when I run them on ruby 2.1.1, so I'm guessing this software is no longer maintained.

@yasuyk
Copy link
Contributor

yasuyk commented Feb 26, 2014

@lunaryorn @expez I got home!

@expez Great! Thank you for sending a patch.

@expez
Copy link
Author

expez commented Feb 26, 2014

@yasuyk I still can't get erubis to work. Should I use it through rvm, and install it as a gem dependency in my project, or as a global gem?

@yasuyk
Copy link
Contributor

yasuyk commented Feb 26, 2014

@expez You use rubinius with rvm, right? I always use CRuby with rbenv, and I have never used rubinius or rvm. I will try to reproduce it with rubinius and rvm.

@expez
Copy link
Author

expez commented Feb 26, 2014

@yasuyk I got it working, I was having some troubles with rvm. Thanks for your help!

@expez expez closed this as completed Feb 26, 2014
@yasuyk
Copy link
Contributor

yasuyk commented Feb 26, 2014

@expez I glad to hear that!

@mijoharas
Copy link

hi @expez, how did you sort your problem out? I have a similar problem with MRI (I sometimes use rubinius too though) and I use RVM as well:

Checker eruby-erubis returned non-zero exit code 1, but no errors from output: /home/michael/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'erubis' (>= 0) among 16 total gem(s) (Gem::LoadError)
    from /home/michael/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:309:in `to_spec'
    from /home/michael/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in `gem'
    from /home/michael/.rvm/gems/ruby-2.1.0/bin/erubis:22:in `<main>'
    from /home/michael/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `eval'
    from /home/michael/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `<main>'

and similarly, I have tried inserting a hook for ruby mode such as:

(add-hook 'ruby-mode-hook
          (lambda () (rvm-activate-corresponding-ruby)))

Any advice on how you managed to resolve the problem would be greatly appreciated.

@mijoharas
Copy link

Also, I suspect it is some kind or rvm issue, but as far as I can tell I have it correctly configured, but I definitely have more than 16 gems, does anyone have any idea how I would be able to test where this is trying to search for dependencies?
The paths (from which the code is called) seem to be correct though...

@mijoharas
Copy link

adding these to my emacs file seems to have fixed it (as far as I can tell), so I assume I had rvm misconfigured in my emacs, thanks again for a great package.

(require 'rvm)
(rvm-use-default)

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

No branches or pull requests

4 participants