# Change default JULIA Path Manually in Ubuntu

**URL:** <https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842>\
**Category:** General Usage\
**Created:** [November 26, 2020, 11:17pm UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842 "2020-11-26T23:17:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@clement](https://discourse.julialang.org/u/clement)\
**Post date:** [November 26, 2020, 11:17pm UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/1 "2020-11-26T23:17:39Z")

</div>

I have managed to locally install a latest Julia (version 1.5.2) locally on an Ubuntu SuperComputer into a folder I created called **Julia\_folder**. I am able to use Julia within this folder. But my challenge is the system full path is still set to the old version 0.4.5 bin. I added my local Julia directory to my .bashrc file to manually change the default path using:

export PATH=“$PATH:/path/to/home/clement/Julia\_folder/julia-1.5.2/bin”

and applied the source .bashrc afterwards. But the path is still the old version 0.4.5 bin, and thus, my manually settings still didn’t work. How can I manually change the path to use the latest Julia version 1.5.2 instead of the old version 0.4.5 which was already installed in this Ubuntu Supercomputer? Please, I need assistance with this. Thanks in advance

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [November 27, 2020, 12:08am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/2 "2020-11-27T00:08:03Z")

</div>

Welcome!

Directories in the `PATH` are searched in order as they appear in the environment variable. If you want that `/path/to/home/clement/Julia_folder/julia-1.5.2/bin` has higher precedence over the rest of the PATH you have to prepend it, instead of appending it:

```nohighlight
export PATH="/path/to/home/clement/Julia_folder/julia-1.5.2/bin:${PATH}"

```

---

<div class="post-metadata">

**Author:** ![clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@clement](https://discourse.julialang.org/u/clement)\
**Post date:** [November 27, 2020, 12:48am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/3 "2020-11-27T00:48:37Z")

</div>

Thanks for the response. I tried your suggestion by prepending as follows:

export PATH=“/path/to/home/clement/Julia\_folder/julia-1.5.2/bin:${PATH}”

However, it still could not achieve higher precedence over the default path in the Ubuntu system (ie. the Julia path for the old version).

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [November 27, 2020, 1:42am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/4 "2020-11-27T01:42:51Z")

</div>

How are you running Julia? Make sure the value of `PATH` is what you expect:

```nohighlight
echo ${PATH}

```

Note that in the worst case you can start Julia just by using the absolute path of the executable you want to run

Please quote your code with triple backticks, to make it easier to read the messages: [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757)

---

<div class="post-metadata">

**Author:** ![clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@clement](https://discourse.julialang.org/u/clement)\
**Post date:** [November 27, 2020, 1:59am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/5 "2020-11-27T01:59:00Z")

</div>

I am technically calling Julia in R via Ubuntu command line, but it couldn’t accept the JuliaCall since the version of Julia was an old one (v 0.4.5). So I installed a new version locally into a a new folder called **Julia\_folder**. So my main goal is to be able to set the default Julia path to the new Julia version within my **Julia\_folder**.

Typing

`echo ${PATH}$`

gives something very close

`/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b??in:/home/clement/Julia_folder/julia-1.5.2/bin/julia:/home/clement/Julia_folder/julia-1.5.2/bin/julia`

However, the Julia default Path is still that of the old Julia version 0.4.5. When I load Julia’s path using:

`LOAD_PATH`

it still gives me:

```nohighlight
 "/usr/local/share/julia/site/v0.4"
 "/usr/share/julia/site" 

```

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [November 27, 2020, 2:07am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/6 "2020-11-27T02:07:50Z")

</div>

> [@clement](#):
>
> gives something very close
> 
> `/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b??in:/home/clement/Julia_folder/julia-1.5.2/bin/julia:/home/clement/Julia_folder/julia-1.5.2/bin/julia`

This seems wrong to me, the directory of Julia v1.5 appears at the end. It doesn’t look like the change you made was effective.

---

<div class="post-metadata">

**Author:** ![clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@clement](https://discourse.julialang.org/u/clement)\
**Post date:** [November 27, 2020, 2:12am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/8 "2020-11-27T02:12:51Z")

</div>

That’s what I have been battling with all day 😞.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [November 27, 2020, 2:20am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/9 "2020-11-27T02:20:51Z")

</div>

Where are you setting the variable exactly and how? To make the change effective you need to re-evaluate the setting of the variable. If you put it in your shell init script you need either to reload it, or simply to open a new shell

---

<div class="post-metadata">

**Author:** ![clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@clement](https://discourse.julialang.org/u/clement)\
**Post date:** [November 27, 2020, 2:34am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/10 "2020-11-27T02:34:25Z")

</div>

I added this code to my .bashrc shell script:

`export PATH="/path/to/home/clement/Julia_folder/julia-1.5.2/bin:${PATH}" `  
and then run:

`source .bashrc`

Afterwards, running

`echo $PATH`  
gives

```julia
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b??in:/home/clement/Julia_folder/julia-1.5.2/bin/julia:/home/clement/Julia_folder/julia-1.5.2/bin/julia

```

That’s what I did. But I need it to access the **Julia\_folder** directory as a default path.

And typing in the command line :

` $ julia`

as well as its

`LOAD_PATH`  
returns the old version instead of the new one

---

<div class="post-metadata">

**Author:** ![magister-ludi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/magister-ludi/32/4003_2.png) [@magister-ludi](https://discourse.julialang.org/u/magister-ludi)\
**Post date:** [November 27, 2020, 5:34am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/11 "2020-11-27T05:34:30Z")

</div>

A couple of things I notice.

Firstly, the PATH that you quote includes (twice) the string

```julia
/home/clement/Julia_folder/julia-1.5.2/bin/julia

```

That is the file that you’re trying to execute, not the directory that contains it. No matter where that is in your path, the operating system won’t find the executable.

Secondly, the line you have in your `.bashrc`,

```julia
export PATH="/path/to/home/clement/Julia_folder/julia-1.5.2/bin:${PATH}"

```

has not been successfully imported into your shell. Perhaps you didn’t do `source ~/.bashrc` after your most recent edit.

Finally, your Julia `LOADPATH` won’t change until you are running the correct executable. What do you get if you run `which julia`? If that gives the correct result, are you running R from the same shell?

---

<div class="post-metadata">

**Author:** ![clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@clement](https://discourse.julialang.org/u/clement)\
**Post date:** [November 27, 2020, 6:09am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/12 "2020-11-27T06:09:22Z")

</div>

Running

`which julia`  
gives me

`/usr/bin/julia `

Yes, I am running R from the same shell.

---

<div class="post-metadata">

**Author:** ![magister-ludi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/magister-ludi/32/4003_2.png) [@magister-ludi](https://discourse.julialang.org/u/magister-ludi)\
**Post date:** [November 27, 2020, 6:14am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/13 "2020-11-27T06:14:04Z")

</div>

OK, so that’s the preinstalled julia. I don’t know why the edit of `.bashrc` didn’t work. Try typing

```julia
export PATH=/path/to/home/clement/Julia_folder/julia-1.5.2/bin:$PATH

```

on the bash command line. Does

```julia
which julia

```

give the same result?

---

<div class="post-metadata">

**Author:** ![clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@clement](https://discourse.julialang.org/u/clement)\
**Post date:** [November 27, 2020, 6:35am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/15 "2020-11-27T06:35:19Z")

</div>

Yes please, it gave me the same results:  
`/usr/bin/julia `

---

<div class="post-metadata">

**Author:** ![magister-ludi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/magister-ludi/32/4003_2.png) [@magister-ludi](https://discourse.julialang.org/u/magister-ludi)\
**Post date:** [November 27, 2020, 6:47am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/16 "2020-11-27T06:47:03Z")

</div>

If you followed the steps I gave, and

```julia
/path/to/home/clement/Julia_folder/julia-1.5.2/bin

```

is in your PATH **before** `/usr/bin`, then it seems that either

```julia
/path/to/home/clement/Julia_folder/julia-1.5.2/bin/julia

```

doesn’t exist, or it isn’t executable. Without any other information, I don’t think I can provide any other advice.

---

<div class="post-metadata">

**Author:** ![clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@clement](https://discourse.julialang.org/u/clement)\
**Post date:** [November 27, 2020, 6:58am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/17 "2020-11-27T06:58:41Z")

</div>

> [@magister-ludi](#):
>
> source ~/.bashrc

If there is a way of removing all the duplicate path in .bashrc, then I can start the whole process again?

---

<div class="post-metadata">

**Author:** ![magister-ludi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/magister-ludi/32/4003_2.png) [@magister-ludi](https://discourse.julialang.org/u/magister-ludi)\
**Post date:** [November 27, 2020, 7:12am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/18 "2020-11-27T07:12:16Z")

</div>

There are two ways I can think of. The easiest one for long term stability of your Julia usage would be to edit your `~/.bashrc` so that PATH is set the way that you want it, then start a new shell session.

The other way is to put something like the following into a text file (let’s call it `fixpath`):

```julia
/bin/sh
export PATH=/path/to/home/clement/Julia_folder/julia-1.5.2/bin:/usr/bin:/bin:/usr/sbin:/sbin

```

You would need to add the other directories that you need to that last line (maybe you can cut and paste from `~/.bashrc` so you get the right list, leaving out the `$PATH:` section). Then you can do

```julia
source fixpath

```

---

<div class="post-metadata">

**Author:** ![mike\_k](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike_k/32/211864_2.png) [@mike\_k](https://discourse.julialang.org/u/mike_k)\
**Post date:** [November 27, 2020, 10:31am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/19 "2020-11-27T10:31:52Z")

</div>

If you have root rights you could open your environment file, e.g., with

```julia
sudo gedit /etc/environment

```

and add your path (or edit the old path if it already exists)

```julia
/path/to/home/clement/Julia_folder/julia-1.5.2/bin

```

log off, and on again. Then typing `julia` in the terminal should start REPL.

I work on a HPC without root rights and start the computations via a script, e.g.,

```julia
#!/bin/sh

# set paths
homepath="/home/myHomeDir"
executable="$homepath/programs/julia/julia-1.1.0/bin/julia"
scriptfile="$homepath/myProgram/myMain.jl"

# set ld path
export LD_LIBRARY_PATH="$homepath/programs/julia/julia-1.1.0/lib":$LD_LIBRARY_PATH

# execute program
$executable $scriptfile 

```

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [November 27, 2020, 11:53am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/20 "2020-11-27T11:53:25Z")

</div>

I haven’t had time to read the whole thread, sorry.  
One thing to watch - if you are running a job on a compute node there is a difference between interactive and non-interactive shells. It can cuase problems like this.  
HOWEVER your .bashrc file should be sourced so you should pick up the correct PATH

I now ask - is the MODULES environment installed on your HPC cluster?  
Please send the output of module whatis  
If modules are installed you can create a personal one in your own directory for Julia.

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [November 27, 2020, 11:55am UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/21 "2020-11-27T11:55:34Z")

</div>

If you are running your code vi a batch system please create a simpel batch script then run it, containg

printenv

---

<div class="post-metadata">

**Author:** ![clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@clement](https://discourse.julialang.org/u/clement)\
**Post date:** [November 27, 2020, 5:25pm UTC](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842/22 "2020-11-27T17:25:27Z")

</div>

Thank you all for the great advice and assistance earlier today. My problem has been solved now. The `.bash_profile` shell script was the cause of the problem. I only needed to delete the `.bash_profile` shell script to save the day. Cheers. Now the new Julia version is set as the default path now as shown below:

```julia
/home/clement/bin:/home/clement/.local/bin:/home/clement/Julia_download/julia-1.5.3/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

```

[Next page](https://discourse.julialang.org/t/change-default-julia-path-manually-in-ubuntu/50842.md?page=2)
