How to fix -bash: No such file or directory - bash

Whenever I open up a new terminal I get the following:
-bash: /Users/chrisjayden/.profile: No such file or directory
I tried searching Q&A's but couldn't find anything relevant.
+ I'm pretty new to this stuff

-bash indicates that your terminal is starting a login shell. That means bash will try to execute the contents of the first of the following three files that it finds.
~/.bash_profile
~/.bash_login
~/.profile
If all three were missing, bash would not complain. Therefore, we can assume that it finds one of the first two files, and in that file is a line like source ~/.profile or . ~/.profile, which will produce the error shown if ~/.profile does not exist.
The easiest solution is to simply create an empty .profile file in your home directory.

Related

Warning on git bash start "bash: C:/Users/RS3/Anaconda3/etc/profile.d/conda.sh: No such file or directory"

Whenever I open git bash I get the following warning:
bash: C:/Users/RS3/Anaconda3/etc/profile.d/conda.sh: No such file or directory
The problem is that I uninstalled Anaconda, because I installed independent python, which resulted in giving that error.
How to remove this Warning.
Check the content of ~/.bashrc (which was mentioned here)
Maybe that (or ~/.profile, mentioned here) includes a command for that old uni uninstalled program.
Remove those lines, and try to open again a git bash session.
To remove that warning, simply erase the file path string in the .bashrc file using nano command. Here's how:
Steps to remove that warning:
Open Git Bash and check .bashrc location by typing ~/.bashrc into git bash.
Navigate to folder where .bashrc file is located.
Type nano .bashrc
Erase the string that says C:/Users/RS3/Anaconda3/etc/profile.d/conda.sh
Press ctrl+O to save .bashrc file and then ctrl+X to exit.
When you reopen git bash nothing should appear because .bashrc doesn't have that path in it anymore. Also, if conda commands were working before it will still continue to work after erasing this.

Terminal cannot find bashrc file when using source command

I recently downloaded mysql. What am I doing wrong when I source the bash file?
The path for my bashrc file is:
Users/Name/bashrc
(I moved it from a different location, can't remember from where, but I figure that if the path is right, it shouldn't matter)
In the terminal, I'm supposed to use:
source ~/.bashrc
When I type that and press enter, it returns:
-bash: /Users/Name/.bashrc: No such file or directory
The bash file itself says:
source /etc/bash.bashrc
source ~/.bashrc
export PATH=$PATH:/usr/local/mysql/bin
You need to have the file .bashrc located in ~ to be able to source it. ~ expands to $HOME (/Users/Name in your case).
If the output of cd ~ && ls -la doesn't contain .bashrc, then you don't have that file, so you cannot source it.
Based on your comments, your file is ~/bashrc.sh (not a great name). If you delete the first two lines of this file, it will work properly. Note that you'll have to source this file every time you open a new terminal. You can add the line
export PATH=$PATH:/usr/local/mysql/bin
to a file that gets automatically sourced upon login, like ~/.bash_profile, /etc/bash.bashrc (not recommended), or create a ~/.bashrc and include that line.

/Users/DylanRichards/.profile:source:2: no such file or directory: QSTK/local.sh

I'm going to open this up again. I installed this thing called QSTK for some financial calculations. Now every time I open my terminal, I get this error:
/Users/DylanRichards/.profile:source:2: no such file or directory: QSTK/local.sh
Because of this error, I am unable to run programs in Sublime Text as well.
How the heck do I get rid of this?
Latest
After trying KEYSER's suggestion, here are the contents of the .profile file:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
source QSTK/local.sh
PATH=$PATH:/Applications/Darwine/Wine.bundle/Contents/bin/
QSTK seems to have injected some line into your profile file, which is loaded by the terminal at startup. That line is trying to run a script which doesn't exist.
To get rid of the error remove line 2 in .profile (and possibly surrounding, related, lines).
It's a hidden file, so you can e.g. open it from a terminal. for example:
open -a "/Applications/Sublime Text.app/" ~/.profile
if that's the name of your sublime app (tab to autocomplete)
How do I find and edit ~/.profile?
In Terminal:
$ cd ~
$ touch .profile
$ open -e .profile
This will open the .profile file in TextEdit for your editing enjoyment.
Once you have completed your editing, save the file in TextEdit and then, in Terminal:
$ source .profile
This should avoid the need for a system restart but always a good idea to do a restart anyway when playing with fundamentals like .____ files.

