简体   繁体   English

Rails产生错误

[英]Rails generate error

This error comes every time I type rails generate : 每当我输入rails generate都会出现此错误:

/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mysql2-0.4.2/lib/mysql2.rb:31:in
`require':
dlopen(/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mysql2-0.4.2/lib/mysql2/mysql2.bundle,
9): Library not loaded: libmysqlclient.18.dylib   Referenced from:
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mysql2-0.4.2/lib/mysql2/mysql2.bundle
Reason: image not found -
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mysql2-0.4.2/lib/mysql2/mysql2.bundle
(LoadError)   from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mysql2-0.4.2/lib/mysql2.rb:31:in
`<top (required)>'    from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:77:in
`require'     from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:77:in
`block (2 levels) in require'     from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in
`each'    from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in
`block in require'    from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in
`each'    from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in
`require'     from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler.rb:99:in
`require'     from
/Users/hadifarhat/simple_cms/config/application.rb:7:in `<top
(required)>'  from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.6.1/lib/spring/application.rb:82:in
`require'     from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.6.1/lib/spring/application.rb:82:in
`preload'     from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.6.1/lib/spring/application.rb:143:in
`serve'   from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.6.1/lib/spring/application.rb:131:in
`block in run'    from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.6.1/lib/spring/application.rb:125:in
`loop'    from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.6.1/lib/spring/application.rb:125:in
`run'     from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.6.1/lib/spring/application/boot.rb:18:in
`<top (required)>'    from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'  from
/Users/hadifarhat/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'  from -e:1:in `<main>'

insert into your GemFile 插入您的GemFile

gem 'mysql2', '~> 0.3.18'

install some mysql2 dependency 安装一些mysql2依赖

sudo apt-get install libmysql-ruby libmysqlclient-dev

then bundle install 然后捆绑安装

bundle install

Add into your GemFile 添加到您的GemFile

gem 'mysql2' #For latest version 

Then update your bundle 然后更新您的套装

bundle install 

Then generate rails into ruby folder 然后生成rails到ruby文件夹

gem install rails

Finally create project 最终创建项目

rails new project #Project your project name 

Hope will help you 希望能帮到您

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM