Search code examples
ruby-on-railsrubyrubygemsrake

Ruby file: "ruby_executable_hooks" syntax error


I am trying to run the command rake db:migrate but the terminal is complaining about a possible syntax error in the file ruby_executable_hooks. I found this reference but did not help me to solve the problem. On the first line of the file it looks like title = "ruby #{ARGV*" "}" is causing the problem as the double quotes are not escaped correctly. I have tried different combinations of escaping but still no luck. So now I am not sure if the problem is really related to escaping issues or something else. Many thanks

Please see bellow the ruby_executable_hooks file

  title = "ruby #{ARGV*" "}"
  $0    = ARGV.shift
  Process.setproctitle(title) if Process.methods.include?(:setproctitle)

  require 'rubygems'

  begin
    require 'executable-hooks/hooks'
    Gem::ExecutableHooks.run($0)
    rescue LoadError
    warn "unable to load executable-hooks/hooks" if ENV.key?
   ('ExecutableHooks_DEBUG')
  end

  eval File.read($0), binding, $0

Error message:

 /Users/username/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `eval':
 /Users/username/.rvm/rubies/ruby-2.2.3/bin/rake:4: syntax error, unexpected
 tSTRING_BEG, expecting keyword_do or '{' or '(' (SyntaxError)
 exec "$bindir/ruby" -x "$0" "$@"
                    ^
 from /Users/username/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in
 `<main>'

Solution

  • Found the solution for this problem

    1 - delete the rake version from your system
    2 - bundle install rake
    3 - rake db:drop:all
    4 - rake db:create:all
    5 - rake db:migrate
    

    For some reason when I first used the command rake db:migrate it corrupted the ruby_executable_hooks file (no idea why). Hope this will help somebody.