Showing posts with label Error. Show all posts
Showing posts with label Error. Show all posts

Saturday, February 4, 2012

"src/rbae.c:13:27: fatal error: Carbon/Carbon.h: No such file or directory" while installing rb-appscript (0.6.1) on ubuntu

While running bundle install, got following error:
Installing rb-appscript (0.6.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/ritesh/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
extconf.rb:44: Use RbConfig instead of obsolete and deprecated Config.
create /home/ritesh/.rvm/gems/ruby-1.9.3-p0@koodrails/gems/rb-appscript-0.6.1/src/osx_ruby.h ...
create /home/ritesh/.rvm/gems/ruby-1.9.3-p0@koodrails/gems/rb-appscript-0.6.1/src/osx_intern.h ...
creating Makefile

make
Makefile:226: warning: overriding commands for target `/home/ritesh/.rvm/gems/ruby-1.9.3-p0@koodrails/gems/rb-appscript-0.6.1/lib'
Makefile:224: warning: ignoring old commands for target `/home/ritesh/.rvm/gems/ruby-1.9.3-p0@koodrails/gems/rb-appscript-0.6.1/lib'
compiling src/rbae.c
src/rbae.c:13:27: fatal error: Carbon/Carbon.h: No such file or directory
compilation terminated.
make: *** [rbae.o] Error 1


Gem files will remain installed in /home/ritesh/.rvm/gems/ruby-1.9.3-p0@koodrails/gems/rb-appscript-0.6.1 for inspection.
Results logged to /home/ritesh/.rvm/gems/ruby-1.9.3-p0@koodrails/gems/rb-appscript-0.6.1/./gem_make.out
An error occured while installing rb-appscript (0.6.1), and Bundler cannot continue.
Make sure that `gem install rb-appscript -v '0.6.1'` succeeds before bundling.




Yet looking for solution to fix the issue, if someone can help.

Tuesday, January 31, 2012

Getting error "can't activate sqlite3 (~> 1.3.5), already activated sqlite3-1.3.4" when upgrading to Rails 3.2

Upgradation from Rails 3.1 to Rails 3.2 done successfully. When starting server, getting error :

Exiting
/home/ritesh/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/rubygems_integration.rb:153:in `block in replace_gem': Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (can't activate sqlite3 (~> 1.3.5), already activated sqlite3-1.3.4. Make sure all dependencies are added to Gemfile.) (LoadError)
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:3:in `<top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `block in require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:234:in `block in load_dependency'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:639:in `new_constants_in'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:234:in `load_dependency'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:48:in `resolve_hash_connection'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:39:in `resolve_string_connection'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:23:in `spec'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:127:in `establish_connection'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.0/lib/active_record/railtie.rb:76:in `block (2 levels) in <class:Railtie>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.0/lib/active_record/base.rb:709:in `<top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/omniauth-identity-1.0.0/lib/omniauth/identity/models/active_record.rb:6:in `<module:Models>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/omniauth-identity-1.0.0/lib/omniauth/identity/models/active_record.rb:5:in `<module:Identity>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/omniauth-identity-1.0.0/lib/omniauth/identity/models/active_record.rb:4:in `<module:OmniAuth>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/omniauth-identity-1.0.0/lib/omniauth/identity/models/active_record.rb:3:in `<top (required)>'
from /home/ritesh/projects/projects/crowd/app/models/crowd/credential.rb:1:in `<top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:469:in `load'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:469:in `block in load_file'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:639:in `new_constants_in'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:468:in `load_file'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:353:in `require_or_load'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:502:in `load_missing_constant'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:192:in `block in const_missing'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:190:in `each'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:190:in `const_missing'
from /home/ritesh/projects/projects/crowd/config/initializers/omniauth.rb:4:in `block in <top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/omniauth-1.0.0/lib/omniauth/builder.rb:7:in `initialize'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.0/lib/action_dispatch/middleware/stack.rb:43:in `new'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.0/lib/action_dispatch/middleware/stack.rb:43:in `build'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.0/lib/action_dispatch/middleware/stack.rb:112:in `block in build'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.0/lib/action_dispatch/middleware/stack.rb:112:in `each'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.0/lib/action_dispatch/middleware/stack.rb:112:in `inject'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.0/lib/action_dispatch/middleware/stack.rb:112:in `build'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/engine.rb:470:in `app'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/application/finisher.rb:32:in `block in <module:Finisher>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:30:in `instance_exec'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:30:in `run'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:54:in `each'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:54:in `run_initializers'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/application.rb:136:in `initialize!'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/ritesh/projects/projects/crowd/spec/dummy/config/environment.rb:5:in `<top (required)>'
from /home/ritesh/projects/projects/crowd/spec/dummy/config.ru:4:in `require'
from /home/ritesh/projects/projects/crowd/spec/dummy/config.ru:4:in `block in <main>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /home/ritesh/projects/projects/crowd/spec/dummy/config.ru:1:in `new'
from /home/ritesh/projects/projects/crowd/spec/dummy/config.ru:1:in `<main>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands/server.rb:46:in `app'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands/server.rb:70:in `start'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands.rb:55:in `block in <top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands.rb:50:in `tap'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands.rb:50:in `<top (required)>'
from /home/ritesh/projects/projects/crowd/spec/dummy/script/rails:6:in `require'
from /home/ritesh/projects/projects/crowd/spec/dummy/script/rails:6:in `<top (required)>'
from script/rails:6:in `load'
from script/rails:6:in `<main>'


To fix the error:

Change the sqlite version in .gemspec from
s.add_development_dependency "sqlite3"
to
s.add_development_dependency "sqlite3" , "~> 1.3.5"

and run 'bundle install'

Getting error 'undefined method `before_dispatch' for class `Rails::Rack::Logger' (NameError) '

Upgradation from Rails 3.1 to Rails 3.2 done successfully. When starting rails server getting following error:

/home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method': undefined method `before_dispatch' for class `Rails::Rack::Logger' (NameError)
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method_chain'
from /home/ritesh/projects/projects/crowd/spec/dummy/config/initializers/quite_assets.rb:6:in `block in <top (required)>'
from /home/ritesh/projects/projects/crowd/spec/dummy/config/initializers/quite_assets.rb:2:in `class_eval'
from /home/ritesh/projects/projects/crowd/spec/dummy/config/initializers/quite_assets.rb:2:in `<top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:245:in `load'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:245:in `block in load'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:236:in `load_dependency'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:245:in `load'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/engine.rb:587:in `each'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/engine.rb:587:in `block in <class:Engine>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:30:in `instance_exec'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:30:in `run'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:54:in `each'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:54:in `run_initializers'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/application.rb:136:in `initialize!'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/ritesh/projects/projects/crowd/spec/dummy/config/environment.rb:5:in `<top (required)>'
from /home/ritesh/projects/projects/crowd/spec/dummy/config.ru:4:in `require'
from /home/ritesh/projects/projects/crowd/spec/dummy/config.ru:4:in `block in <main>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /home/ritesh/projects/projects/crowd/spec/dummy/config.ru:1:in `new'
from /home/ritesh/projects/projects/crowd/spec/dummy/config.ru:1:in `<main>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands/server.rb:46:in `app'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands/server.rb:70:in `start'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands.rb:55:in `block in <top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands.rb:50:in `tap'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands.rb:50:in `<top (required)>'
from /home/ritesh/projects/projects/crowd/spec/dummy/script/rails:6:in `require'
from /home/ritesh/projects/projects/crowd/spec/dummy/script/rails:6:in `<top (required)>'
from script/rails:6:in `load'
from script/rails:6:in `<main>'

To fix the error, 

Place the following code in config/initializers/quiet_assets.rb
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
  def call_with_quiet_assets(env)
    previous_level = Rails.logger.level
    Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
    call_without_quiet_assets(env).tap do
      Rails.logger.level = previous_level
    end
  end
  alias_method_chain :call, :quiet_assets
 end


Sunday, January 1, 2012

Getting error "File Error: data may have been lost" while using spreadsheet and exporting excel

I am using "Spreadsheet" gem with Rails 2.3.8. Microsoft Office 2007 is installed on my system.
I successfully fitted the code snippets in one of my controller.
I just wrote the code to create Worksheet and pushed one row record in it.
Number of records pushed in that row is around 330.
When I export the spreadsheet/excel, I got following error:



"File Error: data may have been lost"

Clicked on Ok and it created the excel file with the File Type "Microsoft Office Excel 97-2003 Worksheet" with one sheet having 1 row.
When closely analyzed the sheet, I found that Number of maximum columns that can be in that sheet is only 256 and as I was trying to have around 330 columns hence I was getting the error.

Saturday, December 3, 2011

Getting error "Illegal octal digit"

While trying to execute below case method to display month, getting 'Illegal octal digit' for August and September month only:

def self.convert_month(month)
    case month
      when "Jan" :         01
      when "Feb" :        02
      when "Mar" :        03
      when "Apr" :        04
      when "May" :       05
      when "Jun" :         06
      when "Jul" :          07
      when "Aug" :       08
      when "Sep" :        09
      when "Oct" :        10
      when "Nov" :       11
      when "Dec" :        
  end

Solution

Ruby is interpreting numbers that have a leading 0 as being in octal (base 8). Thus the digits 8 and 9 are not valid. So,  I removed leading zero from Aug and Sep month and changed the method as:

when "Aug" :        8
when "Sep" :         9

Tuesday, September 6, 2011

Getting error "ArgumentError: wrong number of arguments (3 for 2)" for mysql2_adapter

In one of my application I am using Ruby 1.9.2, mysql2 gem, Rails 3.0.6.

While upgrading to Rails 3.1, getting following error throughout the application. When I ran command on console, then also getting same error:

ruby-1.9.2-p290 :003 > c = Cuisine.all
ArgumentError: wrong number of arguments (3 for 2)
    from /Users/ror/projects/restaurant/highline/ruby/1.9.1/gems/mysql2-0.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:585:in `select'
    from /Users/ror/projects/restaurant/highline/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all'
    from /Users/ror/projects/restaurant/highline/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
    from /Users/ror/projects/restaurant/highline/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:470:in `find_by_sql'
    from /Users/ror/projects/restaurant/highline/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/relation.rb:111:in `to_a'
    from /Users/ror/projects/restaurant/highline/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/relation/finder_methods.rb:155:in `all'
    from /Users/ror/projects/restaurant/highline/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:441:in `all'
    from (irb):3
    from /Users/ror/projects/restaurant/highline/ruby/1.9.1/gems/railties-3.1.0/lib/rails/commands/console.rb:45:in `start'
    from /Users/ror/projects/restaurant/highline/ruby/1.9.1/gems/railties-3.1.0/lib/rails/commands/console.rb:8:in `start'
    from /Users/ror/projects/restaurant/highline/ruby/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:40:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Solution to fix the problem:

In Gemfile, replace 'mysql2' line with

       gem 'mysql2', '>= 0.3'

and install mysql2 greater than '0.3' version, in my case it is ' mysql2 (0.3.6) ' and it will work :)


