当前位置:  开发笔记 > 后端 > 正文

Ruby on Rails安装 - Ubuntu 15

如何解决《RubyonRails安装-Ubuntu15》经验,为你挑选了1个好方法。

我试图在Ubuntu 15(64位)中安装RoR.我已经完成了大部分安装过程,比如安装rvm,ruby,mysql服务器,创建gemset.

rails new first_app
rvm gemset list
rvm gemset use rails3.2.13
rails new first_app
cd first_app/
bundle install 

上面的逗号已成功执行.

Ruby version 2.2.1
Rails version 3.2.13

当我尝试启动我的服务器时,我收到如下错误

rails s
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activesupport-3.2.13/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'coffee-rails'. (Bundler::GemRequireError)
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
    from /home/ela/Documents/first_app/config/application.rb:7:in `'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/railties-3.2.13/lib/rails/commands.rb:53:in `require'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/railties-3.2.13/lib/rails/commands.rb:53:in `block in '
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/railties-3.2.13/lib/rails/commands.rb:50:in `'
    from script/rails:6:in `require'
    from script/rails:6:in `
'

我的宝石文件::

source 'https://rubygems.org'

gem 'rails', '3.2.13'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'mysql2'


# 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', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

"uglifier"gem的错误也是如此,所以我删除了那两颗宝石.然后我在mysql适配器中收到错误.

rails s
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activesupport-3.2.13/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/bundler-1.11.2/lib/bundler/rubygems_integration.rb:314:in `block in replace_gem': Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (can't activate mysql2 (~> 0.3.10), already activated mysql2-0.4.2. Make sure all dependencies are added to Gemfile.) (LoadError)
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:3:in `'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/railtie.rb:82:in `block (2 levels) in '
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `each'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/base.rb:720:in `'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/railtie.rb:88:in `block in '
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
    from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /home/ela/Documents/first_app/config/environment.rb:5:in `'
    from /home/ela/Documents/first_app/config.ru:3:in `require'
    from /home/ela/Documents/first_app/config.ru:3:in `block in 
' from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/rack-1.4.7/lib/rack/builder.rb:51:in `instance_eval' from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/rack-1.4.7/lib/rack/builder.rb:51:in `initialize' from /home/ela/Documents/first_app/config.ru:in `new' from /home/ela/Documents/first_app/config.ru:in `
' from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/rack-1.4.7/lib/rack/builder.rb:40:in `eval' from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/rack-1.4.7/lib/rack/builder.rb:40:in `parse_file' from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/rack-1.4.7/lib/rack/server.rb:200:in `app' from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in `app' from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/rack-1.4.7/lib/rack/server.rb:304:in `wrapped_app' from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/rack-1.4.7/lib/rack/server.rb:254:in `start' from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in `start' from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in ' from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap' from /home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/railties-3.2.13/lib/rails/commands.rb:50:in `' from script/rails:6:in `require' from script/rails:6:in `
'

所以我将我的gem mysql2 gem版本改为<0.3

rake db:migrate --trace
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activesupport-3.2.13/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now
============= WARNING FROM mysql2 =============
This version of mysql2 (0.2.24) isn't compatible with Rails 3.1 as the ActiveRecord adapter was pulled into Rails itself.
Please use the 0.3.x (or greater) releases if you plan on using it in Rails >= 3.1.x
============= END WARNING FROM mysql2 =============
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
rake aborted!
NoMethodError: undefined method `accept' for nil:NilClass
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `to_sql'
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/database_statements.rb:38:in `select_values'
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/migration.rb:587:in `get_all_versions'
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/migration.rb:745:in `migrated'
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/migration.rb:668:in `current_version'
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/migration.rb:685:in `block in migrate'
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/migration.rb:685:in `each'
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/migration.rb:685:in `detect'
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/migration.rb:685:in `migrate'
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/migration.rb:570:in `up'
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/migration.rb:551:in `migrate'
/home/ela/.rvm/gems/ruby-2.2.1@rails3.2.13/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:193:in `block (2 levels) in '
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/home/ela/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/home/ela/.rvm/rubies/ruby-2.2.1/bin/rake:33:in `
' Tasks: TOP => db:migrate

有人请帮帮我.提前致谢.



1> vipin..:

安装nodejs

sudo apt-get install nodejs

然后用

bundle install

推荐阅读
无名有名我无名_593
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有