2016-01-03 251 views
1

我想在Ubuntu 15(64位)中安裝RoR。我已經完成了大部分安裝過程,比如安裝rvm,ruby,mysql服務器,創建gemset。Ruby on Rails安裝 - Ubuntu 15

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/[email protected]/gems/activesupport-3.2.13/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now 
/home/ela/.rvm/gems/[email protected]/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/[email protected]/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require' 
    from /home/ela/.rvm/gems/[email protected]/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each' 
    from /home/ela/.rvm/gems/[email protected]/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require' 
    from /home/ela/.rvm/gems/[email protected]/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each' 
    from /home/ela/.rvm/gems/[email protected]/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require' 
    from /home/ela/.rvm/gems/[email protected]/gems/bundler-1.11.2/lib/bundler.rb:99:in `require' 
    from /home/ela/Documents/first_app/config/application.rb:7:in `<top (required)>' 
    from /home/ela/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/commands.rb:53:in `require' 
    from /home/ela/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/commands.rb:53:in `block in <top (required)>' 
    from /home/ela/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap' 
    from /home/ela/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>' 
    from script/rails:6:in `require' 
    from script/rails:6:in `<main>' 

我的寶石文件::

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' 寶石也因此同樣的錯誤我刪除了這兩個寶石。然後我在mysql適配器中出錯。

rails s 
/home/ela/.rvm/gems/[email protected]/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/[email protected]/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/[email protected]/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:3:in `<top (required)>' 
    from /home/ela/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require' 
    from /home/ela/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require' 
    from /home/ela/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency' 
    from /home/ela/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require' 
    from /home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection' 
    from /home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection' 
    from /home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec' 
    from /home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection' 
    from /home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>' 
    from /home/ela/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval' 
    from /home/ela/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook' 
    from /home/ela/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks' 
    from /home/ela/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `each' 
    from /home/ela/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks' 
    from /home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/base.rb:720:in `<top (required)>' 
    from /home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/railtie.rb:88:in `block in <class:Railtie>' 
    from /home/ela/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec' 
    from /home/ela/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run' 
    from /home/ela/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers' 
    from /home/ela/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each' 
    from /home/ela/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers' 
    from /home/ela/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!' 
    from /home/ela/.rvm/gems/[email protected]/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 `<top (required)>' 
    from /home/ela/Documents/first_app/config.ru:3:in `require' 
    from /home/ela/Documents/first_app/config.ru:3:in `block in <main>' 
    from /home/ela/.rvm/gems/[email protected]/gems/rack-1.4.7/lib/rack/builder.rb:51:in `instance_eval' 
    from /home/ela/.rvm/gems/[email protected]/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 `<main>' 
    from /home/ela/.rvm/gems/[email protected]/gems/rack-1.4.7/lib/rack/builder.rb:40:in `eval' 
    from /home/ela/.rvm/gems/[email protected]/gems/rack-1.4.7/lib/rack/builder.rb:40:in `parse_file' 
    from /home/ela/.rvm/gems/[email protected]/gems/rack-1.4.7/lib/rack/server.rb:200:in `app' 
    from /home/ela/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in `app' 
    from /home/ela/.rvm/gems/[email protected]/gems/rack-1.4.7/lib/rack/server.rb:304:in `wrapped_app' 
    from /home/ela/.rvm/gems/[email protected]/gems/rack-1.4.7/lib/rack/server.rb:254:in `start' 
    from /home/ela/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in `start' 
    from /home/ela/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>' 
    from /home/ela/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap' 
    from /home/ela/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>' 
    from script/rails:6:in `require' 
    from script/rails:6:in `<main>' 

所以我改變了我的寶石mysql2寶石版< 0.3

rake db:migrate --trace 
/home/ela/.rvm/gems/[email protected]/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/[email protected]/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `to_sql' 
/home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/database_statements.rb:38:in `select_values' 
/home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/migration.rb:587:in `get_all_versions' 
/home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/migration.rb:745:in `migrated' 
/home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/migration.rb:668:in `current_version' 
/home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/migration.rb:685:in `block in migrate' 
/home/ela/.rvm/gems/ruby[email protected]/gems/activerecord-3.2.13/lib/active_record/migration.rb:685:in `each' 
/home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/migration.rb:685:in `detect' 
/home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/migration.rb:685:in `migrate' 
/home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/migration.rb:570:in `up' 
/home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/migration.rb:551:in `migrate' 
/home/ela/.rvm/gems/[email protected]/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:193:in `block (2 levels) in <top (required)>' 
/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 `<main>' 
Tasks: TOP => db:migrate 

有人請幫助我。提前致謝。

回答

5

安裝的NodeJS

sudo apt-get install nodejs 

然後用

bundle install 
+0

感謝您的幫助。它的工作現在。在安裝nodejs之後,我做了一個小改動,那就是gem「mysql2」,「〜> 0.3.20」 – user2194445