Undefined local variable or method '_FILE_'

Hi all,

Don’t know why but when I try to use the FILE variable I’m getting the
following error:

irb(main):001:0> puts File.dirname(FILE)
NameError: undefined local variable or method `FILE’ for main:Object
from (irb):1
from :0

I’ve got this error in Windows Seven and Ubuntu 10.04 LTS, both using
Ruby 1.8.7

Have also tried running the code in .rb file but get the same error.
Neither File.dirname(FILE) nor only FILE seems to work.

Looked about it everywhere but got nothing. Any idea…?

Regards,

metanolbr

On 09/16/2010 10:59 PM, Diogo Veras wrote:

I’ve got this error in Windows Seven and Ubuntu 10.04 LTS, both using
Ruby 1.8.7

Have also tried running the code in .rb file but get the same error.
Neither File.dirname(FILE) nor only FILE seems to work.

Looked about it everywhere but got nothing. Any idea…?

You need to use FILE (note the 2 underscores on each side).

-Jeremy

Jeremy B. wrote:

On 09/16/2010 10:59 PM, Diogo Veras wrote:

I’ve got this error in Windows Seven and Ubuntu 10.04 LTS, both using
Ruby 1.8.7

Have also tried running the code in .rb file but get the same error.
Neither File.dirname(FILE) nor only FILE seems to work.

Looked about it everywhere but got nothing. Any idea…?

You need to use FILE (note the 2 underscores on each side).

-Jeremy

It worked. Can’t believe, you are right, have no idea how I let this
pass.

Thank you a lot.

Regards

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs