Windows上的gems错误 - “openpath:pathname too long”

时间:2011-12-01 17:09:03

标签: ruby windows git rubygems

我最近在运行gems或bundler时遇到此错误。 我唯一记得我最近改变的是升级我的git版本。

我使用MINGW32作为shell,这已经有效了一年多。

我已经确定git在我的PATH中,现在我不确定下一步该找什么。

我可以接下来解决这个问题的下一步是什么?

这是我得到的输出的一个例子。此示例显示了heroku gem,但在运行bundle install

时得到了相同的结果
$ heroku console
openpath: pathname too long (ignored)
        Directory ""
        File "chcp"
openpath: pathname too long (ignored)
        Directory ""
        File "git"
c:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-2.14.0/lib/heroku/helpers.rb:111:in ``': No such file or directory -  git --version  (Errno::ENOENT)
        from c:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-2.14.0/lib/heroku/helpers.rb:111:in `has_git?'
        from c:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-2.14.0/lib/heroku/helpers.rb:116:in `git'
        from c:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-2.14.0/lib/heroku/command/base.rb:192:in `git_remotes'
        from c:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-2.14.0/lib/heroku/command/base.rb:170:in `extract_app_in_dir'
        from c:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-2.14.0/lib/heroku/command/base.rb:162:in `extract_app'
        from c:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-2.14.0/lib/heroku/command/run.rb:72:in `console'
        from c:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-2.14.0/lib/heroku/command.rb:114:in `run'
        from c:/Ruby192/lib/ruby/gems/1.9.1/gems/heroku-2.14.0/bin/heroku:14:in `<top (required)>'
        from c:/Ruby192/bin/heroku:19:in `load'
        from c:/Ruby192/bin/heroku:19:in `<main>'

,这是上面引用的helpers.rb中的第111行。

def has_git?
  %x{ git --version } #this is 111
  $?.success?
end

1 个答案:

答案 0 :(得分:4)

此错误消息来自Ruby中的dln_find.c文件,当它尝试生成长于系统上MAXPATHLEN值的路径时会抛出此错误。

根据this MSDN reference,Windows API中许多函数的最大路径长度只有248个字符 - 因此,我猜测MAXPATHLEN在Ruby-for中定义为248 -Windows来源。 (或者,如果没有另外定义,dln_find.c源将其定义为1024.)

如果您是程序员,可以通过多种方式在程序中解决此问题,但是用户级别的解决方案可能是您必须使用名称较短的目录。

(那么,什么目录需要更短?嗯,有错误消息告诉你它正在尝试加载哪个文件,即chcpgit。也许你的git升级改变了它的目录名称过长了,你需要将它移动到一个较短名称的地方吗?或者......看起来这个查找代码可能会迭代你PATH环境变量中的每个条目并检入它如果任何给定的可能性太长,则抛出“太长”的错误 - 也许您的PATH已损坏或有一个新的非常长的条目?)