Rails控制台没有加载? y(Errno :: ENOENT)

时间:2013-02-07 19:56:20

标签: ruby-on-rails ruby rails-console

当我尝试加载rails控制台时,我突然收到以下错误消息。我刚刚将数据库切换到postgres,这给了我一些问题(虽然我必须承认我比mysql好多了!),所以我假设这与此有关。有什么想法吗?

y (Errno::ENOENT)/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require': No such file or directory - /usr/local/lib/?
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `block in require'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/processing.rb:3:in `<top (required)>'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `block in require'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:5:in `<top (required)>'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `block in require'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/environment.rb:1:in `<top (required)>'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/sprockets/railtie.rb:23:in `block in <class:Railtie>'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:30:in `instance_exec'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:30:in `run'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:54:in `each'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:54:in `run_initializers'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application.rb:136:in `initialize!'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/benyorke/rubystore/config/environment.rb:6:in `<top (required)>'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application.rb:103:in `require'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application.rb:103:in `require_environment!'
    from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/commands.rb:40:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

2 个答案:

答案 0 :(得分:0)

我相信这可能是Ruby 1.9.3-p327的一个错误,它已经被Ruby 1.9.3-p385修复了。升级到1.9.3-p385是否适合您?

在此错误消息中看起来很奇怪,并且类似于我一直遇到的问题,是路径末尾的问号:No such file or directory - /usr/local/lib/?。我几周前从1.9.3-p194升级到1.9.3-p327后,我收到了与ruby的require和路径带有问号,符号或路径末尾的其他随机字符相关的类似奇怪错误消息。然而,这些问题非常零星,而且大约在同一时间我们遇到了一些硬件故障,因此很难追查。

今天问题始终在一个特定的环境中发生,所以我能够做一些额外的调试。更新到1.9.3-p385似乎已经修复了它,但考虑到我遇到的问题的零星性质,我不完全是100%,这实际上是修复。我也不完全确定这是否与你所遇到的问题相同。路径中的神秘问号只是让它看起来像它可能是相关的。以下是我们获得的错误类型的几个示例:

No such file or directory - /srv/shared/rails/internal/admin/vendor/bun@

No such file or directory - /srv/shared/rails/internal/admin/vendor?

如果它与我遇到的相同问题有关,但1.9.3-p385升级无法解决,还有一些其他注意事项需要探讨:

  • 我今天能够在1.9.3-p327和1.9.3-p374上重现这个问题。但是,问题似乎没有出现在1.9.3-p194,1.9.3-p286和1.9.3-p385上。
  • 您是否在gem载入路径中的任何位置使用符号链接?例如,我们使用Bundler将gem安装到每个应用程序内的本地vendor/bundle路径中。但vendor/bundle实际上是另一个位置的符号链接(这与Capistrano部署设置有关)。我相信符号链接可能起作用。在今天的测试中,如果我没有使用符号链接,那么问题就会在所有版本的ruby上消失。
  • 您使用bundler-exec吗?在另一个偶然发生这个问题的场合,绕过别名bundler-exec似乎也神奇地解决了问题,但今天的问题甚至没有触及bundler-exec,所以我不太确定。
  • 大多数情况下,我们的问题非常随机(在尝试运行相同命令后会消失),但有时候,问题会持续一个小时或更长时间才会消失。
  • 有关我们系统的一些信息:
    • 64位RedHat Enterprise Linux 6
    • Bundler 1.2.3
    • Rubygems 1.2.5(也发生在1.2.4下)
    • rbenv

但就像我说的那样,这个问题也恰好与一些硬件磁盘故障和一般服务器难以理解,所以我还不确定这是Ruby问题还是发生了什么。但是这里希望1.9.3-p385实际修复它。

答案 1 :(得分:0)

很抱歉没有更新这个帖子 - 我实际上已经在后台工作了几个星期了。我在网上找不到任何关于此的信息,所以我将尽可能详细地发布解决方案。


问题

我遇到的问题是我无法访问rails控制台,每次重新启动计算机时都必须手动启动postgres服务器。我已经解决了这个问题,因为我已经使用了几个星期了

关于控制台,我使用了herokus控制台。通过将我的应用程序推送到heroku(免费),我不仅可以在网络上查看它(任何机器),而且可以在我的机器上运行

$ heroku run console

并获得对控制台的访问权限。现在这不是一个完美的解决方案,因为我无法在我的机器上操纵数据,但它为我节省了很多次

关于服务器我跑了

$ brew info postgres

给了我手动重启服务器的命令

You should reload postgresql:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

解决方案

说实话,我已经运行了几十次我能找到的命令,而今天它已经运行了。我不知道我是否在制作拼写错误,以无效的顺序进行拼写,混合pg / postgres / postgresql或者我在下面做了什么

使用此解决方案时,它将清除所有数据库。迁移将能够重建结构,但任何数据都将丢失

1。更新了Homebrew

$ brew update

如果您没有家酿,请查看此页面以获取安装说明(保存好我的脖子,包括minimagick imagemagick和postgres!):http://mxcl.github.com/homebrew/ < / p>

2。删除了postgresql

$ brew rm postgresql --force

3。安装postgreql

$ brew install postgresql

这是参考postgres的第一步。在线查看时,我遇到了使用postgresql,postgres和pg的命令。 Postgresql指的是实际的PostgreSQL程序。 postgres和pg是ruby gems,我们稍后会介绍

4。 Ran建议命令

运行“$ brew install postgres”后,会有很多信息给你。请务必仔细阅读,因为它会建议运行什么命令。使用这些建议来查找我在下面引用的命令。 如果您稍后需要访问此信息,只需运行

即可
$ brew info postgresql

初始化数据库

$ initdb file/path

设置自动启动器

$ cp file/path ~ LaunchAgents/file/path

最初启动postgresql

$ launchctl load file/path
$ pg_ctl-D file/oath

5。下载Postgres.app

虽然据我所知这似乎是多余的,但这就是我的mac上工作的原因。访问http://postgresapp.com下载

6。安装宝石

有两个宝石 - postgres和pg。我在我的gemfile中需要pg并运行了一个bundle install命令,但是在我的机器上安装postgres之前它仍然给我带来了问题 - 即使我的gemfile中不需要它,rails控制台似乎没有安装至少

在宝石文件中

gem 'pg'

在终端窗口中运行bundle install命令

$ bundle install

Sudo安装postgres gem

$ sudo gem install postgres

此时一切都应该有效。您应该能够重启机器并且没有任何问题!