# Starting julia with flags

**URL:** <https://discourse.julialang.org/t/starting-julia-with-flags/7833>\
**Category:** New to Julia\
**Tags:** optimization, gettingstarted\
**Created:** [December 18, 2017, 12:06pm UTC](https://discourse.julialang.org/t/starting-julia-with-flags/7833 "2017-12-18T12:06:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![alirezamecheng](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@alirezamecheng](https://discourse.julialang.org/u/alirezamecheng)\
**Post date:** [December 18, 2017, 12:06pm UTC](https://discourse.julialang.org/t/starting-julia-with-flags/7833/1 "2017-12-18T12:06:35Z")

</div>

Hello.  
I am trying to start Julia using Optimization flag.  
my test file is this

```julia
    for i = 1:10
    println(i);
    end

```

I run this command

```julia
$ julia --optimize=3 -- test.jl

```

but jukia returns this

```julia
ERROR: julia: invalid argument to -O (3 -- test.jl)

```

where are my mistake or mistakes?😄  
Thankyou for your help and attention.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [December 18, 2017, 12:17pm UTC](https://discourse.julialang.org/t/starting-julia-with-flags/7833/2 "2017-12-18T12:17:41Z")

</div>

`$ julia --optimize=3 test.jl`

---

<div class="post-metadata">

**Author:** ![alirezamecheng](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@alirezamecheng](https://discourse.julialang.org/u/alirezamecheng)\
**Post date:** [December 20, 2017, 12:14pm UTC](https://discourse.julialang.org/t/starting-julia-with-flags/7833/3 "2017-12-20T12:14:07Z")

</div>

Thank you for your attention.  
I did try that but the result was the same error!

```julia
ERROR: julia: invalid argument to -O (3 test.jl)

```

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [December 21, 2017, 1:10am UTC](https://discourse.julialang.org/t/starting-julia-with-flags/7833/4 "2017-12-21T01:10:11Z")

</div>

What exactly are you running?

```julia
fredrik@fredrik-desktop:~$ cat test.jl 
for i = 1:3
    println(i)
end
fredrik@fredrik-desktop:~$ julia --optimize=3 test.jl
1
2
3
fredrik@fredrik-desktop:~$ julia -O3 test.jl
1
2
3

```

---

<div class="post-metadata">

**Author:** ![Non-Contradiction](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-contradiction/32/2208_2.png) [@Non-Contradiction](https://discourse.julialang.org/u/Non-Contradiction)\
**Post date:** [December 21, 2017, 3:09am UTC](https://discourse.julialang.org/t/starting-julia-with-flags/7833/5 "2017-12-21T03:09:14Z")

</div>

I guess the problem is that the space between `optimization=3` and `test.jl` in your command is not a “real space”, for example, if I type anything between `optimization=3` and `test.jl`, the error message is similar to yours.

```julia
julia --optimize=3_test.jl
ERROR: julia: invalid argument to -O (3_test.jl)

```

---

<div class="post-metadata">

**Author:** ![alirezamecheng](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@alirezamecheng](https://discourse.julialang.org/u/alirezamecheng)\
**Post date:** [December 23, 2017, 10:56am UTC](https://discourse.julialang.org/t/starting-julia-with-flags/7833/6 "2017-12-23T10:56:49Z")

</div>

I guess you are right.  
but there is something that is strange. I have two machines both Linux one is mint and the other is Ubuntu. This command works on one of them and gives the error on the other one. That’s strange. I tried a new clean reinstallation but It doesn’t seem to solve the problem.

After all, Thank you for your attention and help.  
and If you have advice for me I will be glad hearing that.

---

<div class="post-metadata">

**Author:** ![alirezamecheng](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@alirezamecheng](https://discourse.julialang.org/u/alirezamecheng)\
**Post date:** [December 23, 2017, 10:59am UTC](https://discourse.julialang.org/t/starting-julia-with-flags/7833/7 "2017-12-23T10:59:59Z")

</div>

I have a CFD code and I am trying to make its speed better but the code I’m trying to run is a simple hello world test code.

---

<div class="post-metadata">

**Author:** ![Per](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/per/32/10387_2.png) [@Per](https://discourse.julialang.org/u/Per)\
**Post date:** [December 23, 2017, 2:48pm UTC](https://discourse.julialang.org/t/starting-julia-with-flags/7833/8 "2017-12-23T14:48:50Z")

</div>

This problem is likely cause by the shell (or other program) that is starting up the Julia process. It is not passing the arguments in the correct way, interpreting space as part of the argument, instead of a separator between arguments.

What shell are you using? Or are you starting Julia using a function call from some programming language?

Do you have any funny environment variables set? (Some shells allow you to specify that space will not be used to separate arguments.)

---

<div class="post-metadata">

**Author:** ![alirezamecheng](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@alirezamecheng](https://discourse.julialang.org/u/alirezamecheng)\
**Post date:** [January 14, 2018, 1:07pm UTC](https://discourse.julialang.org/t/starting-julia-with-flags/7833/9 "2018-01-14T13:07:20Z")

</div>

Thanks for your help.  
Your idea made me check that if ssh is messing with the command.  
after some trial and error, I figured out that this is a bug of JuliaPro.

Anyway, thank you for your attention.
