mysql2 gem 在 gem 列表中但获取项目找不到 gem
mysql2 gem in gem list but getting project can not find gem
我目前正在构建一个需要 mysql2 gem 的 RoR 项目。我成功安装了gem。因为它出现在我的 gem 列表中。
[root@vc2cmmka035538n simple_cms]# gem list
*** LOCAL GEMS ***
actionmailer (3.2.3)
actionpack (3.2.3)
activemodel (3.2.3)
activerecord (3.2.3)
activeresource (3.2.3)
activesupport (3.2.14, 3.2.3)
arel (3.0.2)
bigdecimal (1.1.0)
builder (3.2.2, 3.0.0)
bundler (1.1.5)
c2c_linux_patch_utilities (0.29.0)
chef (11.6.2)
chef-zero (1.6)
debug_me (0.5.1)
diff-lcs (1.1.3)
erubis (2.7.0)
gelf (1.1.3)
hashie (2.0.5)
highline (1.6.19)
hike (1.2.1)
i18n (0.6.5)
io-console (0.3)
ipaddress (0.8.0)
journey (1.0.3)
json (1.7.7, 1.5.5)
knife-lastrun (0.0.4)
mail (2.4.4)
mime-types (1.25)
minitest (2.5.1)
mixlib-authentication (1.3.0)
mixlib-cli (1.3.0)
mixlib-config (1.1.2)
mixlib-log (1.6.0)
mixlib-shellout (1.2.0)
moneta (0.6.0)
multi_json (1.8.1)
mysql2 (0.3.17) //here it is! :(
net-ssh (2.7.0)
net-ssh-gateway (1.2.0)
net-ssh-multi (1.2.0, 1.1)
ohai (6.18.0)
polyglot (0.3.3)
pony (1.4, 1.3)
poseidon (0.0.4)
puma (1.6.3)
rack (1.5.2, 1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.3)
railties (3.2.3)
rake (10.1.0, 0.9.2.2)
rdoc (3.12.2, 3.9.5)
rest-client (1.6.7)
rspec (2.12.0)
rspec-core (2.12.2)
rspec-expectations (2.12.1)
rspec-mocks (2.12.2)
rspec_junit_formatter (0.1.6)
ruby-shadow (2.2.0)
rubygems-update (1.8.19)
sdoc (0.3.20)
simplecov (0.7.1)
simplecov-html (0.7.1)
sprockets (2.1.2)
systemu (2.5.2, 2.5.1)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.31)
xml-simple (1.1.1)
yajl-ruby (1.1.0)
然而,当我尝试启动我的项目时出现以下错误:
[root@vc2cmmka035538n simple_cms]# rails s
Could not find gem 'mysql2 (= 0.3.17) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
gem 也肯定在我的 Gemfile 中:
source 'https://rubygems.org'
gem 'rails', '3.2.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2', '0.3.17'
gem 'json'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platform => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug'
如何让我的项目识别出 mysql2 gem 绝对安装在我的机器上?
编辑: 想要包含有关我的环境的信息
Ruby: ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
Rails: Rails 3.2.3
Ruby宝石环境:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2013-06-27 patchlevel 448) [x86_64-linux]
- INSTALLATION DIRECTORY: /opt/chef/embedded/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /opt/chef/embedded/bin/ruby
- EXECUTABLE DIRECTORY: /opt/chef/embedded/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /opt/chef/embedded/lib/ruby/gems/1.9.1
- /root/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://c2c-repo1-prod.fmr.com:9292"]
- REMOTE SOURCES:
- http://c2c-repo1-prod.fmr.com:9292
删除你的Gemfile.lock和运行bundle install
gem 安装 mysql
然后
gem 安装 mysql2
工作正常
可能没有安装构建本机扩展所需的包。
#installs the tools and libraries for basic development, eg. make.
sudo apt-get install build-essential
#installs the sources for ruby
sudo apt-get install ruby-dev
#installs the libraries and headers for mysql extensions
sudo apt-get install libmysqlclient-dev
对于 folks/mac 仍然面临此问题的用户,请尝试
(您可以跳过第一步)
第 1 步
gem install mysql
第 2 步
brew install openssl
第 3 步
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
第 4 步
brew install mysql2
如果这不起作用,请查看此 github 问题页面
上的对话
Ref - in case the above thing doesn't work can check the
我目前正在构建一个需要 mysql2 gem 的 RoR 项目。我成功安装了gem。因为它出现在我的 gem 列表中。
[root@vc2cmmka035538n simple_cms]# gem list
*** LOCAL GEMS ***
actionmailer (3.2.3)
actionpack (3.2.3)
activemodel (3.2.3)
activerecord (3.2.3)
activeresource (3.2.3)
activesupport (3.2.14, 3.2.3)
arel (3.0.2)
bigdecimal (1.1.0)
builder (3.2.2, 3.0.0)
bundler (1.1.5)
c2c_linux_patch_utilities (0.29.0)
chef (11.6.2)
chef-zero (1.6)
debug_me (0.5.1)
diff-lcs (1.1.3)
erubis (2.7.0)
gelf (1.1.3)
hashie (2.0.5)
highline (1.6.19)
hike (1.2.1)
i18n (0.6.5)
io-console (0.3)
ipaddress (0.8.0)
journey (1.0.3)
json (1.7.7, 1.5.5)
knife-lastrun (0.0.4)
mail (2.4.4)
mime-types (1.25)
minitest (2.5.1)
mixlib-authentication (1.3.0)
mixlib-cli (1.3.0)
mixlib-config (1.1.2)
mixlib-log (1.6.0)
mixlib-shellout (1.2.0)
moneta (0.6.0)
multi_json (1.8.1)
mysql2 (0.3.17) //here it is! :(
net-ssh (2.7.0)
net-ssh-gateway (1.2.0)
net-ssh-multi (1.2.0, 1.1)
ohai (6.18.0)
polyglot (0.3.3)
pony (1.4, 1.3)
poseidon (0.0.4)
puma (1.6.3)
rack (1.5.2, 1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.3)
railties (3.2.3)
rake (10.1.0, 0.9.2.2)
rdoc (3.12.2, 3.9.5)
rest-client (1.6.7)
rspec (2.12.0)
rspec-core (2.12.2)
rspec-expectations (2.12.1)
rspec-mocks (2.12.2)
rspec_junit_formatter (0.1.6)
ruby-shadow (2.2.0)
rubygems-update (1.8.19)
sdoc (0.3.20)
simplecov (0.7.1)
simplecov-html (0.7.1)
sprockets (2.1.2)
systemu (2.5.2, 2.5.1)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.31)
xml-simple (1.1.1)
yajl-ruby (1.1.0)
然而,当我尝试启动我的项目时出现以下错误:
[root@vc2cmmka035538n simple_cms]# rails s
Could not find gem 'mysql2 (= 0.3.17) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
gem 也肯定在我的 Gemfile 中:
source 'https://rubygems.org'
gem 'rails', '3.2.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2', '0.3.17'
gem 'json'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platform => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug'
如何让我的项目识别出 mysql2 gem 绝对安装在我的机器上?
编辑: 想要包含有关我的环境的信息
Ruby: ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
Rails: Rails 3.2.3
Ruby宝石环境:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2013-06-27 patchlevel 448) [x86_64-linux]
- INSTALLATION DIRECTORY: /opt/chef/embedded/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /opt/chef/embedded/bin/ruby
- EXECUTABLE DIRECTORY: /opt/chef/embedded/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /opt/chef/embedded/lib/ruby/gems/1.9.1
- /root/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://c2c-repo1-prod.fmr.com:9292"]
- REMOTE SOURCES:
- http://c2c-repo1-prod.fmr.com:9292
删除你的Gemfile.lock和运行bundle install
gem 安装 mysql
然后
gem 安装 mysql2
工作正常
可能没有安装构建本机扩展所需的包。
#installs the tools and libraries for basic development, eg. make.
sudo apt-get install build-essential
#installs the sources for ruby
sudo apt-get install ruby-dev
#installs the libraries and headers for mysql extensions
sudo apt-get install libmysqlclient-dev
对于 folks/mac 仍然面临此问题的用户,请尝试
(您可以跳过第一步)
第 1 步
gem install mysql
第 2 步
brew install openssl
第 3 步
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
第 4 步
brew install mysql2
如果这不起作用,请查看此 github 问题页面
上的对话
Ref - in case the above thing doesn't work can check the