# Lecture: Your first Julia code

**URL:** <https://discourse.julialang.org/t/lecture-your-first-julia-code/65331>\
**Category:** New to Julia\
**Created:** [July 26, 2021, 8:45pm UTC](https://discourse.julialang.org/t/lecture-your-first-julia-code/65331 "2021-07-26T20:45:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![amrnasr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrnasr/32/27533_2.png) [@amrnasr](https://discourse.julialang.org/u/amrnasr)\
**Post date:** [July 26, 2021, 8:45pm UTC](https://discourse.julialang.org/t/lecture-your-first-julia-code/65331/1 "2021-07-26T20:45:38Z")

</div>

Hello everyone! I’m new to programming, so I might need a lot of help! In the lecture (see topic), the include function doesn’t work. It always gives the error “could not open file”, although I have followed every step. Please help!

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [July 26, 2021, 8:59pm UTC](https://discourse.julialang.org/t/lecture-your-first-julia-code/65331/2 "2021-07-26T20:59:58Z")

</div>

Can you give us some more detail? What lecture (link?) are you referring to?

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [July 26, 2021, 10:21pm UTC](https://discourse.julialang.org/t/lecture-your-first-julia-code/65331/3 "2021-07-26T22:21:31Z")

</div>

You mean this one: [Your First Julia Code! Julia Programming For Nervous Beginners (Week 1 Lesson 1) - YouTube](https://youtu.be/L0TDqQCHigg)?

`include("file.jl")`, where `file.jl` is some file that you like to include, checks for files next to the file that you‘re in. Is the file near your current directory? Use `pwd()` to see your current directory

---

<div class="post-metadata">

**Author:** ![amrnasr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrnasr/32/27533_2.png) [@amrnasr](https://discourse.julialang.org/u/amrnasr)\
**Post date:** [July 26, 2021, 10:26pm UTC](https://discourse.julialang.org/t/lecture-your-first-julia-code/65331/4 "2021-07-26T22:26:39Z")

</div>

@rdeits Thank you for responding! I’m referring to Lecture 1 in the Julia academy course ([Your First Julia Code! Julia Programming For Nervous Beginners (Week 1 Lesson 1) - YouTube](https://www.youtube.com/watch?v=L0TDqQCHigg)), in the third segment of the video, which explains running a code from a file. I saved the file as instructed, but still gives an error message.

---

<div class="post-metadata">

**Author:** ![amrnasr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrnasr/32/27533_2.png) [@amrnasr](https://discourse.julialang.org/u/amrnasr)\
**Post date:** [July 26, 2021, 10:31pm UTC](https://discourse.julialang.org/t/lecture-your-first-julia-code/65331/5 "2021-07-26T22:31:59Z")

</div>

@rikh Yes that one! Thanks. Yes, I’ve seen my current directory (C: Users/amro0/). I have the .jl file saved in the path (C: Users/amro0/JuliaCourse/Codes). Is that where I’m wrong?

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [July 26, 2021, 11:21pm UTC](https://discourse.julialang.org/t/lecture-your-first-julia-code/65331/6 "2021-07-26T23:21:55Z")

</div>

Are you in the REPL or in a file? In the REPL you can type

```julia
julia> include("<TAB>

```

where is the tab key on the keyboard which will show which files are in your current directory.

For the file. You could add a `@show readdir()` to try to figure out where you are and adjust the path accordingly

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [July 26, 2021, 11:23pm UTC](https://discourse.julialang.org/t/lecture-your-first-julia-code/65331/7 "2021-07-26T23:23:31Z")

</div>

> [@amrnasr](#):
>
> JuliaCourse/Codes

Probably, you need something like `include("JuliaCourse/Codes/file.jl")`

---

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [July 27, 2021, 1:00am UTC](https://discourse.julialang.org/t/lecture-your-first-julia-code/65331/8 "2021-07-27T01:00:08Z")

</div>

Looks like you’ve got a solution. Just a remark in passing, sometimes `expanduser` is useful, to help Julia understand that `~` refers to your home directory. And sometimes it’s useful to push an entire directory to the load path. Something like this:

dir = expanduser(“~/JuliaCourse/Codes/”)  
push!(LOAD\_PATH, dir)
