version of mysql2 (0.3.2) doesn't ship with the ActiveRecord adapter bundled anymore as it's now part of Rails 3.1

后端 未结 5 1953
余生分开走
余生分开走 2020-12-28 13:36

Hi i am using rails version 3.0.7 when i run rails generate model task name:string i m getting following warning

WARNING: This version of mysql2 (0.3.2) doe         


        
相关标签:
5条回答
  • 2020-12-28 13:53

    if still not working try this too:

    sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Users/YOUR_USER_NAME/.rvm/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
    
    0 讨论(0)
  • 2020-12-28 13:54

    The problem is because you are trying to install the latest version of mysql2 which is incompatible with rails 3.0.x version

    SO, in your Gemfile change the line for mysql2 gem for this:

    gem 'mysql2', '< 0.3'
    

    then bundle command

    and then when the new mysql2 gem file ( i think is 0.2.7 ) you will solve the problem.

    0 讨论(0)
  • 2020-12-28 13:54

    WARNING: Please use the 0.2.x releases if you plan on using it in Rails <= 3.0.x

    so in short just use the latest in the 0.2.x branch for the mysql2 gem.

    0 讨论(0)
  • 2020-12-28 14:01

    After trying the solution offered by @eveevans I was still having version issues. Then reading the suggestion by @rubyconvict, I thought instead about using the -v option for gem rather than pushing files about.

    Here's what I found eventually resolved my struggle with the dreaded "version of mysql2 (0.3.2)" message on DreamHost:

    # in mysql, create example_app & example_app_test ...
    # ... for the purposes of this example only, production == development db
    rails new example_app --database=mysql --freeze
    cd example_app
    vim config/database.yml
    #   change settings for host, user, password ...
    #   ... database for test (example_app_test) ...
    #   ... & database for production & development (example_app)
    
    vim Gemfile
    #   gem 'mysql2', '< 0.3'
    
    gem uninstall mysql2        # if installed: gem list -d mysql2
    gem install mysql2 -v 0.2.7 
    rake db:migrate     
    

    From there, I can move onto other RoR fun, like perhaps modifying routes (vim config/routes.rb ... however your mileage may vary).

    0 讨论(0)
  • 2020-12-28 14:12

    gem 'mysql2', '< 0.3' is the only way on Rails 3.0.7 (before 3.1)

    UPDATE: sorry, that was not the case also, did't work either, there is a better way:

    vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.2/lib/active_record/connection_adapters$[rails307]$ ls em_mysql2_adapter.rb mysql2_adapter.rb

    take mysql2_adapter.rb file from mysql2 gem version 0.2.x and copy it to the above location

    now it works for me with just gem 'mysql2' in Gemfile

    0 讨论(0)
提交回复
热议问题