本文介绍了在Windows 7上不安装mysql ruby gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 以下是我在尝试安装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 我是如何到达这一点的? 安装了Windows版MySQL。 http://dev.mysql.com/downloads/windows/installer/ 安装了Windows版Python。这一步可能与我的错误没有任何关系,但是我包含它,因为它是我部署的构建所需的。 https://www.python.org/downloads/ 安装了Ruby for Windows。看起来像我下载了rubyinstaller-2.2.2-x64.exe并安装了它。 http://rubyinstaller.org/downloads/ 安装了Ruby Gems,看起来像我下载并提取了rubygems-2.4.7.zip。 https://rubygems.org/pages/download 然后从Windows命令提示符运行这些命令: gem update --system 已安装在C:/ Ruby22-x64 / bin / gem中 gem install rubygems-update update_rubygems ...然后cd {文件夹解压缩到} ruby setup.rb 然后,我尝试安装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 ' 所以我按照说明操作。我去了那个页面( http://rubyinstaller.org/downloads )。看起来像我下载了DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe。当我提取愚蠢的提取器把文件放在与其他一切相同的目录中。因此,请确保您在下载后创建一个新文件夹,然后解压。 然后我运行这个命令。 p> ruby dk.rb init 然后我运行这个命令,并得到一个错误。 ruby dk.rb install 我必须确保config.yml文件指向我的机器上的C:\Ruby22-x64文件夹,以便安装Ruby。我删除了评论并更改了路径。然后重新执行这个命令,它就起作用了。 ruby dk.rb install 然后运行这个命令。 gem install rdiscount - -platform = ruby 重新安装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:\> 解决方案 所以我重复步骤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日更新: 安装在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(必需)>' ... ...继续 Below is an error I'm receiving when trying to install the mysql gem on Windows.C:\>gem install mysqlTemporarily 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.rbchecking for main() in -llibmysql... no*** extconf.rb failed ***Could not create Makefile due to some reason, probably lack of necessarylibraries and/or headers. Check the mkmf.log file for more details. You mayneed 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-libmysqllibextconf failed, exit code 1Gem 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.outHow did I get to this point?Installed MySQL for Windows.http://dev.mysql.com/downloads/windows/installer/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/Installed Ruby for Windows. Looks like I downloaded the "rubyinstaller-2.2.2-x64.exe and installed that.http://rubyinstaller.org/downloads/Installed Ruby Gems. Looks like I downloaded and extracted "rubygems-2.4.7.zip".https://rubygems.org/pages/downloadThen ran these commands from the Windows command prompt:gem update --system... was installed in C:/Ruby22-x64/bin/gemgem install rubygems-updateupdate_rubygems... then cd {folder extracted zip to}ruby setup.rbThen I tried installing the mysql gem like so. And got an error.C:>gem install mysqlFetching: 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 DevKitfrom 'http://rubyinstaller.org/downloads' and follow the instructionsat 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'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 initThen I ran this command, and got an error. ruby dk.rb installI 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 installThen ran this command.gem install rdiscount --platform=rubyThen 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 mysqlEDIT 5/21/2015:Per the question below, I'm getting a new error.Ruby MYSQL2 gem installation on windows 7C:\>gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\mysql-connector\lib" --with-mysql-include="C:\mysql-connector\include" --with-mysql-dir="C:\mysql-connector"'Temporarily enhancing PATH to include DevKit...Building native extensions with: '--with-mysql-lib="C:\mysql-connector\lib" --with-mysql-include="C:\mysql-connector\include" --with-mysql-dir="C:\mysql-connector"'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-connector\include" --with-mysql-dir="C:\mysql-connector"checking for ruby/thread.h... yeschecking for rb_thread_call_without_gvl() in ruby/thread.h... yeschecking for rb_thread_blocking_region()... nochecking for rb_wait_for_single_fd()... yeschecking for rb_hash_dup()... yeschecking for rb_intern3()... yes-----Using --with-mysql-dir=C:\mysql-connector\include;C:\mysql-connector\include;C:\mysql-connector-----checking for mysql.h... yeschecking for errmsg.h... yeschecking for mysqld_error.h... yes*** extconf.rb failed ***Could not create Makefile due to some reason, probably lack of necessarylibraries and/or headers. Check the mkmf.log file for more details. You mayneed 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}/libC:/Ruby22-x64/lib/ruby/2.2.0/rake/task_manager.rb:62:in `[]': Don't know how tobuild 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_prerequisite' from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:53:in `block in prerequisite_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_prerequisites' from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_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 1Gem 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.outC:\> 解决方案 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 mysqlIt installed the x86 version of mysql gem, because I can see the gem, by running this. It's very shiny and looks expensive!gem list5/26/2015 update: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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!