# FileUtils.mv Pointless Errno::ENOENT

**URL:** <https://www.ruby-forum.com/t/fileutils-mv-pointless-errno-enoent/175025>\
**Category:** Ruby\
**Created:** [September 6, 2009, 11:13am UTC](https://www.ruby-forum.com/t/fileutils-mv-pointless-errno-enoent/175025 "2009-09-06T11:13:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [September 6, 2009, 11:13am UTC](https://www.ruby-forum.com/t/fileutils-mv-pointless-errno-enoent/175025/1 "2009-09-06T11:13:17Z")

</div>

Noticed that when $DEBUG=true, any FileUtils.mv call produces two  
(rescued) exceptions:

$ ls  
sim-1.0.0.zip  
$ irb

> > $DEBUG=true  
> > =\> true
> 
> > FileUtils.mv(‘sim-1.0.0.zip’, ‘sm.zip’)  
> > Exception `Errno::ENOENT' at /usr/lib/ruby/1.8/fileutils.rb:1420 - No such file or directory - sm.zip Exception`Errno::ENOENT’ at /usr/lib/ruby/1.8/fileutils.rb:1200 - No  
> > such file or directory - sm.zip

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [September 11, 2009, 8:55pm UTC](https://www.ruby-forum.com/t/fileutils-mv-pointless-errno-enoent/175025/2 "2009-09-11T20:55:15Z")

</div>

Thomas S. wrote:

> Noticed that when $DEBUG=true, any FileUtils.mv call produces two  
> (rescued) exceptions:

It’s probably checking for existence before doing the mv. why 2, I have  
no idea 🙂  
-r

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [September 12, 2009, 10:09pm UTC](https://www.ruby-forum.com/t/fileutils-mv-pointless-errno-enoent/175025/3 "2009-09-12T22:09:15Z")

</div>

Thomas S. wrote:

> Noticed that when $DEBUG=true, any FileUtils.mv call produces two  
> (rescued) exceptions:
> 
> $ ls  
> sim-1.0.0.zip  
> $ irb
> 
> > > $DEBUG=true  
> > > =\> true
> > 
> > > FileUtils.mv(‘sim-1.0.0.zip’, ‘sm.zip’)  
> > > Exception `Errno::ENOENT' at /usr/lib/ruby/1.8/fileutils.rb:1420 - No such file or directory - sm.zip Exception`Errno::ENOENT’ at /usr/lib/ruby/1.8/fileutils.rb:1200 - No  
> > > such file or directory - sm.zip

/usr/lib/ruby/1.8/fileutils.rb:

```
  def fu_same?(a, b) #:nodoc:
    if fu_have_st_ino?
      st1 = File.stat(a)

```

1420: st2 = File.stat(b)

```
  def lstat
    if dereference?

```

1200: @lstat ||= File.stat(path())  
else  
@lstat ||= File.lstat(path())  
end  
end