Bash Issue When Terminal Opens

Whenever I open Terminal I get the following messages:
bash: /etc/profile.d/sm.sh: No such file or directory
bash: /etc/profile.d/rvm.sh: No such file or directory
These don't seem to impact anything but are incredibly annoying.
The entry will be in one of the dot files which are run when you open a new terminal or login.
In your home directory you will find the entry in one of
.profile
.bashrc
.bash_profile
If it's not in there it could be in the system wide start file /etc/profile.

How to remove entry from $PATH on mac

I was trying to install Sencha Touch SDK tools 2.0.0 but could not run it properly. It created an entry in the $PATH variable.
Later I deleted the sencha sdk tools folder but didn't realize that the path variable is still there.
When i did echo $PATH I got -
/Applications/SenchaSDKTools-2.0.0-beta3:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
I searched on how to remove variables from $PATH and followed these steps :
Gave the command PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
Did echo $PATH which showed /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
gave the command export PATH
Closed terminal and reopened it. Gave the command echo $PATH. This time I got
/Applications/SenchaSDKTools-2.0.0-beta3:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
Can anyone tell me what am i doing wrong?
echo $PATH and copy it's value
export PATH=""
export PATH="/path/you/want/to/keep"
Check the following files:
/etc/bashrc
/etc/profile
~/.bashrc
~/.bash_profile
~/.profile
~/.MacOSX/environment.plist
Some of these files may not exist, but they're the most likely ones to contain $PATH definitions.
On MAC OS X Leopard and higher
cd /etc/paths.d
There may be a text file in the above directory that contains the path you are trying to remove.
vim textfile //check and see what is in it when you are done looking type :q
//:q just quits, no saves
If its the one you want to remove do this
rm textfile //remove it, delete it
Here is a link to a site that has more info on it, even though it illustrates 'adding' the path. However, you may gain some insight.
What you're doing is valid for the current session (limited to the terminal that you're working in). You need to persist those changes. Consider adding commands in steps 1-3 above to your ${HOME}/.bashrc.
If you're removing the path for Python 3 specifically, I found it in ~/.zprofile and ~/.zshrc.
$PATH contains data that is referenced from actual files. Ergo, you should find the file containing the reference you want to delete, and then delete said reference.
Here is a good list to run through progressively [copied from #Ansgar's answer with minor updates].
/etc/bashrc
/etc/profile
~/.bashrc
~/.bash_profile
~/.profile
~/.MacOSX/environment.plist
/etc/paths
/etc/paths.d/
Note that /etc/paths.d/ is a directory that contains files with path references. For example, inside this directory may be a file called, say, fancy-app, and inside this file you'll see an entry like below:
/path/to/fancy-app
This path will appear in your $PATH and you can delete the entry in the file to remove it, or you can delete the file if it has only the one reference you want to remove.
Use sudo pico /etc/paths inside the terminal window and change the entries to the one you want to remove, then open a new terminal session.
when you login, or start a bash shell, environment variables are loaded/configured according to .bashrc, or .bash_profile. Whatever export you are doing, it's valid only for current session. so export PATH=/Applications/SenchaSDKTools-2.0.0-beta3:$PATH this command is getting executed each time you are opening a shell, you can override it, but again that's for the current session only. edit the .bashrc file to suite your need. If it's saying permission denied, perhaps the file is write-protected, a link to some other file (many organisations keep a master .bashrc file and gives each user a link of it to their home dir, you can copy the file instead of link and the start adding content to it)
Close the terminal(End the current session). Open it again.
If the manual export $PATH method does not seem to be working after you close the terminal and open again, definitely check the shell configuration files.
I found a small script that kept adding some more path in front of the $PATH everytime it was open.
For zsh you can check the ~/.zshrc file.

Resources