# FileUtils.mv raises Errno::EPERM

**URL:** <https://www.ruby-forum.com/t/fileutils-mv-raises-errno-eperm/86739>\
**Category:** Development\
**Created:** [February 25, 2007, 7:07am UTC](https://www.ruby-forum.com/t/fileutils-mv-raises-errno-eperm/86739 "2007-02-25T07:07:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![GO\_Noguchi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/7cd45c/32.png) [@GO\_Noguchi](https://www.ruby-forum.com/u/GO_Noguchi)\
**Post date:** [February 25, 2007, 7:07am UTC](https://www.ruby-forum.com/t/fileutils-mv-raises-errno-eperm/86739/1 "2007-02-25T07:07:05Z")

</div>

e$BLn8}$H?=$7$^$9!#e(B

File.renamee$B$,e(BErrno::EXDEVe$B$K$J$k\>u67$G%G%#%l%/%H%j$r0\F0$9$k$He(B  
e$B%G%#%l%/%H%j$KBP$7$Fe(BFile.unlinke$B$7$h$&$H$7$F!"e(BFileUtils.mve$B$,e(B  
e$B%(%i!\<$K$J$j$^$9!#e(B

$ cd ~  
$ mkdir foo  
$ touch foo/1  
home/ruby/local/ruby185/bin/ruby -rfileutils -ve ‘FileUtils.mv(“foo”,  
“/tmp”)’  
ruby 1.8.5 (2007-02-14 patchlevel 20) [i386-freebsd6.1]  
$ /home/ruby/local/ruby185/lib/ruby/1.8/fileutils.rb:504:in `unlink': Operation not permitted - foo (Errno::EPERM) from /home/ruby/local/ruby185/lib/ruby/1.8/fileutils.rb:504:in `mv’  
from /home/ruby/local/ruby185/lib/ruby/1.8/fileutils.rb:1379:in  
`fu_each_src_dest' from /home/ruby/local/ruby185/lib/ruby/1.8/fileutils.rb:1393:in `fu\_each\_src\_dest0’  
from /home/ruby/local/ruby185/lib/ruby/1.8/fileutils.rb:1377:in  
`fu_each_src_dest' from /home/ruby/local/ruby185/lib/ruby/1.8/fileutils.rb:490:in `mv’  
from -e:1

e$BBEEv$+$I$&$+$o$+$j$^$;$s$,!"0l1~%Q%C%A$r$D$1$F$\*$-$^$9!#e(B

— fileutils.rb.orig Sun Feb 25 14:46:44 2007  
+++ fileutils.rb Sun Feb 25 14:53:16 2007  
@@ -484,7 +484,7 @@

# FileUtils.mv Dir.glob(‘test\*.rb’), ‘test’, :noop =\> true,

:verbose =\> true

# 

def mv(src, dest, options = {})

- fu\_check\_options options, :force, :noop, :verbose

- fu\_check\_options options, :force, :noop, :verbose, :secure  
fu\_output\_message “mv#{options[:force] ? ’ -f’ : ‘’}  
#{[src,dest].flatten.join ’ '}” if options[:verbose]  
return if options[:noop]  
fu\_each\_src\_dest(src, dest) do |s, d|  
@@ -501,7 +501,11 @@  
File.rename s, d  
rescue Errno::EXDEV  
copy\_entry s, d, true

- 

```
     File.unlink s

```

- 

```
     if options[:secure]

```

- 

```
       remove_entry_secure s, options[:force]

```

- 

```
     else

```

- 

```
       remove_entry s, options[:force]

```

- 

```
     end
   end
 rescue SystemCallError
   raise unless options[:force]

```

@@ -514,7 +518,7 @@  
module\_function :move

OPT\_TABLE[‘mv’] =

- OPT\_TABLE[‘move’] = %w( noop verbose force )

- OPT\_TABLE[‘move’] = %w( noop verbose force secure )

* * *

GO Noguchi[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![GO\_Noguchi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/7cd45c/32.png) [@GO\_Noguchi](https://www.ruby-forum.com/u/GO_Noguchi)\
**Post date:** [March 3, 2007, 1:51pm UTC](https://www.ruby-forum.com/t/fileutils-mv-raises-errno-eperm/86739/2 "2007-03-03T13:51:42Z")

</div>

ã€€é’æœ¨ã•ã‚“ã€ã“ã®ä»¶ã¯ã©ã†ã§ã—ã‚‡ã†ã‹ã€‚

At Sun, 25 Feb 2007 15:06:26 +0900,  
GO Noguchi wrote:

> ruby 1.8.5 (2007-02-14 patchlevel 20) [i386-freebsd6.1]  
> from -e:1
> 
> - fu\_check\_options options, :force, :noop, :verbose
> 
> - 
> 
> ```
> if options[:secure]
> 
> ```
> 
> OPT\_TABLE[‘mv’] =
> 
> - OPT\_TABLE[‘move’] = %w( noop verbose force )
> 
> - OPT\_TABLE[‘move’] = %w( noop verbose force secure )
> 
> def rename\_cannot\_overwrite\_file? #:nodoc:  
> /djgpp|cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY\_PLATFORM
> 
> * * *
> 
> GO Noguchi[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

–  
/  
/\_\_ \_\_ [Akinori.org](http://Akinori.org) / [MUSHA.org](http://MUSHA.org)  
/ ) ) ) ) / [FreeBSD.org](http://FreeBSD.org) / [Ruby-lang.org](http://Ruby-lang.org)  
Akinori MUSHA aka / (\_ / ( (\_\_( @ [iDaemons.org](http://iDaemons.org) / and.or.jp

“Different eyes see different things,  
Different hearts beat on different strings –  
But there are times for you and me when all such things agree”

---

<div class="post-metadata">

**Author:** ![GO\_Noguchi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/7cd45c/32.png) [@GO\_Noguchi](https://www.ruby-forum.com/u/GO_Noguchi)\
**Post date:** [March 3, 2007, 3:19pm UTC](https://www.ruby-forum.com/t/fileutils-mv-raises-errno-eperm/86739/3 "2007-03-03T15:19:01Z")

</div>

e$B@DLZ$G$9!#$&$C$+$j8D?M08$KJV?.$7$F$^$7$?!#=E$M=E$M$9$\_$^$;$s!#e(B

On 2007/03/03, at 21:50, Akinori MUSHA wrote:

> e$B!!@DLZ$5$s!"$3$N7o$O$I$&$G$7$g$&$+!#e(B

> > File.renamee$B$,e(BErrno::EXDEVe$B$K$J$k\>u67$G%G%#%l%/%H%j$r0\F0e(B  
> > e$B$9$k$He(B  
> > e$B%G%#%l%/%H%j$KBP$7$Fe(BFile.unlinke$B$7$h$&$H$7$F!"e(B  
> > FileUtils.mve$B$,e(B  
> > e$B%(%i!\<$K$J$j$^$9!#e(B

e$B$9$_$^$;$s!"$9$C$+$jK:$l$F$^$7$?!#e(B  
trunk, 1.8 branch e$B$H$b:#%3%_%C%H$7$^$7$?!#e(B
