Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

The dbconsole can't exec the db command successfully.

#1488

System:

Microsoft Windows XP [Version 5.1.2600] Rails 2.2.2 gem 1.3.1 PATH=D:\bin\Ruby\1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;

Steps:

  1. Put sqlite3.exe and sqlite3.dll in the ruby bin dir.
  2. Ensure the ruby bin dir is in PATH.
  3. Create a rails app with all default options.

>rails demo
  1. Invoke the dbconsole

>cd demo
>ruby script\dbconsole

and the I got the follow output:


D:/bin/Ruby/1.8/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/dbconsole.rb:64:in `exec': No such file or directory - sqlite3.exe (Errno::ENOENT)
        from D:/bin/Ruby/1.8/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/dbconsole.rb:64
        from D:/bin/Ruby/1.8/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from D:/bin/Ruby/1.8/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from script/dbconsole:3

Suggested solution:

The gems\rails-2.2.2\lib\commands\dbconsole.rb (22): find_cmd function would return the full path of the db command.

This find_cmd works fine for me. (Sorry, I use Windows that don't have a easy-to-use git)


def find_cmd(*commands)
  dirs_on_path = ENV['PATH'].to_s.split(File::PATH_SEPARATOR)
  commands += commands.map{|cmd| "#{cmd}.exe"} if RUBY_PLATFORM =~ /win32/

  full_path_command = nil
  found = commands.detect do |cmd|
    dir = dirs_on_path.detect do |path|
      full_path_command = File.join(path, cmd)
      File.executable? full_path_command
    end
  end
  found ? full_path_command : abort("Couldn't find database client: #{commands.join(', ')}. Check your $PATH and try again.")
end

Reported by xpol · November 28th, 2008 @ 09:13 AM

State: committed
Milestone: 2.3.4
Assigned to: Pratik Pratik
Importance: Medium

Activity

  1. paolo
    paolo

    Hi,

    I get the same error as referred in the ticket..

    C:\jite_2k9>ruby script/dbconsole C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/dbconsole.rb:63:in exe ': No such file or directory - sqlite3.exe (Errno::ENOENT)

        from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/dbconsole.
    
    

    b:63

        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `g
    
    

    m_original_require'

        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `r
    
    

    quire'

        from script/dbconsole:3
    
    

    C:\jite_2k9>sqlite3 SQLite version 3.6.7 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite>

    January 8th, 2009 @ 10:31 AM

  2. Pratik
    Pratik
    • Assigned user set to Pratik
    • State changed from new to incomplete

    Could you please submit a patch using git-format-patch ? http://guides.rails.info/contrib... should help.

    Thanks!

    March 8th, 2009 @ 05:01 PM

  3. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from 2.2.2, dbconsole, windows to 2.2.2, bugmash, dbconsole, windows

    August 5th, 2009 @ 03:22 PM

  4. Kamal Fariz
    Kamal Fariz

    I've generated the patch for the amended find_cmd. This patch works in both 2-3-stable and master.

    August 10th, 2009 @ 07:15 AM

  5. Kamal Fariz
    Kamal Fariz
    • Tag changed from 2.2.2, bugmash, dbconsole, windows to 2.2.2, bugmash, dbconsole, patch, windows

    At the risk of spamming the ticket, I left out the obligatory bugmash magic phrase:

    I've attached a patch.

    August 10th, 2009 @ 07:19 AM

  6. Jeremy Kemper
    Jeremy Kemper
    • State changed from incomplete to committed
    • Tag changed from 2.2.2, bugmash, dbconsole, patch, windows to 2.2.2, dbconsole, patch, windows
    • Milestone changed from 2.x to 2.3.4

    August 10th, 2009 @ 08:05 AM

  7. Repository
  8. Repository