PATH related issues - terminal

A couple of days ago, I added code to my Mac's PATH to make some newly installed programs work properly on my machine. Unfortunately, it seems I have messed it up somewhere because some additional lines are printed every time I open my terminal.
Here is a screenshot of my terminal:
And here is a screenshot of my PATH Variable:
Does anyone know how I can remove extra lines in my terminal?
Thanks in advance

I renamed my ~/.zshrc file to ~/.zshrc2. Then all the extra lines were not shown anymore while opening up my terminal. Now I am sure the problems belong somewhere in my ~/.zshrc file
You can rename a folder by entering this command mv old-name-folder new-name-folder in the folder's directory.

Related

Accidentally deleted contents of .zshrc, can I get them back?

I was trying to add sql to my zsh file and I ran this code I found online:
echo 'export PATH=${PATH}:/usr/local/mysql/bin/' >.zshrc
When I opened .zshrc, this was the only line in the file and everything I had before was deleted.
Can someone please help me in understanding if I can revert back to what I had before I made this change? Or is everything just lost now? And what about this line of code did this?
FYI, I'm using Mac. Also, things like commands like "brew" and "npm" are still working, despite my .zshrc being empty. I don't know if that's telling or helpful in any way. ("sql" still doesn't work)

Windows cmd git bash: conda.sh no such file or directory (Windows line endings, missing slashes)

I'm working in Windows 10 with a fresh installation of Anaconda and Git Bash. I decided to set cmd.exe as my default console program to use git bash (instead of the minTTY), and I think already I am getting issues with Unix style characters vs Windows.
When I fire up cmd Bash tells me it can't find my conda.sh file:
bash: C:UsersjoshuAnaconda3/etc/profile.d/conda.sh: No such file or directory
First, it looks like bash is missing the default windows slashes for my root directory ("C:/Users/joshu/"). Does anyone know how to fix this?
Thanks
I have the exact same problem. Run ~/.bashrc in a terminal. Go to the path given and correct the conda.sh path.
In your case, you will replace the C:\Users\joshu\Anaconda3/etc/profile.d/conda.sh to C:/Users/joshu/Anaconda3/etc/profile.d/conda.sh
Your only problem is that your slashes are set wrong.
Fix this issue by opening ~/.bashrc and change location of conda.sh, e.g. in my case
. D:/Users/my_user/ProgramFile/Continuum/anaconda3/etc/profile.d/conda.sh
Had the same problem on Windows 10/Git Bash/Anaconda installation. If you run ~/.bashrc in Git Bash, it should give you the location of the shell script file containing the incorrect path. Once you correct the path in that file, the message should disappear when you restart the terminal.
Another thing to check is make sure your user profile folder under C:\Users has not gone hidden. If it has gone hidden, then the C:\Anaconda\etc\profile.d\conda.sh script
won't be able to find the folder.

Terminal - No such file or directory exists

So complete newbie question, but I've googled it and tried all their suggestions and I can't get it to work still :(
Trying to learn about the terminal... so I've created two files on my Desktop - filea.txt, fileb.txt - when I try to run the cd command I get the error, "No such file or directory exists".
I'm in the Desktop so that isn't the problem.
Is there anyone who could please suggest anything I can try?
I appreciate the help, and am completely grateful to anyone who answers - I understand time is valuable.
Thank you!
On an ubuntu to change to Desktop, you should type cd ~/Desktop, now you are in the Desktop directory, now typing ls would should list your files and directories on your desktop. Now you can open your file on a text editing application such as gedit by typing gedit filea.txt, which would open the file filea.txt in the text editor.
If you're trying to change directory to desktop and it's giving you that error, try typing cd .. which goes back one directory, and repeat to go back as far as you can and then try changing directory to desktop again.

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.

How do you get your path in Octave (on Windows)?

I used addpath(pwd) to get my .m files working in my projects directory. When I close the window and start a new window, the path I just added is gone. But the files still run.
Is it in my path or not? How do I see the directories I have added to my path?
Also, . is the first entry I see from path. Does that mean I don't need to add any directories because it will always search the current directory first?
Thanks.
Basically, yes.
You can add a directory to the search path using addpath(), but as you know, it only exists for the current session and is reset when you restart Octave. If you want a path to survive between sessions, add it to your octaverc, a script file that gets run whenever a new session gets started. Example path to octaverc file is:
C:\Octave\3.2.4_gcc-4.4.0\share\octave\site\m\startup
Since . is in your path by default, Octave will search your current directory for any function files that it needs. Using addpath(pwd) is somewhat useless if you're just going to stay in the same directory. However, there are some cases where it'd be useful, if for example you have a directory that contains your functions, and another one that has the data that you're working on: you could start in the functions directory, do addpath(pwd), and then cd to the data directory while still being able to use your functions.
You can create batch file, which will start Octave with your directory path. Please see example below:
octave-3.6.4.exe -p "C:\MyOctaveDiretory"
-p means addpath()
addpath(pwd); savepath();
Done.
I think there is a bug in Octave (I use version 4.0.3 on Windows). When I create a new file in current path, this can't be called by Octave ("error: 'foo' undefined near line 1 column 1"). If I restart Octave, it works. This addpath(pwd) trick helps me a lot (before I unsuccessfully tried rehash() and cd elsewhere and back again).
If you had the same problem, the reason for the symptom might be:
Start Octave.
Create newfile.m.
Call newfile - fails since Octave did not register its existence.
addpath(pwd) - causes Octave to register it.
Close Octave
Start Octave - now pwd is gone from path, but newfile.m is registered at startup.
call newfile - works
I faced a similar problem in adding path where the path was added by using addpath command directly in Octave GUI (Command Window). The path added was being shown in console window but none of the functions worked.
The problem was solved by changing the path directory from Windows directory to some other direction where OS is not installed.

Resources