创建一个名为' con'的目录。

时间:2014-05-24 10:54:14

标签: ruby windows directory

在Ruby控制台中,每当我尝试创建一个文件夹时,我都会收到以下错误:

> FileUtils.mkdir_p('con/')

Errno::ENOTDIR: Not a directory - con
    from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:245:in `mkdir'
    from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:245:in `fu_mkdir'
    from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:219:in `block (2 levels) in mkdir_p'
    from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:217:in `reverse_each'
    from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:217:in `block in mkdir_p'
    from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:203:in `each'
    from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:203:in `mkdir_p'
    from (irb):21
    from C:/RailsInstaller/Ruby2.0.0/bin/irb:12:in `<top (required)>'
    from -e:1:in `load'
    from -e:1:in `<main>'

其他名称不会发生。

为什么会这样?

我使用Ruby 2.0.0。

1 个答案:

答案 0 :(得分:4)

您似乎正在使用Windows。

在Windows中,con是设备的保留名称(console)。您不能将其用作目录/文件名。

请参阅MS-DOS Device Driver Names Cannot be Used as File Names