好吧,我花了很长时间为 Ruby 和 RoR 设置 IDE 环境。到目前为止,我已经解决了每一个问题,除了一个,所以我谦虚地向强大的 stackoverflow 寻求指导。
我的 RubyMine 安装无法识别某些已安装的 gem,或更具体地说,SQLite3、Mysql 和 Mysql2。在 RubyMine 上使用 Gem 快速安装在所有三个上都失败,但是,在 cmd 中使用正确的配置安装 gem 是成功的。虽然成功,但 RubyMine 无法或不会识别已安装的 gem。 “require mysql2”(前面有“require rubygems”)立即失败,RubyMine 指出它无法加载这样的文件。当通过 firefox 访问本地主机上的 RoR 服务器时,我收到一条错误,指出 gem 未加载,我应该将其添加到我的 Gemfile 中(此时我应该声明所有上述 gem 已经在 gemfile 中,如果没有加载,我应该将其添加到我的 Gemfile 中)添加它们并运行捆绑安装)这很令人困惑。我花了几天时间在互联网和 stackoverflow 上搜索解决方案,但似乎没有任何效果。我什至尝试从 64 位版本的 ruby 2 升级到 32 位版本和一些以前的版本。
顺便说一句,在 Linux 发行版中编写 ruby 代码会更容易吗? (如 Ubuntu)
目前,我在 Windows 8x64 上的自定义装备中使用 RubyMine 5.4 IDE。我有三个 Ruby SDK 可供使用:2.0x64PO、2.0PO 和 1.9.3,并且安装了最新版本的 Rails。 Rubygems 与最新版本的 SQLite3、mysql 和 Mysql2 一起安装,通过手动安装正确安装。
下面是我在尝试运行 rubymine 时遇到的错误的副本。
runnerw.exe C:\Ruby200\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:/Users/RocYourSockx/RubymineProjects/testerrails/bin/rails server -b 127.0.0.1 -p 3000 -e development
C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in `require': cannot load such file -- mysql2/2.0/mysql2 (LoadError)
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in `<top (required)>'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in `<top (required)>'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from C:/Users/RocYourSockx/RubymineProjects/testerrailsnigga/config/application.rb:7:in `<top (required)>'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0.rc1/lib/rails/commands.rb:78:in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0.rc1/lib/rails/commands.rb:78:in `block in <top (required)>'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0.rc1/lib/rails/commands.rb:75:in `tap'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0.rc1/lib/rails/commands.rb:75:in `<top (required)>'
from C:/Users/RocYourSockx/RubymineProjects/testerrailsnigga/bin/rails:4:in `require'
from C:/Users/RocYourSockx/RubymineProjects/testerrailsnigga/bin/rails:4:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
Process finished with exit code 1
最佳答案
回答一下你的旁注,在我看来,ruby + windows 是一个非常非常痛苦的过程。安装 VirtualBox 和现代 Ubuntu 虚拟机可能会更好。让gems在windows下工作可能会很麻烦。
我在工作中使用 OSX,目前正在从此处设置 Ubuntu 镜像:http://virtualboxes.org/images/ubuntu/在我的家用笔记本电脑上,只是因为我厌倦了尝试在 Windows 7 上提高工作效率。
关于mysql - Mysql2、RoR 和 Windows 8 x64 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16441126/