Julia alias in .bashrc not working correctly - linux

I am running Julia on my university's cluster, which runs Red Hat Linux. The Julia download's path is
/gsfs0/data/heathjo/Downloads/julia-1.5.3/bin
When I run
/gsfs0/data/heathjo/Downloads/julia-1.5.3/bin/julia
Julia runs fine. However, I just want to type
julia
And have it run. I edited my .bashrc to include
alias julia="/gsfs0/data/heathjo/Downloads/julia-1.5.3/bin/julia"
Running "julia", I now get the prompt
CORRECT>.julia (y|n|e|a)?
Running both .julia and julia results in
julia: Command not found.
What am I doing wrong? I also get the same issue when I try to set my path in the .bashrc file.
EDIT1: For reference, here's my .bashrc file :
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
module load gcc
module load torque
alias julia="/gsfs0/data/heathjo/Downloads/julia-1.5.3/bin/julia"
EDIT2: Here is my bash_profile as well, where I have tried adding it to my path. For some reason, I get the same error:
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH="/gsfs0/data/heathjo/Downloads/julia-1.5.3/bin:$PATH"
export PATH
Ideally, I'd like to just add it to my path rather than make an alias, but for some reason nothing seems to be working.

Related

Can't source Bash profile on Linux Cluster

This is a follow-up to my previous question:
Julia alias in .bashrc not working correctly
My main issue is that I cannot add Julia to my path on a Linux Cluster. If I go into the bin subfolder of the Julia folder, I can run Julia itself fine. However, I cannot edit the .bash_profile to get it into my path. As opposed to my previous question, I believe my issue has less with building an alias (or something Julia related) and more concerning my .bash_profile itself not updated.
The Julia file itself is located in
/gsfs0/data/heathjo/Downloads/julia-1.5.3/bin
I configured my .bash_profile as follows:
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH=$PATH:$HOME/.local/heathjo/Downloads/julia-1.5.3/bin
export PATH
If I run
source .bash_profile
I get the following issue:
if: Expression Syntax.
then: Command not found.
As such, it seems as if I run echo $PATH, Julia doesn't appear in my path, because it seems as if I can't source the .bash_profile. Am I doing something incorrectly?

Echo $JAVA_HOME returns empty despite being present in .bashrc, .bash_profile, .profile files

I've added the following line in all 3 files:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
If I do, echo $JAVA_HOME, I get empty line as output.
If I do source .bash_profile and then do echo $JAVA_HOME, I get the output correctly.
If I close the terminal application and re-open the terminal app again, echo $JAVA_HOMEshows empty again. Isn't .profile or .bash_profile supposed to load it to bash when I reopen? I added it to all 3 files to be sure. But it just doesn't seem to work
Note: I'm using Zsh on Mac. Does this have anything to do with what I'm facing?
Thanks #JoachimIsaksson for the solution in the comments. I had to move stuff to .zprofile for zshell on Mac and it worked.

linux bash error: -bash: No such file or directory

After I login to Linux every time, it shows :
-bash: /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/xx/bin: No such file or directory
I notice that there is a '=' in it, but I don't know why.
My .bash_profile:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
$PATH=$PATH:$HOME/bin
export PATH
export JAVA_HOME=/opt/jdk1.8.0_73
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
I want to set the JAVA environment , and it works ,but after I edit profile,it shows the bash error.
How could I fix it?
$PATH=$PATH:$HOME/bin does not do what you want. After substituting the values for variables (PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin and HOME=/home/xx) it executes a command:
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/xx/bin
which explains the error.
To do a variable assignment, remove $ from variable name on the left side of the assignment:
PATH=$PATH:$HOME/bin

bash: homestead: command not found

I install homestead and laravel but when i write the command in command line there is error the command not found for both laravel and homestead so i search a lot and i found that i must add the path so i added in efferent way but still the same error command not found.
and this is my bash profile is there any wrong when i added the path?
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export composer=php /usr/bin/composer.phar
export PATH=~/.composer/vendor/bin/:$PATH:/home/alsachit/.composer
You should run Laravel commands from Laravel project directory, like php artisan or composer. If you will run there commands from other directories, you can meet a lot of errors (a lot of guys ask for help on SO because of it), so my advice is to keep it simple.
UPDATE:
COMPOSER_PATH=~/.composer/vendor/bin
PATH=$COMPOSER_PATH:$PATH
export PATH
Another way which may work for you:
export PATH="$PATH:$HOME/.composer/vendor/bin"
I believe to directly answer the issue homestead: command not found
you must perform steps below:
Add bash function into your ~/.bashrc or ~/.bash_profile file:
# Homestead shortcut
function homestead() {
( cd ~/Homestead && vagrant $* )
}
Restart terminal, see image below for possible output.

Cannot add environment variables in linux

For an entire day I have been tryng to add an environment variable to linux ad it isn't working. This is the guide that I am following. This is what is written in the .profile file.
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
JAVA_HOME=/usr/local/java/jdk1.8.0_51
JRE_HOME=$JAVA_HOME/jre
LARAVEL=/home/user/.composer/vendor/bin
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$LARAVEL
export JAVA_HOME
export JRE_HOME
export LARAVEL
export PATH
I am running the file. But when I run echo $PATH I am not getting the $LARAVEL path. What am I doing wrong?
Have you logged out and logged in? Also try to update your .bashrc file instead. I think that .profile is only used for the ksh shell.
Try to source the file, like;
$ source yourfilename
In Unix/Linux (unlike in Windows) a program cannot affect the environment of the parent process. When you are running it as a regular shellscript it becomes a subprocess of the parent, and it will affect only it's own environment and not that of the parent.
Using the keyword source (or using the dot .) will instruct your process to executed the shell script directly rather than fork a new subprocess.
echo 'export PATH="$PATH":/path/to/folder/' >> ~/.bashrc
and
source ~/.bashrc

Resources