NOTE: as of Rails 0.3.0, and ActiveRecord 3.1 - the ActiveRecord adapter has been pulled out of mysql2 gem and into ActiveRecord itself. If you need to use mysql2 with Rails versions < 3.1 make sure and specify gem "mysql2", "~> 0.2.7" in your Gemfile

And for Rails version 3.1 or above use  gem 'mysql2', '>= 0.3'

Sunday, September 4, 2011

Getting error 'Could not update iceauthority file' in ubuntu

After logging in to an Ubuntu an ICEauthority error appeared. 

Solution
Press Ctrl-Alt-F1 to get a console. There, I hit Enter to get a login prompt. I logged in with my username and password, and this gave me a regular command prompt. After trying several failed commands, I found the following command on Ubuntuforums.org that helped me to login successfully.

Open a terminal and enter the following command:
sudo chown -R user:user /home/user/.*

Replace user with your username. For example, My username is 'ritesh' so I typed command:
 

sudo chown -R ritesh:ritesh /home/ritesh/.*
After issuing the command, log out and log back in and Ubuntu will be back to normal GUI screen. This error came because of sftp. I installed sftp and assigned my username to use sftp that caused this error to occur. 


Related Links:
- http://ubuntuforums.org/showthread.php?t=1081730&highlight=ICEAuthority&page=2

