在Windows 7上不安装mysql ruby​​ gem [英] mysql ruby gem not installing on Windows 7

查看:130
本文介绍了在Windows 7上不安装mysql ruby​​ gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


不重复。这个问题是MySQL的宝石,而另一个问题是mysql2宝石。尽管他们确实有相同的答案,但另一个问题的答案并不能明确说明解决方案是什么。答案隐藏在评论中。


以下是我在尝试安装mysql时收到的错误gem安装mysql
临时增强PATH以包含DevKit ... ./。

$ b $ p code $ C $ \\ b>
构建本地扩展。这可能需要一段时间...
错误:安装mysql时出错:
错误:无法构建gem本机扩展。

C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20150520-7968-hbly9l.rb extconf.rb
检查main()in -llibmysql ... no
*** extconf.rb失败***
由于某些原因无法创建Makefile,可能缺少必要的
库和/或头文件。检查mkmf.log文件以获取更多详细信息。您可能
需要配置选项。

提供的配置选项:
--with-opt-dir
--without-opt-dir
--with-opt-include
- -without-opt-include = $ {opt-dir} / include
--with-opt-lib
--without-opt-lib = $ {opt-dir} / lib
--with-make-prog
--without-make-prog
--srcdir =。
--curdir
--ruby = C:/ Ruby22-x64 / bin / $(RUBY_BASE_NAME)
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include = $ {mysql-dir} / include
--with-mysql-lib
--without- mysql-lib = $ {mysql-dir} / lib
--with-libmysqllib
--without-libmysqllib

extconf失败,退出代码1

Gem文件将保持安装在C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql-
2.9.1中进行检查。
记录到C的结果:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0
/mysql-2.9.1/gem_make.out



我是如何到达这一点的?




  1. 安装了Windows版MySQL。

http://dev.mysql.com/downloads/windows/installer/


  1. 安装了Windows版Python。这一步可能与我的错误没有任何关系,但是我包含它,因为它是我部署的构建所需的。

https://www.python.org/downloads/


  1. 安装了Ruby for Windows。看起来像我下载了rubyinstaller-2.2.2-x64.exe并安装了它。

http://rubyinstaller.org/downloads/


  1. 安装了Ruby Gems,看起来像我下载并提取了rubygems-2.4.7.zip。

< a href =https://rubygems.org/pages/download =nofollow noreferrer> https://rubygems.org/pages/download



然后从Windows命令提示符运行这些命令:

  gem update --system 

已安装在C:/ Ruby22-x64 / bin / gem中

  gem install ruby​​gems-update 

update_rubygems

