when I export the environment variable :
$ export VS_PATH=/cygdrive/c/Users/bla/Documents/Visual\ Studio\ 2010/Projects/
and echo $VS_PATH gives the correct variable,
$ echo $VS_PATH
/cygdrive/c/Users/bla/Documents/Visual Studio 2010/Projects/
so I thought it is set correctly.But
$ cd $VS_PATH
-bash: cd: /cygdrive/c/Users/bla/Documents/Visual: No such file or directory
what is the problem? How could I export and cd it correctly
Because the cd command is reading the variable as is, meaning the exact same way you see it when you echo it. It'll work fine if you put the var in quote marks.
$ cd "$VS_PATH"
Related
I have followed a tutorial to install JDK 8 on my computer Centos7 OS, but in the last part I tried to set environment varibles.
In the last part of the tutorial I typed:
echo “export JAVA_HOME=/opt/jdk1.8.0_101” > /etc/profile.d/jre.sh
echo “export JRE_HOME=/opt/jdk1.8.0_101/jre” >> /etc/profile.d/jre.sh
echo “export PATH=$PATH:/opt/jdk1.8.0_101/bin:/opt/jdk1.8.0_101/jre/bin” >> /etc/profile.d/jre.sh
and then I am seeing this when I open the terminal:
bash: $'\342\200\234export':order not found
bash: $'\342\200\234export': order not found
bash: $'\342\200\234export': order not found
[evconsul8#localhost ~]$
Path:
[evconsul8#localhost ~]$ echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/evconsul8/.local/bin:/home/evconsul8/bin
After that I Trying to search the cause open
~/.bash_profile
[root#localhost evconsul8]# gedit ~/.bash_profile
Result:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export JAVA_HOME=/opt/jdk1.8.0_101
export JRE_HOME=/opt/jdk1.8.0_101/jre
export PATH=$PATH:/opt/jdk1.8.0_101/bin:/opt/jdk1.8.0_101/jre/bin
export PATH
Note: In one of my attemps after the error I added manually the lines corresponding to JAVA_HOME, JRE_HOME and PATH=$PATH in the file above. It was ok??
The principal problem I guess it is causing troubles to other apps in my machine.
You should use regular double quotes (") to enclose a string and not the fancy ones (“) you are using.
I recently upgraded my osx to os x el capitan. I noticed that subl command was missing so I tried adding the path to my bash_profile. It didn't work out so I removed it and then do a source ~/.bash_profile and now all of my bash commands are gone.
Here is my bash_profile file
export $PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
##
# Your previous /Users/judyngai/.bash_profile file was backed up as /Users/judyngai/.bash_profile.macports-saved_2013-06-27_at_16:30:58
##
# MacPorts Installer addition on 2013-06-27_at_16:30:58: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
export PATH=/usr/local/sbin:$path
export PATH=/usr/local/bin:$PATH
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
:q!
and when I do export $PATH
I am getting this
31-34-238:bin judyngai$ export $PATH
-bash: export: `/usr/local/bin:/usr/local/sbin:': not a valid identifier
I cd into all of the directories that its getting searched through /usr/local/bin, /bin, /usr/local/bin etc. and saw all of the commands in there.
and this
31-34-238:~ judyngai$ source ~/.bash_profile
-bash: export: `/Users/judyngai/.rbenv/bin:/usr/local/bin:/usr/local/sbin:=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin': not a valid identifier
env: bash: No such file or directory
-bash: :q!: command not found
I actually think my bash_profile is fine so what is wrong? Rbenv and macport both look fine.
This line is destroying your path: export PATH=/usr/local/sbin:$path -- variables are case sensitive.
However, this error
-bash: export:`/usr/local/bin:/usr/local/sbin:': not a valid identifier
Indicates you probably have this in your bash_profile
export PATH=/usr/local/sbin:$path # PATH=/usr/local/sbin:
export PATH=/usr/local/bin:$PATH # PATH=/usr/local/bin:/usr/local/sbin:
export $PATH="$HOME/.rbenv/bin:$PATH"
# .....^
Where you are substituting the variable on the left-hand side instead of providing the variable name.
You export a variable (name), not a variable's value.
I have a script HOST_AVAI.sh in /home/campus27/zwang10/bin. And in my .bashrc, I add export PATH=$PATH:/home/zwang10/bin/HOST_AVAI.sh. But after I type HOST_AVAI.sh, it shows HOST_AVAI.sh: Command not found..
Can someone help me here?
ADDED
$ echo $SHELL
/bin/tcsh
Your path should be PATH=$PATH:/home/zwang10/bin and add this in .bash_profile. After this run the script with following command :
$ . .bash_profile
Make sure your HOST_AVAI.sh must have the execute permission.
$ cd /home/zwang10/bin
$ chmod +x HOST_AVAI.sh
now run this command from anywhere.
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
I set 2 environment variables to test which one works for me, as following
.bash_profile
NODE_BIN1="/cygdrive/c/Program Files/nodejs"
NODE_BIN2=/cygdrive/c/Program\ Files/nodejs
export NODE_BIN1 NODE_BIN2
then test them in Cygwin terminal
$ cd $NODE_BIN1
kevin#kevin-HP /cygdrive/c/Program (wrong!)
$ cd $NODE_BIN2
kevin#kevin-HP /cygdrive/c/Program (wrong!)
$ cd C:/Program Files/nodejs
kevin#kevin-HP /cygdrive/c/Program (wrong!)
$ cd "C:/Program Files/nodejs"
kevin#kevin-HP /cygdrive/c/Program Files/nodejs
The last result is what I want but actually it's same string as $NODE_BIN1.
Any idea to fix this ?
Thanks a lot !
Try using cygpath?
export NODE_BIN1=`cygpath -w -s "/cygdrive/c/Program Files/nodejs"`
This also provides the same output
export NODE_BIN1=`cygpath -d "/cygdrive/c/Program Files/nodejs"`
Both approaches will set the environment variable correctly. The problem you're experiencing is when you try to use it; bash will split variables on spaces by default, and you end up calling cd with two arguments: /cygdrive/c/Program and Files/nodejs.
The solution, of course, is to switch to zsh. ;)
Okay, okay. If your intention is to be able to switch to this directory with ease, consider writing an alias instead.
alias cdnode='cd "/cygdrive/c/Program\ Files/nodejs"'
If you only want to set this for node's benefit, then don't worry; you're already good to go. You can be absolutely sure using echo instead.
$ echo "[$NODE_BIN1]"
[/cygdrive/c/Program\ Files/nodejs]