Wednesday, July 6, 2011

searchd giving error "dyld: Library not loaded: libmysqlclient.18.dylib" on Mac

On Mac system, in one of my application using Thinking Sphinx. After installation while running searchd, it gives following errors:

$ searchd
dyld: Library not loaded: libmysqlclient.18.dylib
  Referenced from: /usr/local/bin/searchd
  Reason: image not found
Trace/BPT trap
-:sphinx-0.9.8 ror$ cd ..
-:Downloads ror$ l
-bash: l: command not found

Solution:
It's because unable to find the libmysqlclient library. Add the following to to your ~/.profile:

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
and it will work fine

Wednesday, June 22, 2011

incompatible character encodings: ASCII-8BIT and UTF-8 in Ruby 1.9.2

While migrating from Ruby 1.8.7 to Ruby 1.9.2 getting error:
incompatible character encodings: ASCII-8BIT and UTF-8 in Ruby 1.9.2

While running rake task, getting error:

rake aborted!
C:/projects/restaurant/lib/tasks/setup.rake:158: invalid multibyte char (US-ASCII)
C:/projects/restaurant/lib/tasks/setup.rake:158: invalid multibyte char (US-ASCII)
C:/projects/restaurant/lib/tasks/setup.rake:158: syntax error, unexpected $end, expecting ')'
     Cuisine.create(:name=>"Caf├⌐")
                                 ^
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:235:in `load'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:235:in `block in load'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:in `block in load_dependency'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:596:in `new_constants_in'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:in `load_dependency'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:235:in `load'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/engine.rb:131:in `block in load_tasks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/engine.rb:131:in `each'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/engine.rb:131:in `load_tasks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/application.rb:141:in `load_tasks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/application.rb:77:in `method_missing'
C:/projects/restaurant/Rakefile:7:in `<top (required)>'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2373:in `load'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:1991:in `run'
C:/Ruby192/bin/rake:31:in `<main>'

At some other places getting error :
invalid multibyte char (US-ASCII)


Solution:
Solved it by following steps:
  • Make sure 'config.encoding = "utf-8"' is there in application.rb file.
  • Make sure you are using 'mysql2' gem
  • Putting '# encoding: utf-8' on top of rake file.
  • Above 'Starter::Application.initialize!' line in environment.rb file, add following two lines:
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8

Friday, May 27, 2011

Thinking Sphinx giving error "Failed to start searchd daemon"

I have Rails 3.0 application running on Windows 7. I am using Thinking Sphinx. I configured it and worked for few days. One day, after some file update when I ran "rake ts:start", it gives following errors:

C:\projects\demo>rake ts:start
(in C:/projects/demo)

Sphinx cannot be found on your system. You may need to configure the following
settings in your config/sphinx.yml file:
  * bin_path
  * searchd_binary_name
  * indexer_binary_name

For more information, read the documentation:
http://freelancing-god.github.com/ts/en/advanced_config.html
C:/Ruby187/bin/rake: No such file or directory - searchd --pidfile --config "C:/projects/demo/config/development.sphinx.conf"
Failed to start searchd daemon. Check C:/projects/demo/log/searchd.log.
Failed to start searchd daemon. Check C:/projects/demo/log/searchd.log

When I checked 'searchd.log' file it displays following error:
[Wed Apr 27 19:28:50.187 2011] [  236] accepting connections
[Wed Apr 27 19:35:05.546 2011] [  236] caught SIGTERM, shutting down
[Wed Apr 27 19:35:05.630 2011] [  236] shutdown complete

Steps to fix the error:

Change the 'config/sphinx.yml' file and give path to bin directory where Sphinx is installed as given below:
development:
  bin_path: "C:/Sphinx/bin"

Then run
rake thinking_sphinx:index
rake thinking_sphinx:start
and it will run without any error.

Wednesday, May 25, 2011

Could not find gem 'sass (>= 0)' in any of the gem sources listed in your Gemfile

Ruby version - ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
I ran the command 'gem install rails --pre' to install 'Rails 3.1.0.beta1'.

When checking 'rails -v', it gives following errors:
Could not find gem 'sass (>= 0)' in any of the gem sources listed in your Gemfile

Steps to fix the error:
Fixed the error by running the command 'gem install sass' separately.

And then again I checked rails version, it gave:
Rails 3.1.0.beta1

Tuesday, May 24, 2011

'rake ts:rebuild' giving 'execution expired' error

I have one Rails 3.0 application on linux. I am using Thinking Sphinx.
When I ran rake ts:rebuild, I got following error:

rake ts:rebuild
(in /var/www/rails/sphinx/releases/20110524133955)
d. Use lib/tasks instead. (called from /var/www/rails/sphinx/releases/20110524133955/Rakefile:7)
** Invoke ts:restart (first_time)
** Invoke thinking_sphinx:restart (first_time)
** Invoke thinking_sphinx:app_env (first_time)
** Execute thinking_sphinx:app_env
** Invoke thinking_sphinx:stop (first_time)
** Invoke thinking_sphinx:app_env
** Execute thinking_sphinx:stop
rake aborted!
execution expired
/usr/lib/ruby/1.8/timeout.rb:60
/home/advent-ror/.bundler/ruby/1.8/thinking-sphinx-3fbd0df76796/lib/thinking_sphinx/tasks.rb:53
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

Steps to fix the error:
This error occurs when search daemon is already running, so first we have to kill the search daemon process.
To find out the process ID, run the command
ps | grep searchd
OR
pgrep searchd
It will give you a process ID.

Kill the process by command
"sudo kill -9 process_id", change the process_id with yours one.

Then run rake ts:rebuild again.

Thursday, May 5, 2011

Routing error when running Rails 3 application server in production mode

I was developing a Rails3 application and I wanted to execute a bunch of JavaScript code only on production server. So, in order to do that in my view I added these lines:

<%- if RAILS_ENV == "production" -%>
      -- my JavaScript code --
<% end %>

Now, I wanted to test the code before deploying it on production. So, I needed to start the Rails server in production mode. To start a Rails3 application server in production mode, I passed '-e production' parameter as:
rails s -e production

But when I started browsing the application, all the stylesheets, images were gone and was getting Routing errors similar to the one given below:
Started GET "/javascripts/jquery.js?1303373839" for 127.0.0.1 at Thu May 05 19:55:09 +0530 2011

ActionController::RoutingError (No route matches "/javascripts/jquery.js"):

Reason was - Rails defaults not serve static assets in production, so to fix Routing Errors, I changed

config.serve_static_assets = false
line in 'config/environments/production.rb' to
config.serve_static_assets = true

And restarted the server in production mode. It solved the Routing issue.

Thursday, March 31, 2011

Getting error: The specified module could not be found. - C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql-2.8.1-x86-mingw32/lib/1.9/mysql_api.so (LoadError )

After installing pik, added Ruby 1.9.2 and then switched to Ruby 1.9.2, installed rails on Ruby 1.9.2.
On my existing rails application which has already been updated to Rails -v 3.0.3, I ran 'bundle install' and it executed and installed the gems. Tried to run rails server, but got error:


>rails s
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql-2.8.1-x86-mingw32/lib/mysql.rb:7:in `require': 126: The specified module could not be found.   - C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql-2.8.1-x86-mingw32/lib/1.9/mysql_api.so (LoadError
)
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql-2.8.1-x86-mingw32/lib/mysql.rb:7:in `rescue in <top (required)>'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql-2.8.1-x86-mingw32/lib/mysql.rb:2:in `<top (required)>'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `block in require'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
        from C:/projects/working project/phoenix/config/application.rb:7:in `<top (required)>'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:28:in `require'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:28:in `block in <top (required)>'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:27:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

