lanvige
2009-09-02 23:41
浏览 249
已采纳

Ubuntu 下配置Ruby1.9.1,Rails2.3.3出错

安装一切正常
ruby -v; gem -v; rails -v都能出来正确的结果。

但用rails project时,就出错了,错误原因

$ rails hello
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.3/lib/rails_generator/options.rb:32:in default_options': [b][color=red]undefined methodwrite_inheritable_attribute' for Rails::Generator::Base:Class (NoMethodError)[/color][/b]
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.3/lib/rails_generator/base.rb:90:in <class:Base>'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.3/lib/rails_generator/base.rb:85:in
module:Generator'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.3/lib/rails_generator/base.rb:48:in <module:Rails>'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.3/lib/rails_generator/base.rb:6:in
'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.3/lib/rails_generator.rb:34:in require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.3/lib/rails_generator.rb:34:in
'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.3/bin/rails:14:in require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.3/bin/rails:14:in
'
from /usr/local/ruby/bin/rails:19:in load'
from /usr/local/ruby/bin/rails:19:in
'

有很多关于这个问题的分析,全是英文 ,大意是[color=red]iconv.so未配置好[/color],已经一周了。实在搞不定,谁有办法,帮我一下啊。。第一次配环境。
[b]问题补充:[/b]
感谢night_stalker的回答,按你的提示,我去试了下

[code="sh"]require 'iconv'
返回
[color=red]=> true[/color][/code]

[code="java"]
sudo apt-get install iconv
[color=red]E: Couldn't find package iconv[/color]
[/code]

我试着用了你的 iconv-pure 后,还是不行,错误原因一样!
[b]问题补充:[/b]
[code="java"]
irb(main):001:0> require 'activesupport'

LoadError: no such file to load -- activesupport
from (irb):1:in require'
from (irb):1
from /usr/local/ruby/bin/irb:12:in
'
[/code]

看来应该是这个问题了,我先自己找下解决方案,麻烦你也帮我看下怎么解决吧。
谢谢了! :D
[b]问题补充:[/b]
再次感谢 night_stalker:

问题解决了,果然是activesupport引起的。
我运行了这个gem去安装
[code="java"]
$ sudo gem install activesupport
[/code]

安装完成后就好了,谢谢!

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • xenocide 2009-09-03 22:05
    已采纳

    那应该不是 iconv 的问题,先把 iconv-pure 删了吧 ……
    [code="sh"]sudo gem uninstall luikore-iconv-pure[/code]

    write_inheritable_attributes 是 ActiveSupport 的方法,试试:
    [code="ruby"]require 'activesupport'[/code]

    看看错误信息是什么 ……

    打赏 评论
  • xenocide 2009-09-03 17:06

    先打开 irb,看看是不是真的 iconv 的问题:
    [code="ruby"]require 'iconv'[/code]

    如果出错,那么就是 iconv 的问题。那么下面两种方案选一:

    [b]方案 A ,装上 iconv[/b]

    1.先把 iconv 装上:
    [quote="sh"]sudo apt-get install iconv[/quote]

    2.再转到 ruby 1.9.1 的源码目录
    [code="sh"]
    cd ext/iconv
    ruby extconf.rb
    make
    make install[/code]

    [b]方案 B ,试试我写的 iconv-pure[/b]

    [code="sh"]
    sudo gem install luikore-iconv-pure --source http://gems.github.com
    [/code]

    打赏 评论
  • xenocide 2009-09-03 22:44

    再试试这个:

    [code="ruby"]require 'rubygems'
    require 'activesupport'[/code]

    打赏 评论

相关推荐 更多相似问题