Posts match “ bug-fix ” tag:

rails3.1rc1在服务器上运行报Could not find a JavaScript

rail3.1rc1在服务器上运行时报以下的错误信息:

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

解决方式是在gemfile中加入

  gem 'therubyracer-heroku', '0.8.1.pre3'

rails3rc1在安装rspec-rails时碰到报错

今天在rails3rc1下安装rspec-rails, 提示了以下错误

Invalid gemspec in [/Users/ZoOL/.rvm/gems/ruby-1.8.7-p334/specifications/rspec-core-2.6.2.gemspec]: invalid date format in specification: "2011-05-21 00:00:00.000000000Z"

解决方法

找到specifications/rspec-core-2.6.2.gemspec, 将下面这行注释

s.date = %q{2011-05-21 00:00:00.000000000Z}

另外在执行rake命令时, 遇到了下面的报错信息

undefined method `prerequisites' for nil:NilClass

google后发现是rspec-rails版本的问题, 使用2.6.1.beta1版本以上就好了, 编辑Gemfile

  gem 'rspec-rails', '~> 2.6.1.beta'

修复安装gems时Errno::ETIMEDOUT: Operation timed out - connect(2)的错误

这两天更新gems出现下面的错误

➜  ~  gem install rails      
ERROR:  Could not find a valid gem 'rails' (>= 0) in any repository
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    Errno::ETIMEDOUT: Connection timed out - connect(2) (http://rubygems.org/latest_specs.4.8.gz)

经检查和GFW无关,是rubygems的DNS
调整问题

问题解决的最好方法方法

使用google的DNS
8.8.8.8 / 8.8.4.4

另一种解决方式

修改rubygems的source源

#删除原有gem source

gem source -r http://rubygems.org/
gem source -r http://production.s3.rubygems.org/ 

#增加新source源

gem source -a  http://production.s3.rubygems.org.s3.amazonaws.com/

ubuntu下mysql字符集设置错误

原来在rhel下设置了

character-set-server = utf8

但在ubuntu下不起作用,报错:

mysql: unknown variable 'character-set-server=utf8'

换为以下设置解决问题:

default-character-set = utf8

生产环境下rake db:migrate报错database is not configured

我在服务器上运行了下面的命令

RAILS_ENV=production rake db:migrate

结果报错

> ** Invoke db:migrate (first_time)

> ** Invoke environment (first_time)

> ** Execute environment

> rake aborted!

> proudction database is not configured

google后得到解决方法,将RAILS_ENV参数放到最后

rake db:migrate RAILS_ENV=production

ubuntu下gem安装pg出错

在安装pg时,系统报了如下的错误

/home/zool/.rvm/rubies/ruby-1.8.7-p302/bin/ruby extconf.rb 
checking for pg_config... no
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/zool/.rvm/rubies/ruby-1.8.7-p302/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib

请教GOOGLE大神后,找到如下解决方案

sudo apt-get install libpq-dev libpq5

安装更新后解决问题

gem install mysql2 报错

在服务器上安装mysql时,报错,安装失败, 内容如下

> sudo gem install mysql  
> Building native extensions.  This could take a while...   
> ERROR:  Error installing mysql:  
> ERROR: Failed to build gem native extension.  
> /usr/local/bin/ruby extconf.rb install mysql     
> checking for mysql_query() in -lmysqlclient... no      
> checking for main() in -lm... yes   
> checking for mysql_query() in -lmysqlclient... no   
> checking for main() in -lz... yes   
> checking for mysql_query() in -lmysqlclient... no   
> checking for main() in -lsocket... no   
> checking for mysql_query() in -lmysqlclient... no   
> checking for main() in -lnsl... yes   
> checking for mysql_query() in -lmysqlclient... no   
> extconf.rb failed  
> Could not create Makefile due to some reason, probably lack of   
> necessary libraries and/or headers.  Check the mkmf.log file for more   
> details.  You may need configuration options.   

> Provided configuration options:   
>    --with-opt-dir   
>    --without-opt-dir   
>    --with-opt-include   
>    --without-opt-include=${opt-dir}/include   
>    --with-opt-lib   
>    --without-opt-lib=${opt-dir}/lib   
>    --with-make-prog   
>    --without-make-prog 
>    --srcdir=. 
>    --curdir 
>    --ruby=/usr/local/bin/ruby 
>    --with-mysql-config 
>    --without-mysql-config 
>    --with-mysql-dir 
>    --without-mysql-dir   
>    --with-mysql-include   
>    --without-mysql-include=${mysql-dir}/include   
>    --with-mysql-lib   
>    --without-mysql-lib=${mysql-dir}/lib   
>    --with-mysqlclientlib   
>    --without-mysqlclientlib   
>    --with-mlib   
>    --without-mlib   
>    --with-mysqlclientlib   
>    --without-mysqlclientlib   
>    --with-zlib   
>    --without-zlib   
>    --with-mysqlclientlib   
>    --without-mysqlclientlib   
>    --with-socketlib   
>    --without-socketlib   
>    --with-mysqlclientlib   
>    --without-mysqlclientlib   
>    --with-nsllib   
>    --without-nsllib   
>    --with-mysqlclientlib   
>    --without-mysqlclientlib    

经检查,是由于我将mysql调整了安装目录导致, 执行下面代码后安装成功.

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config