This project is archived and is in readonly mode.

#1488 ✓committed
xpol

The dbconsole can't exec the db command successfully.

Reported by xpol | November 28th, 2008 @ 09:13 AM | in 2.3.4

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

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments