# How to use Get on a folder

Documentation flaw introduced before 9.0 and persisting through V11.0.0

In the documentation for Get it says:

If the file found by <<name is a directory, the Wolfram Language will try to load the file init.m in that directory.

So I make a folder called test with a single file called init.m whose only contents are

Print["It works."]


In the same directory as the folder test I open a notebook and run

SetDirectory[NotebookDirectory[]];
<<test


which returns Get::noopen: Cannot open test. (Note that <<test/init.m works as expected).

What gives?

Edit: This has been filed as a documentation bug to Wolfram.

• @Kuba But also Get["test", Path -> {NotebookDirectory[]}] does not work. I think it should? – Mr.Wizard Feb 20 '15 at 19:59
• @Mr.Wizard Good point :/ – Kuba Feb 20 '15 at 20:07
• @Kuba Sorry, I didn't understand that last comment. – Mr.Wizard Feb 20 '15 at 20:17
• related – Kuba Feb 21 '15 at 9:31
• related: 64739 – Kuba Feb 21 '15 at 9:56

### Shortly:

automatic behavior happens when you use a backtick .

I think there are multiple typos in docs for Get. I added Test2 dir and and Test2\init.m file to the first path in $Path. In my case Links dir. According to Get documentation <<Test2 should get it. It won't but <<Test2 will. Additionally this will work, even without SetDirectory: Get["Test", Path -> {NotebookDirectory[]}]  and this will work automatically too: SetDirectory @ NotebookDirectory[]; << Test  So the difference is in . ### More accurate in description is tutorial/FilesForPackages: ### The typical sequence of files looked for by <<name: • name.mx file in DumpSave format • name.mx/$SystemID/name.mx file in DumpSave format for your computer system

• name.m file in Wolfram Language source format

• name/init.m initialization file for a particular directory

• dir/… files in other directories specified by \$Path

<…>

If name is a directory, then the Wolfram Language will try to load the initialization file init.m in that directory.

So the point is that automatic behaviour happens when you use a backtick .

• I think this question should be marked as a documentation bug. The behavior you illustrate is the one we are all familiar with from Get and Needs. – Mr.Wizard Feb 20 '15 at 21:38
• Another case in <<nameis: name/Kernel/init.m – Murta Feb 21 '15 at 1:12
• @Kuba thanks for getting to the bottom of this...I filed a bug. – Ian Hincks Feb 21 '15 at 5:06
• @Kuba: I think Murta just wanted to note that name/Kernel/init.m is another file which Mathematica tries to open when you use Get["name"]. I think that this is the older convention for where Mathematica looks for such a file and it will use that before name/init.m if both exist. The answer to "why" is of course pure convention, but I guess it has to do with the fact that WRI wants you to be able to distinguish between FrontEnd/init.m and Kernel/init.m within your package... – Albert Retey Feb 21 '15 at 11:17
• @Kuba, got the reply from Wolfram, they said someone had already filed it. – Ian Hincks Mar 3 '15 at 23:09