To fix this error, I copied "libmySQL.dll" file from 'C:\Program Files\MySQL\MySQL Server 5.1\bin' to 'C:\Ruby192\bin' and then on starting the server it ran without any error.

Saturday, February 26, 2011

Getting error "uninitialized constant Rake::RDocTask" while running rake db:migrate

I am upgrading an existing rails application from Rails verison 2.3.5 to 3.0.3.
I added some files, and while running rake db:migrate, getting error:
uninitialized constant Rake::RDocTask
After long searching, running rake --trace and analyzing found the fix.
Added the line
require 'rake/testtask'
require 'rake/rdoctask'
below "require 'rake'" in Rakefile and it worked.

Friday, February 25, 2011

Getting error uninitialized constant ENV_PATH (NameError) on running rails console

My Rails version is - 3.0.3
Ruby version - ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
Gem version - 1.3.7
Operating system - Windows 7

When I run command "rails console" it gives following error:

C:\projects\working project\demo>rails console
C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.0.beta3/lib/rails/commands.rb:33: uninitialized constant ENV_PATH (NameError)
        from script/rails:6:in `require'
        from script/rails:6

Note -"Rails console" is not working only for this project and only on Windows 7
("Rails console" for the above project demo is working fine on linux but not working on Windows 7.
"Rails console" on another application on Rails 3 is working fine on Windows 7)

Can anybody guide me how to solve this error?

Wednesday, February 23, 2011

Getting error: undefined method `to_key' for #

