I have a package at `/Users/me/Desktop/Mathematica/MyPackages/SamplePackage.m`

. It looks like this:

```
BeginPackage["SamplePackage`"]
bruh::usage = "bruh[ x] computes a simple function."
bruhpriv::usage = "bruhpriv[x] gives 5."
bruh[x_] := Module[{y}, y = x^2;
y + 1]
Begin["`Private`"]
bruhpriv[x_] := 5
End[]
EndPackage[]
```

Obviously I have no use for this, I am just trying to make a freaking package load. Anyways, if I open the file SamplePackage.m in Mathematica and run it then open a new notebook, I can access both `bruh`

and `bruhpriv`

by their short and long names. Further, SamplePackage’ is in the list of

$Packages

and SamplePackage’ is also in the

$ContextPath

bruh[4] gives 17 like it should, etc. However, if I do anything but run the file SamplePackage.m it won’t work. I use `AppendTo[$Path,the folder I want]`

and if I do <<SamplePackage.m it runs with no error message. If I do `Get["SamplePackage.m"]`

it runs with no error message. I know it is finding the file because if I remove the AppendTo line I get the file no found error, as expected.

So after I do <<SamplePackage.m it does not matter what I do I cannot use bruh[x] or bruhpriv[x]. Typing them in just echoes back the input. Further, SamplePackage’ is not in

$Packages

or

$Context Path

The only way to get the functions is to open the file and run the lines. What am I doing wrong?

**One way:**

```
AppendTo[$Path, "~/Desktop/Mathematica/MyPackages"]
Get["SamplePackage.m"]
bruh[3]
(* 10 *)
```

**Nicer way:**

- Create a new folder
`SamplePackage`

inside

`/Desktop/Mathematica/MyPackages`

. - Move
`SamplePackage.m`

into that new folder. - In
`/Desktop/Mathematica/MyPackages/SamplePackage`

create a new subfolder`Kernel`

. - In that new subfolder
`Kernel`

, put the following little package`init.m`

whose contents consist of just the single cell:`Get["SamplePackage`SamplePackage`"]`

Now again append `Get["SamplePackage`SamplePackage`"]`

to `$Path`

and just load the package by:

```
<< SamplePackage`
```

**Nicest way**

Do the same thing as for “Nicer Way” *except* put the whole folder `SamplePackage`

into the `Applications`

subfolder of `$UserBaseDirectory`

(which under macOS, for example, would be `~/Library/Mathematica/Applications`

).

This way, you no longer have to use `AppendTo[$Path,...]`

. Now you simple use:

```
<< SamplePackage`
```