rails错误记录

阅读更多

错误1

在创建rails的数据库时,rake db:create RAILS_ENV='development'出现如下错误:

Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.

/home/liuxiaoqin/ruby/depot/config/application.rb:7

/home/liuxiaoqin/ruby/depot/Rakefile:5

 

 

解决方法:

1. 首先安装libv8

gem install 'libv8'

在安装libv8出错,

 

nable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
Traceback (most recent call last):
  File "build/gyp/gyp", line 15, in ?
    import gyp
  File "build/gyp/pylib/gyp/__init__.py", line 8, in ?
    import gyp.input
  File "build/gyp/pylib/gyp/input.py", line 14, in ?
    import gyp.common
  File "build/gyp/pylib/gyp/common.py", line 375
    with open(source_path) as source_file:
            ^
SyntaxError: invalid syntax

 

 看上去是GCC的原因实际是python版本的问题,为了跳过这个问题,

使用如下命令:

gem install libv8 --version=3.11.8.3

 

2. 安装rubytracer

gem install therubyracer --version=0.10.2

 

3.安装execjs

gem install execjs

 

4.在Gemfile中添加:

 

gem 'therubyracer'
gem 'execjs'

 

5. bundle install

6.rake db:create RAILS_ENV='development'

成功!

 

错误2

 

/Library/Ruby/Gems/1.8/gems/rack-1.4.1/lib/rack/handler/thin.rb:1:in `require': no such file to load -- thin (LoadError)
	from /Library/Ruby/Gems/1.8/gems/rack-1.4.1/lib/rack/handler/thin.rb:1
	from /Library/Ruby/Gems/1.8/gems/rack-1.4.1/lib/rack/handler.rb:20:in `const_get'
	from /Library/Ruby/Gems/1.8/gems/rack-1.4.1/lib/rack/handler.rb:20:in `get'
	from /Library/Ruby/Gems/1.8/gems/rack-1.4.1/lib/rack/server.rb:269:in `inject'
	from /Library/Ruby/Gems/1.8/gems/rack-1.4.1/lib/rack/handler.rb:20:in `each'
	from /Library/Ruby/Gems/1.8/gems/rack-1.4.1/lib/rack/handler.rb:20:in `inject'
	from /Library/Ruby/Gems/1.8/gems/rack-1.4.1/lib/rack/handler.rb:20:in `get'
	from /Library/Ruby/Gems/1.8/gems/rack-1.4.1/lib/rack/server.rb:269:in `server'
	from /Library/Ruby/Gems/1.8/gems/railties-3.2.8/lib/rails/commands/server.rb:59:in `start'
	from /Library/Ruby/Gems/1.8/gems/railties-3.2.8/lib/rails/commands.rb:55
	from /Library/Ruby/Gems/1.8/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
	from /Library/Ruby/Gems/1.8/gems/railties-3.2.8/lib/rails/commands.rb:50
	from ./script/rails:6:in `require'
	from ./script/rails:6

 在GemFile中添加 gem 'thin'即可。

 

Rails中安装mysql2错误

gem install mysql2 -- --sicdir=/usr/local/mysql/include/

即可

 

你可能感兴趣的:(rails)