Search code examples
javascriptruby-on-railsrubyruby-on-rails-4uglifier

Rails server fails because of uglifier gem


When I try to load rails server, I get this error:

/home/jared/.rvm/gems/ruby-head/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
from /home/jared/.rvm/gems/ruby-head/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/jared/.rvm/gems/ruby-head/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
from /home/jared/.rvm/gems/ruby-head/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
from /home/jared/.rvm/gems/ruby-head/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
from /home/jared/.rvm/gems/ruby-head/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
from /home/jared/.rvm/gems/ruby-head/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
from /home/jared/thirteenthagecharbuilder/config/application.rb:7:in `<top (required)>'
from /home/jared/.rvm/gems/ruby-head/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:78:in `require'
from /home/jared/.rvm/gems/ruby-head/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from /home/jared/.rvm/gems/ruby-head/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /home/jared/.rvm/gems/ruby-head/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:75:in `server'
from /home/jared/.rvm/gems/ruby-head/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/jared/.rvm/gems/ruby-head/gems/railties-4.2.5.1/lib/rails/commands.rb:17:in `<top (required)>'
from /home/jared/thirteenthagecharbuilder/bin/rails:9:in `require'
from /home/jared/thirteenthagecharbuilder/bin/rails:9:in `<top (required)>'
from /home/jared/.rvm/gems/ruby-head/gems/spring-1.6.2/lib/spring/client/rails.rb:28:in `load'
from /home/jared/.rvm/gems/ruby-head/gems/spring-1.6.2/lib/spring/client/rails.rb:28:in `call'
from /home/jared/.rvm/gems/ruby-head/gems/spring-1.6.2/lib/spring/client/command.rb:7:in `call'
from /home/jared/.rvm/gems/ruby-head/gems/spring-1.6.2/lib/spring/client.rb:28:in `run'
from /home/jared/.rvm/gems/ruby-head/gems/spring-1.6.2/bin/spring:49:in `<top (required)>'
from /home/jared/.rvm/gems/ruby-head/gems/spring-1.6.2/lib/spring/binstub.rb:11:in `load'
from /home/jared/.rvm/gems/ruby-head/gems/spring-1.6.2/lib/spring/binstub.rb:11:in `<top (required)>'
from /home/jared/thirteenthagecharbuilder/bin/spring:13:in `require'
from /home/jared/thirteenthagecharbuilder/bin/spring:13:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'

I have searched this question a lot, and every answer on stackoverflow I spy says "install nodejs", which I have done, and this hasn't fixed anything for me.

jared@machine:~$ nodejs -v
v0.10.29
jared@machine:~$ node -v
v4.4.4
jared@machine:~$ npm --version
2.15.1
jared@machine:~$ echo $PATH
/home/jared/.rvm/gems/ruby-head/bin:/home/jared/.rvm/gems/ruby-head@global/bin:/home/jared/.rvm/rubies/ruby-head/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/jared/.rvm/bin:/home/jared/.rvm/bin:/home/jared/.rvm/bin:/usr/local/nodejs/bin

I have also added therubyracer gem to my gemfile. I bundle installed. At the end of my rope here, because, well, honestly the only advice I have seen from anyone regarding this problem is install nodejs, and usually the thread is marked as solved based on this, no further things I could try.

Running rails 4.2.5.1 on debian 8 (jessie) 64-bit, using rvm, ruby 2.4.0 installed.

EDIT: Since no one seems to want to take a crack at this, here is some more info from a rails dev I know who was also unable to troubleshoot the problem:

Adding

$stderr.puts e.inspect

Right above line 80 yields:

#<TypeError: wrong argument type Class (expected Module)>

And doing a search for uglifier to see if a class is being referenced somewhere in the project where it shouldn't be results in:

jared@machine:~/thirteenthagecharbuilder$ grep -r uglifier /home/jared/thirteenthagecharbuilder/
/home/jared/thirteenthagecharbuilder/Gemfile.lock:    uglifier (3.0.0)
/home/jared/thirteenthagecharbuilder/Gemfile.lock:  uglifier (>= 2.7.1)
/home/jared/thirteenthagecharbuilder/Gemfile:gem 'uglifier', '>= 2.7.1'
/home/jared/thirteenthagecharbuilder/config/environments/production.rb:  config.assets.js_compressor = :uglifier

And lastly (for now), Line 7 of config/application.rb says

Bundler.require(*Rails.groups)

Solution

  • So, I nuked ruby, long story short. I use rvm, so removing it was pretty easy, and I hadn't gotten much work done on the project anyway. So rvm and associated gems gone. I re-installed rvm, but this time used the option to install rails as well:

    https://rvm.io/rvm/install

    \curl -sSL https://get.rvm.io | bash -s stable --rails
    

    This got me up and running. So I guess my best advice is to use the rails flag when using rvm.