Rails生成错误



每次键入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>'

插入您的GemFile

gem 'mysql2', '~> 0.3.18'

安装一些mysql2依赖项

sudo apt-get install libmysql-ruby libmysqlclient-dev

然后捆绑安装

bundle install

添加到您的GemFile 中

gem 'mysql2' #For latest version 

然后更新您的捆绑

bundle install 

然后在ruby文件夹中生成rails

gem install rails

最终创建项目

rails new project #Project your project name 

希望能帮助您

相关内容

  • 没有找到相关文章

最新更新