Is there a location for custom Ruby libraries to be stored so Ruby can find them?

I have written a module that has some generic, reusable code that I would like to be able to use in other projects. Is there a place I could put this file on computer so that Ruby can find it regardless of where I saved the file that is including it? I am using a Mac.


There's no standard place to put code like this. You could put all your code in a gem and install the gem, or create a directory to put this code in. Once you create the directory, alter the LOAD_PATH global variable to include this directory. You can do this either in each script that uses these, or with the RUBYOPT environment variable. For example, you could put ~/my_ruby_stuff in your path and put your files there. One warning if you do that, make sure the path you add is at the end of the gem path and try to avoid any name conflicts with existing Ruby libraries or gems.

Consider making a "gem" out of your code. The advantages are: separate project, better defined interface, separate source control, can share with other developers in your company, etc

Need Your Help

Print API for Chrome Extensions

google-chrome google-chrome-extension

Is there a Chrome Extension API that I can use to interact with the printing options for a page? I've checked Chrome's extension API's, but I can't seem to find anything on interacting with printing

Why doesn't my list comprehension code sort things immediately?

python nltk

My question: Why do I have to evaluate the code twice for it to actually work? I want to filter just the scores that are above 20. I don't know why I have to evaluate it twice for it to actually wo...