...然后cd {文件夹解压缩到}

  ruby​​ setup.rb 




  1. 然后,我尝试安装mysql gem。错误。



    <> C:> gem install mysql
    获取:mysql-2.9.1.gem(100%)
    错误:安装mysql时出错:$

    请更新PATH以包含构建工具或从' =http://rubyinstaller.org/downloads =nofollow noreferrer> http://rubyinstaller.org/downloads '并按照说明
    在' http://github.com/oneclick/rubyinstaller/wiki/Development-Kit '


  2. 所以我按照说明操作。我去了那个页面( http://rubyinstaller.org/downloads )。看起来像我下载了DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe。当我提取愚蠢的提取器把文件放在与其他一切相同的目录中。因此,请确保您在下载后创建一个新文件夹,然后解压。

  3. 然后我运行这个命令。 p>

      ruby​​ dk.rb init 

    然后我运行这个命令,并得到一个错误。

      ruby​​ dk.rb install 

    我必须确保config.yml文件指向我的机器上的C:\Ruby22-x64文件夹,以便安装Ruby。我删除了评论并更改了路径。然后重新执行这个命令,它就起作用了。

      ruby​​ dk.rb install 

    然后运行这个命令。

      gem install rdiscount  - -platform = ruby​​ 




    1. 重新安装mysql gem。并在我的问题中得到了错误。什么是宝石! 我得到了你的珠宝贝蒂,珠宝!



      gem install mysql




    编辑5/21/2015:



    根据以下问题,我收到一个新错误。



    在Windows 7上安装Ruby MYSQL2 gem p>

      C:\> gem install mysql2 --platform = ruby​​  - '--with-mysql-lib =C: \mysql-connector\ 
    lib--with-mysql-include =C:\mysql-connector\include--with-mysql-dir =C:\mysq
    l-connector''
    临时增强PATH以包含DevKit ...
    使用以下命令构建本机扩展:--with-mysql-lib =C:\mysql-connector\lib - -wi
    th-mysql-include =C:\mysql-connector\include--with-mysql-dir =C:\mysql-connect
    或'
    这可能需要一段时间...
    错误:安装mysql2时出错:
    错误:无法构建gem本机扩展。

    C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20150521-10824-1plgdr8.rb extconf.rb
    --with-mysql-lib =C:\\ \\ mysql-connector \ lib--with-mysql-include =C:\mysql -conc
    tor \include--with-mysql-dir =C:\ mysql_connector
    检查ruby / thread.h ...是
    在ruby / thread.h中检查rb_thread_call_without_gvl()...是
    检查rb_thread_blocking_region()... no
    检查rb_wait_for_single_fd()...是
    检查rb_hash_dup()...是
    检查rb_intern3()...是
    -----
    使用--with-mysql-dir = C:\mysql-connector\include; C:\ mysql-connector\include; C:\
    mysql-connector
    -----
    检查mysql.h ...是
    检查errmsg.h ...是
    检查mysqld_error.h ...是
    *** extconf.rb失败***
    由于某些原因无法创建Makefile,可能缺少必要的
    库和/或头文件。检查mkmf.log文件以获取更多详细信息。您可能
    需要配置选项。

    提供的配置选项:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    - -without-opt-include = $ {opt-dir} / include
    --with-opt-lib
    --without-opt-lib = $ {opt-dir} / lib
    --with-make-prog
    --without-make-prog
    --srcdir =。
    --curdir
    --ruby = C:/ Ruby22-x64 / bin / $(RUBY_BASE_NAME)
    --with-mysql-dir
    --with-mysql-include = $ {mysql-dir} / include
    --with-mysql-lib = $ {mysql-dir} / lib
    C:/Ruby22-x64/lib/ruby/2.2.0/rake/ task_manager.rb:62:在`[]':不知道如何
    构建任务'C:/ mysql-connector / lib; C:/ mysql-connector / lib; C:/ mysql-connector / lib
    /libmysql.lib'(RuntimeError)
    from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:57:在`lookup_prerequisit
    e'从C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:53:在`block in prerequis
    ite_tasks'
    from C:/ Ruby22-x64 /lib/ruby/2.2.0/rake/task.rb:53:in`map'
    from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:53:in `prerequisite_tasks
    '
    from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:199:in`invoke_prerequisi
    tes'
    from C :/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:178:在`block in invoke_w
    ith_call_chain'从C:/Ruby22-x64/lib/ruby/2.2.0/monitor.rb:211:在`mon_synchronize'
    从C:/Ruby22-x64/lib/ruby/2.2.0/ rake / task.rb:172:in`invoke_with_call_
    chain'
    from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:165:in`invoke'
    from extconf.rb:117:在< main>'

    extconf失败,退出代码1

    Gem文件将保持安装在C:/ Ruby22- x64 / lib / ruby​​ / gems / 2.2.0 / gems / mysql2
    -0.3.18进行检查。
    记录到C的结果:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0
    /mysql2-0.3.18/gem_make.out

    C:\>


    解决方案


    和'mysql2'packages / extensions / gems不能与Windows 7上的
    x64位版本的Ruby(或任何64位版本的
    Windows)兼容。您需要安装x86(32)位版本的Ruby以便
    工作。


    所以我重复步骤3在我的问题中,安装了1.9版本,而不是在2013年8月30日由luislavena在我的问题中发表评论(问题191)。这是x86(32位)版本。从这里得到它。



    http://rubyinstaller.org / downloads /



    看起来文件名称是rubyinstaller-1.9.3-p551.exe。



    然后完成步骤4. Ruby开发人员必须修复它们的脚本以自动修改x86版本的config.yml文件。 然后在第5步中,我安装了这个devkit exe文件,因为新版本的Ruby没有开发工具包,是x86。

    对于第6步,我将它放入了它自己的文件夹中。它仍然提取exe根目录中的文件,而不是exe根目录的文件夹。然后运行除最后一个之外的所有命令。它仍然抛出错误。



    DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe

    然后第7步,我跑这个。

      gem install mysql 

    它安装了mysql版本的gem,因为我可以看到gem,通过运行这个。

     宝石列表






    2015年5月26日更新:

    < blockquote>

    安装在Windows上的最新版本的Ruby允许您
    启动Rails服务器,版本为2.1.6。


    启动rails服务器通过运行rails s不起作用。我不得不回去卸载旧版本的Ruby。在这里看到我的答案。忽略其他答案,如果你在Windows上。



    删除旧版本的Ruby(在Windows上)



    Windows上唯一能够让你稳定的Ruby版本启动rails服务器是rubyinstaller-2.1.6.exe。 rubyinstaller-2.2.2.exe引发以下错误:

      C:/ row / Ruby22 / lib / ruby​​ / gems /2.2.0/gems/nokogiri-1.6.6.2-x86-mingw32/lib/nokogiri 
    .rb:29:在`require'中:无法加载这样的文件 - nokogiri / nokogiri(LoadError)
    from C:/row/Ruby22/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2-x86-mingw32
    /lib/nokogiri.rb:29:in`rescue in< top(必需)>'
    ...
    ...继续


    Not a duplicate. This question is mysql gem and the other question is mysql2 gem. They do have the same answer though, but the other question's answer doesn't tell what the solution is explicitly. The answer is hidden in the comments. See yellow text of the answer for this question contains the solution.

    Below is an error I'm receiving when trying to install the mysql gem on Windows.

    C:\>gem install mysql
    Temporarily enhancing PATH to include DevKit...
    Building native extensions.  This could take a while...
    ERROR:  Error installing mysql:
            ERROR: Failed to build gem native extension.
    
        C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20150520-7968-hbly9l.rb extconf.rb
    checking for main() in -llibmysql... no
    *** extconf.rb failed ***
    Could not create Makefile due to some reason, probably lack of necessary
    libraries and/or headers.  Check the mkmf.log file for more details.  You may
    need configuration options.
    
    Provided configuration options:
            --with-opt-dir
            --without-opt-dir
            --with-opt-include
            --without-opt-include=${opt-dir}/include
            --with-opt-lib
            --without-opt-lib=${opt-dir}/lib
            --with-make-prog
            --without-make-prog
            --srcdir=.
            --curdir
            --ruby=C:/Ruby22-x64/bin/$(RUBY_BASE_NAME)
            --with-mysql-dir
            --without-mysql-dir
            --with-mysql-include
            --without-mysql-include=${mysql-dir}/include
            --with-mysql-lib
            --without-mysql-lib=${mysql-dir}/lib
            --with-libmysqllib
            --without-libmysqllib
    
    extconf failed, exit code 1
    
    Gem files will remain installed in C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql-
    2.9.1 for inspection.
    Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0
    /mysql-2.9.1/gem_make.out
    

    How did I get to this point?

    1. Installed MySQL for Windows.

    http://dev.mysql.com/downloads/windows/installer/

    1. Installed Python for Windows. This step probably has nothing to do with my error, but I'm including it since it is required for the build I'm deploying.

    https://www.python.org/downloads/

    1. Installed Ruby for Windows. Looks like I downloaded the "rubyinstaller-2.2.2-x64.exe and installed that.

    http://rubyinstaller.org/downloads/

    1. Installed Ruby Gems. Looks like I downloaded and extracted "rubygems-2.4.7.zip".

    https://rubygems.org/pages/download

    Then ran these commands from the Windows command prompt:

    gem update --system
    

    ... was installed in C:/Ruby22-x64/bin/gem

    gem install rubygems-update
    
    update_rubygems
    

    ... then cd {folder extracted zip to}

    ruby setup.rb
    

    1. Then I tried installing the mysql gem like so. And got an error.

      C:>gem install mysql Fetching: mysql-2.9.1.gem (100%) ERROR: Error installing mysql: The 'mysql' native gem requires installed build tools.

      Please update your PATH to include build tools or download the DevKit from 'http://rubyinstaller.org/downloads' and follow the instructions at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'

    2. So I followed the instructions. I went to that page (http://rubyinstaller.org/downloads). Looks like I downloaded "DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe". When I extracted the stupid extractor put the files in the same directory with everything else. So make sure you make a new folder after downloading, and before extracting.

    Then I ran this command.

    ruby dk.rb init
    

    Then I ran this command, and got an error.

    ruby dk.rb install
    

    I had to make sure the "config.yml" file pointed to the C:\Ruby22-x64 folder on my machine for where Ruby was installed. I removed the comment and change the path. Then reran the command, and it worked.

    ruby dk.rb install
    

    Then ran this command.

    gem install rdiscount --platform=ruby
    

    1. Then tried to re-install the mysql gem. And got the error in my question. What a gem! "I got you jewels Betty, jewels!"

      gem install mysql

    EDIT 5/21/2015:

    Per the question below, I'm getting a new error.

    Ruby MYSQL2 gem installation on windows 7

    C:\>gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\mysql-connector\
    lib" --with-mysql-include="C:\mysql-connector\include" --with-mysql-dir="C:\mysq
    l-connector"'
    Temporarily enhancing PATH to include DevKit...
    Building native extensions with: '--with-mysql-lib="C:\mysql-connector\lib" --wi
    th-mysql-include="C:\mysql-connector\include" --with-mysql-dir="C:\mysql-connect
    or"'
    This could take a while...
    ERROR:  Error installing mysql2:
            ERROR: Failed to build gem native extension.
    
        C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20150521-10824-1plgdr8.rb extconf.rb
     --with-mysql-lib="C:\mysql-connector\lib" --with-mysql-include="C:\mysql-connec
    tor\include" --with-mysql-dir="C:\mysql-connector"
    checking for ruby/thread.h... yes
    checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
    checking for rb_thread_blocking_region()... no
    checking for rb_wait_for_single_fd()... yes
    checking for rb_hash_dup()... yes
    checking for rb_intern3()... yes
    -----
    Using --with-mysql-dir=C:\mysql-connector\include;C:\mysql-connector\include;C:\
    mysql-connector
    -----
    checking for mysql.h... yes
    checking for errmsg.h... yes
    checking for mysqld_error.h... yes
    *** extconf.rb failed ***
    Could not create Makefile due to some reason, probably lack of necessary
    libraries and/or headers.  Check the mkmf.log file for more details.  You may
    need configuration options.
    
    Provided configuration options:
            --with-opt-dir
            --without-opt-dir
            --with-opt-include
            --without-opt-include=${opt-dir}/include
            --with-opt-lib
            --without-opt-lib=${opt-dir}/lib
            --with-make-prog
            --without-make-prog
            --srcdir=.
            --curdir
            --ruby=C:/Ruby22-x64/bin/$(RUBY_BASE_NAME)
            --with-mysql-dir
            --with-mysql-include=${mysql-dir}/include
            --with-mysql-lib=${mysql-dir}/lib
    C:/Ruby22-x64/lib/ruby/2.2.0/rake/task_manager.rb:62:in `[]': Don't know how to
    build task 'C:/mysql-connector/lib;C:/mysql-connector/lib;C:/mysql-connector/lib
    /libmysql.lib' (RuntimeError)
            from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:57:in `lookup_prerequisit
    e'
            from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:53:in `block in prerequis
    ite_tasks'
            from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:53:in `map'
            from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:53:in `prerequisite_tasks
    '
            from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisi
    tes'
            from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_w
    ith_call_chain'
            from C:/Ruby22-x64/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
            from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_
    chain'
            from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
            from extconf.rb:117:in `<main>'
    
    extconf failed, exit code 1
    
    Gem files will remain installed in C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2
    -0.3.18 for inspection.
    Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0
    /mysql2-0.3.18/gem_make.out
    
    C:\>
    

    解决方案

    The 'mysql' and 'mysql2' packages/extensions/gems don't work with the x64 bit version of Ruby on Windows 7 (or any 64 bit version of Windows). You need to install the x86 (32) bit version of Ruby for them to work.

    So I repeated step 3 in my question, and installed version 1.9 instead taking the advice from my comment in my question (on issue 191) by luislavena on August 30, 2013. This is the x86 (32 bit) version. Got it from here.

    http://rubyinstaller.org/downloads/

    Looks like the file's name is "rubyinstaller-1.9.3-p551.exe".

    Then completed step 4. The Ruby developers must have fixed their scripts to modify the config.yml file automatically for the x86 version. I didn't have to edit this time.

    Then for step 5, I installed this devkit exe, because the newer version of Ruby didn't have a dev kit that was x86.

    For step 6, I placed into it's own folder. It still extracts files in the exe root, not a folder of the exe root. Then ran all the commands except for the last one. It still threw the error.

    "DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe"

    Then for step 7, I ran this.

    gem install mysql
    

    It installed the x86 version of mysql gem, because I can see the gem, by running this. It's very shiny and looks expensive!

    gem list
    


    5/26/2015 update:

    Latest version of Ruby when installed on Windows that allows you to start the Rails server is 2.1.6.

    Starting the rails server didn't work by running "rails s". I had to go back and uninstall old versions of Ruby. See my answer here. Ignore the other answers if you are on Windows.

    Remove older versions of Ruby (on Windows)

    The only stable version of Ruby on Windows that allows you to start the rails server is "rubyinstaller-2.1.6.exe". "rubyinstaller-2.2.2.exe" throws the following error:

    C:/row/Ruby22/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2-x86-mingw32/lib/nokogiri
    .rb:29:in `require': cannot load such file -- nokogiri/nokogiri (LoadError)
            from C:/row/Ruby22/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2-x86-mingw32
    /lib/nokogiri.rb:29:in `rescue in <top (required)>'
    ... 
    ... continued
    

    这篇关于在Windows 7上不安装mysql ruby​​ gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