升级到 ruby 1.9.2 后奇怪无法要求配置/启动
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3865515/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
strange inability to require config/boot after upgrading to ruby 1.9.2
提问by dan
I upgraded my ruby to 1.9.2 and now when I try to start up a Rails 2.3.5 app with script/server I get this error:
我将 ruby 升级到 1.9.2,现在当我尝试使用脚本/服务器启动 Rails 2.3.5 应用程序时,出现此错误:
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- script/../config/boot (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from script/server:2:in `<main>'
But script/server:2 definitely looks correct, and the file config/boot.rb exists in the right place.
但是 script/server:2 看起来肯定是正确的,并且文件 config/boot.rb 存在于正确的位置。
回答by UncleGene
Much simpler, does not require modification of all scripts:
更简单,不需要修改所有脚本:
Instead of:
代替:
script/server
call:
称呼:
./script/server
回答by Ian Fleeton
Replacing line 2 of script/server with
将脚本/服务器的第 2 行替换为
require File.expand_path('../../config/boot', __FILE__)works for me (taken from Rails 3)
对我来说有效(取自 Rails 3)
回答by shingara
it's because ruby 1.9.2 doesn't add the current directory in the LOAD_PATH.
这是因为 ruby 1.9.2 没有在 LOAD_PATH 中添加当前目录。
Add this that in top of your script/server file:
将此添加到脚本/服务器文件的顶部:
$: << File.dirname(__FILE__)
Or in your case:
或者在你的情况下:
$: << File.dirname(__FILE__) + '..'
回答by Jing
I met the exact same problem as described. Ubuntu 10.04 x64, Eclipse Helio, AptanaStudion2 with RadRail, Ruby 1.9.2, Rails 2.3.5 this doesn't work for me:
我遇到了与描述完全相同的问题。Ubuntu 10.04 x64、Eclipse Helio、AptanaStudion2 和 RadRail、Ruby 1.9.2、Rails 2.3.5 这对我不起作用:
require File.expand_path('../../config/boot', __FILE__)
This works for me
这对我有用
require File.expand_path(__FILE__)+ '/../../config/boot'
回答by user1391546
You might try to add the path source /usr/share/ruby-rvm/scripts/rvm
您可以尝试添加路径 source /usr/share/ruby-rvm/scripts/rvm
回答by Skyfall
Please check your root path before start padrino. like if your application in "C:\XXXXXXX\YYYYYYY\ZZZ-padrino" here and you are in "C:\XXXXXXX\YYYYYYY\" in command prompt then this error will occur. then you should in "C:\XXXXXXX\YYYYYYY\ZZZ-padrino".
请在启动 padrino 之前检查您的根路径。就像如果您的应用程序在“C:\XXXXXXX\YYYYYYY\ZZZ-padrino”中,而您在命令提示符中位于“C:\XXXXXXX\YYYYYYY\”中,则会发生此错误。那么你应该在“C:\XXXXXXX\YYYYYYY\ZZZ-padrino”中。
回答by blackrat
The $: << File.dirname(__File__) + '..'won't work since you'd get a dir of
该$: << File.dirname(__File__) + '..'不会工作,因为你会得到一个目录
'script..'
'脚本..'
Try
尝试
$: << File.join(File.dirname(__FILE__),'..')

