简体   繁体   English

Rails控制台错误:“加载错误”“ NoMethodError”

[英]rails console error: 'load error' 'NoMethodError'

I installed rails, but when I try to run $rails console I get an error. 我安装了rails,但是当我尝试运行$ rails console时出现错误。 Can anybody tell me what should I do?(I know similar questions have been asked before, but I still don't know what exactly should I do.) If that helps, I have ubuntu 13.10, ruby 2.1.2, rails 4.1.1. 谁能告诉我该怎么办?(我知道以前也曾问过类似的问题,但我仍然不知道该怎么办。)如果有帮助,我可以使用ubuntu 13.10,ruby 2.1.2,rails 4.1。 1。 The error is pretty long, this is how it starts: 错误很长,这是它的开始方式:

Loading development environment (Rails 4.1.1)
load error: /home/u12/.rvm/rubies/ruby-2.1.2/.irbrc
NoMethodError: undefined method `split' for nil:NilClass
    /home/u12/.rvm/scripts/irbrc.rb:45:in `<top (required)>'
    /home/u12/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'

First try: 第一次尝试:

rvm get stable

If it doesn't work: 如果不起作用:

As stated in this previous thread: 如上一个线程所述:

Load error when running rails console 运行Rails控制台时出现加载错误

The problem might be that the ENV['GEM_HOME'] is nil. 问题可能是ENV ['GEM_HOME']为零。

Spring seems to be the problem and a small incompatibility with rvm. Spring似乎是问题所在,并且与rvm有点不兼容。

Just change the env variable to a blank string. 只需将env变量更改为空白字符串即可。

If you encounter this problem you should restart you computer. 如果遇到此问题,应重新启动计算机。 If that does not fix it read on. 如果不能解决问题,请继续阅读。

The bin/spring file sets ENV["GEM_HOME"] to a non blank string bin / spring文件将ENV [“ GEM_HOME”]设置为非空白字符串

bin/spring 斌/春天

11 ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
12 ENV["GEM_HOME"] = "spring"
13 Gem.paths = ENV

It seems one of your files tries to call the split method on a variable that is nil instead of a string. 似乎您的文件之一试图在nil而不是字符串变量上调用split方法。 You should either check that it's actually a string before calling split, or use the to_s method to make sure it never raise an exeception. 您应该在调用split之前检查它是否实际上是一个字符串,或者使用to_s方法确保它永远不会引发错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM