ruby – windows上的gems错误 – “openpath:pathname too long
我最近在运行gems或bundler时遇到此错误.
我唯一记得我最近改变的是升级我的git版本. 我使用MINGW32作为外壳,这已经使用了一年多. 我已经确定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 解决方法
此错误消息来自Ruby中的
dln_find.c 文件,当它尝试生成比系统上的MAXPATHLEN值更长的路径时会抛出此错误.
根据this MSDN reference,Windows API中许多函数的最大路径长度只有248个字符 – 因此,我猜想在Ruby-for-Windows源中MAXPATHLEN定义为248. (或者,如果没有另外定义,dln_find.c源将其定义为1024.) 如果您是程序员,可以通过多种方式在程序中解决此问题,但用户级别的解决方案可能是您必须使用名称较短的目录. (那么,什么目录需要更短?嗯,有错误消息告诉你它正在尝试加载哪个文件,这是chcp和git.也许你的git升级将其目录名改为过长的东西,你需要将它移动到一个名字较短的地方?或者……看起来这个查找代码可能会迭代你的PATH环境变量中的每个条目并检入它并且如果任何给定的可能性太长则抛出“太长”错误 – – 也许你的PATH已损坏或有一个新的很长的条目?) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |