# Sanity Check

**URL:** <https://www.ruby-forum.com/t/sanity-check/72744>\
**Category:** Rails\
**Created:** [February 24, 2006, 8:31am UTC](https://www.ruby-forum.com/t/sanity-check/72744 "2006-02-24T08:31:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dylan\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/34f0e0/32.png) [@Dylan\_S](https://www.ruby-forum.com/u/Dylan_S)\
**Post date:** [February 24, 2006, 8:31am UTC](https://www.ruby-forum.com/t/sanity-check/72744/1 "2006-02-24T08:31:29Z")

</div>

Maaaaaaaaaaaaajor sanity check needed.  
I wrote a simple little plugin, and it wouldn’t load. I put some  
comments  
in it’s init.rb, and it didn’t even spit those out. So, I dug into the  
initializer.rb (/vendor/rails/railties/lib/initializer.rb) to see wtf is  
going on, and found the problem… but… can’t explain it. Here is the  
code in question:

```
    lib_path = File.join(directory, 'lib')
    init_path = File.join(directory, 'init.rb')
    has_lib = File.directory?(lib_path)
    #raise LoadError, "Dude, this path is ok: " + has_lib# =>

```

public/…/config/…/vendor/plugins/my\_plugin/init.rb  
has\_init = File.file?(init\_path)  
#raise LoadError, “WTF !..” + has\_init.to\_s# =\>  
False !!!

I’ve loaded the same situation up in IRB, and it works fine. Why is  
File.file?(init\_path) returning false !?  
Permissions are fine, the path is fine:  
public/…/config/…/vendor/plugins/my\_plugin/init.rb.

I’m losing my mind.

---

<div class="post-metadata">

**Author:** ![Dylan\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/34f0e0/32.png) [@Dylan\_S](https://www.ruby-forum.com/u/Dylan_S)\
**Post date:** [February 24, 2006, 4:22pm UTC](https://www.ruby-forum.com/t/sanity-check/72744/2 "2006-02-24T16:22:33Z")

</div>

What version of rails are you running? Plugins don’t work before  
0.14releases…

---

<div class="post-metadata">

**Author:** ![Dylan\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/34f0e0/32.png) [@Dylan\_S](https://www.ruby-forum.com/u/Dylan_S)\
**Post date:** [February 24, 2006, 6:24pm UTC](https://www.ruby-forum.com/t/sanity-check/72744/3 "2006-02-24T18:24:24Z")

</div>

I’m running Edge.

---

<div class="post-metadata">

**Author:** ![Dylan\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/34f0e0/32.png) [@Dylan\_S](https://www.ruby-forum.com/u/Dylan_S)\
**Post date:** [February 24, 2006, 7:11pm UTC](https://www.ruby-forum.com/t/sanity-check/72744/4 "2006-02-24T19:11:01Z")

</div>

So, I was able to hack this to work when I “hardcode” my absolute path  
in  
here… however, that is obviously the biggest hack ever.

Problem is, the path it’s getting from #{RAILS\_ROOT} is a relative path,  
and  
when it’s being applied within the context of the initializer.rb  
directory  
(which is actually in the /vendor/ directory), it’s not a valid URL  
anymore.

So, it looks as if you’re running Edge, and want plugins to work, your  
out  
of luck.  
Am I crazy ?

---

<div class="post-metadata">

**Author:** ![Dylan\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/34f0e0/32.png) [@Dylan\_S](https://www.ruby-forum.com/u/Dylan_S)\
**Post date:** [February 25, 2006, 4:57am UTC](https://www.ruby-forum.com/t/sanity-check/72744/5 "2006-02-25T04:57:29Z")

</div>

Dylan… don’t know if this will help you here or not, but I was  
commenting on the strange  
relative path that RAILS\_ROOT produces and Kris L. pointed out that  
one can do  
“File.expand\_path(RAILS\_ROOT)” to get the full path.

b

---

<div class="post-metadata">

**Author:** ![Dylan\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/34f0e0/32.png) [@Dylan\_S](https://www.ruby-forum.com/u/Dylan_S)\
**Post date:** [February 25, 2006, 7:34am UTC](https://www.ruby-forum.com/t/sanity-check/72744/6 "2006-02-25T07:34:35Z")

</div>

Thanks a bunch Ben. I just did a little test, and think I may have a  
possible bug in hand… but not sure.  
Here is what I did:

==============================

1. rails -v (rails 1.0.0)
2. rails test (in my home dir, now ive got  
/home/dylan/test/)
3. create plugin:  
(/home/dylan/test/vendor/plugins/custom/lib/custom.rb and

/home/dylan/test/vendor/plugins/custom/lib/init.rb)  
4) rake freeze\_edge

1. put debug in:  
(/home/dylan/test/vendor/rails/railties/lib/initializer.rb … line  
311:  
“raise LoadError, init\_path”)
2. output:  
“public/…/config/…/vendor/plugins/custom/init.rb”
3. put debug in:  
(/home/dylan/test/vendor/rails/railties/lib/initializer.rb … line  
312:  
“raise LoadError, has\_init.to\_s”)
4. output: “false”  
==============================

So, normal 1.0.0 install, froze edge, threw a valid plugin in  
/vendor/plugins, and initializer.rb can’t pick it up due to an invalid  
URL.

Do I have a point here, or am I doing something wrong ?
