diff options
author | Teddy Wing | 2017-05-09 20:30:02 +0200 |
---|---|---|
committer | Teddy Wing | 2017-05-09 20:30:02 +0200 |
commit | 27eaa02d28cc07ceb59a51529100ee4b7016a38f (patch) | |
tree | 05164fda48d2815345911af43bc9f9377b188e2f /lib | |
parent | 67c870705085d44b99e9d0ca1361f9d62c133715 (diff) | |
download | dbshell-rails-27eaa02d28cc07ceb59a51529100ee4b7016a38f.tar.bz2 |
rails.rb: Check that `Rake` is loaded before loading Rake task
Was getting an exception when trying to start the development server on
a Rails 5.0.1 app:
$ bundle exec rails s
dbshell-rails/lib/dbshell/rails/tasks/dbshell.rake:5:in `<top (required)>': undefined method `desc' for main:Object (NoMethodError)
from .../ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
from .../ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `block in load'
from .../ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from .../ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
from dbshell-rails/lib/dbshell/rails.rb:3:in `<top (required)>'
from .../ruby/gems/2.3.0/gems/bundler-1.14.2/lib/bundler/runtime.rb:105:in `require'
from .../ruby/gems/2.3.0/gems/bundler-1.14.2/lib/bundler/runtime.rb:105:in `rescue in block in require'
from .../ruby/gems/2.3.0/gems/bundler-1.14.2/lib/bundler/runtime.rb:82:in `block in require'
from .../ruby/gems/2.3.0/gems/bundler-1.14.2/lib/bundler/runtime.rb:75:in `each'
from .../ruby/gems/2.3.0/gems/bundler-1.14.2/lib/bundler/runtime.rb:75:in `require'
from .../ruby/gems/2.3.0/gems/bundler-1.14.2/lib/bundler.rb:107:in `require'
from rails-app/config/application.rb:7:in `<top (required)>'
from .../ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:88:in `require'
from .../ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:88:in `block in server'
from .../ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
from .../ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
from .../ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from .../ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from rails-app/bin/rails:9:in `require'
from rails-app/bin/rails:9:in `<top (required)>'
from .../ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `load'
from .../ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `call'
from .../ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/client/command.rb:7:in `call'
from .../ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/client.rb:30:in `run'
from .../ruby/gems/2.3.0/gems/spring-2.0.1/bin/spring:49:in `<top (required)>'
from .../ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `load'
from .../ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `<top (required)>'
from rails-app/bin/spring:15:in `require'
from rails-app/bin/spring:15:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
Looks like Rails is trying to load the task without Rake, and the
interpreter doesn't know what to do with the Rake methods.
Follow the pattern in
https://github.com/paulelliott/fabrication/blob/b470cd817e1973c14e3253cd76606cf934942ca1/lib/fabrication.rb
and guard the load with a check for whether `Rake` is defined.
This makes the server start up and work as expected again.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dbshell/rails.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/dbshell/rails.rb b/lib/dbshell/rails.rb index 0e18f6b..1b60b48 100644 --- a/lib/dbshell/rails.rb +++ b/lib/dbshell/rails.rb @@ -1,6 +1,8 @@ require 'dbshell/rails/version' -load 'dbshell/rails/tasks/dbshell.rake' +if defined?(Rake) + load 'dbshell/rails/tasks/dbshell.rake' +end module DBShell module Rails |