Rails 3 and Authlogic together giving error :
undefined method `to_key' for #<UserSession: no credentials provided>
To fix the error, change the code in user_session.rb as given below:

class UserSession < Authlogic::Session::Base

 def to_key
   new_record? ? nil : [ self.send(self.class.primary_key) ]
  end
end

And it will work fine.
For details, you can refer to http://techoctave.com/c7/posts/37-authlogic-and-rails-3-0-solution

Thursday, February 10, 2011

named_scope DEPRECATION WARNING on Rails 3.0.3

While using named_scope in Rails 3.0.3
class Project < ActiveRecord::Base
  named_scope :completed,:conditions=>"finish = true" 
end
you will get DEPRECATION WARNING.
DEPRECATION WARNING: Base.named_scope has been deprecated, please use Base.scope instead. (called from C:/projects/myapp/app/models/project.rb:2)
 To fix this use scope instead of named_scope. Your new code will be:

class Project < ActiveRecord::Base
  scope :completed,:conditions=>"finish = true" 
end

Bundle install on linux giving ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

Ruby version - 1.8.7, Rails version - 3.0.3
While running command bundle install on linux, getting following errors:

Installing bcrypt-ruby (2.1.2) with native extensions /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/usr/bin/ruby1.8 extconf.rb
extconf.rb:13:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:13


Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/bcrypt-ruby-2.1.2 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/bcrypt-ruby-2.1.2/ext/mri/gem_make.out
from /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:446:in `each'
from /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:446:in `build_extensions'
from /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:198:in `install'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/source.rb:95:in `install'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:55:in `run'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:44:in `run'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:8:in `install'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/cli.rb:225:in `install'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/task.rb:22:in `send'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/task.rb:22:in `run'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/base.rb:389:in `start'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/bin/bundle:13
from /usr/bin/bundle:19:in `load'
from /usr/bin/bundle:19


Any suggestion on this?