2

I'm learning rails. I downloaded the code from https://github.com/diaspora/diaspora but it can't run. It's the error codes:

/home/a1/.rvm/rubies/ruby-2.1.7/web/diaspora/config/environments/development.rb:42:in `block in <top (required)>': uninitialized constant TurboDevAssets (NameError)
    from /home/a1/.rvm/gems/ruby-2.1.7/gems/railties-4.2.6/lib/rails/railtie.rb:210:in `instance_eval'
    from /home/a1/.rvm/gems/ruby-2.1.7/gems/railties-4.2.6/lib/rails/railtie.rb:210:in `configure'
    from /home/a1/.rvm/gems/ruby-2.1.7/gems/railties-4.2.6/lib/rails/railtie.rb:182:in `configure'
    from /home/a1/.rvm/rubies/ruby-2.1.7/web/diaspora/config/environments/development.rb:1:in `<top (required)>'

The config/environments/development.rb is:

Diaspora::Application.configure do
    [...]
    # Speed up asset serving
    config.middleware.insert 0, TurboDevAssets
 end

How to resolve the problem?

Maen
  • 10,603
  • 3
  • 45
  • 71
lilyxue
  • 23
  • 2

2 Answers2

2

Open your Gemfile and make sure this line is in there:

  gem "turbo_dev_assets", "0.0.2"

If it is but you're getting that error move that line outside a conditional or to one of the conditional sections where you know it will get picked up when you run the command:

RAILS_ENV=development bin/bundle install --deployment --with "development test postgresql"

Then verify in the output of that command that you see this line:

Installing turbo_dev_assets 0.0.2

This should resolve the error:

Name error ,uninitialized constant TurboDevAssets (NameError)
senya
  • 984
  • 12
  • 20
Kaleb
  • 591
  • 4
  • 17
  • 1
    The `--jobs $(nproc)` there is a bit misleading. It is not necessary for the task and, also, `nproc` only exists in Linux systems – Daniel Apr 06 '17 at 02:15
  • 1
    Thanks @Daniel, I have edited the answer to remove the --jobs $(nproc), a result of copy/paste on Ubuntu that I overlooked. I did not account for "portability". Thanks! – Kaleb Apr 07 '17 at 17:36
  • The command `RAILS_ENV=development bin/bundle install --deployment --with development --with test --with postgresql` doesn't work as expected with modern bundler, you actually have to run `RAILS_ENV=development bin/bundle install --deployment --with development test postgresql`. I tried to edit the post twice, but my edit was rejected with no explanation – senya Jun 28 '18 at 14:56
  • @senya your solution works for modern bundler but is not portable to older bundler, the behavior has change and as such should be place in a comment not a global edit to the entire solution! Cheers. -K – Kaleb Jun 28 '18 at 20:46
  • @Kaleb I asked on the Bundler official Slack channel and they told me that multiple `--with` never was officially supported behavior. [Screenshot](https://framapic.org/nAOfJrEJjtEz/AGrzZCU1xCkl.png). – senya Jul 01 '18 at 18:54
0

You must run bundle install.

TurboDevAssets is a gem within the gemfile:

  gem "turbo_dev_assets", "0.0.2"

Bundle install will setup it up.

fabriciofreitag
  • 2,843
  • 22
  • 26
  • What he means here is to add that line to the "Gemfile". It should already be in the "development" section but if it is not loading try moving it to a section you know will run it or just move it outside all conditions so it is forced to load. Then re-run the command: RAILS_ENV=development bin/bundle install --jobs $(nproc) --deployment --with development --with test --with postgresql – Kaleb Nov 19 '16 at 19:36