updating osx terminal after macport installation - terminal

I installed macports on my macbook pro and after the successful install, I tried typing in 'port' in a terminal tab that I had was already opened before the macport installation and it gave me the error "command not found"
When I opened another tab in the terminal and tried again, it worked. (It works in the new tab but does not work in the old one)
I am guessing that this has to do with the fact that the first tab was opened before the the macport installation took place.
Just wanted to know how to refresh the terminal after I install something like macports.
PS: I know that I can open a new tab and continue working but am just curious how to do so.

General: You can use the reset command:
reset
For more information run:
man reset
MacPorts: The PATH variable is set by the postflight script to append the MacPorts executable paths to the default path:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
The location of this line depends on your shell, the installer may use .profile, .bash_login, .bash_profile, .tcshrc, or .cshrc.
If you want these changes to take effect in the current Terminal window, you either need to execute this command manually:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
Or if you know which file contains the line above, you can source it. For example:
source ~/.profile

Related

Use RVM Ruby instead of MAMP Ruby

I've used RVM to install the latest stable version of Ruby, however, I can't set it to be the default version. Running which ruby always returns the path of Ruby installed with MAMP on my system eg /Applications/MAMP/Library/bin/ruby
I've tried various rvm commands with no effect. I'd rather not have to run an rvm use command every time I open my terminal.
I'm using oh-my-zsh and iTerm2 if it makes a difference.
As Dave Newton suggested, this smells like a PATH issue, but in the case of MAMP, it's also an alias issue.
If you open ~/.profile and ~/.zprofile, in one of them you will probably see these lines:
alias erb='/Applications/MAMP/Library/bin/erb'
alias gem='/Applications/MAMP/Library/bin/gem'
alias irb='/Applications/MAMP/Library/bin/irb'
alias rake='/Applications/MAMP/Library/bin/rake'
alias rdoc='/Applications/MAMP/Library/bin/rdoc'
alias ri='/Applications/MAMP/Library/bin/ri'
alias ruby='/Applications/MAMP/Library/bin/ruby'
alias rails='/Applications/MAMP/Library/bin/rails'
You'll want to remove them all, save the file, then quit and restart iTerm2.
If you don't know how to open and edit dotfiles, read my guide that explains various ways to read and edit dotfiles on a Mac.
If removing those aliases doesn't fix it, then it's a PATH issue.
For your Mac to know about a command or other executable program, it has to be told where to look for it. It wouldn't be efficient for the computer to search the entire hard drive for the program.
Instead, it looks in a specific list of locations, which are stored in an environment variable called PATH, separated by a colon. You can view this list by running this command in your terminal:
echo $PATH
When you install new programs, such as Ruby, they might get installed in a location that is not already included in the PATH. If you don't add this new location to the PATH, the computer won't know to look for it there, and so it thinks it doesn't exist.
Similarly, if the location of the new program did get added to the PATH, but you have another location for the same program earlier in the PATH, then it will always use the first one it finds.
Most Ruby version managers use a script to automatically update the PATH, and they instruct you to add a line to your shell file to call that script, or they might add it for you. That line should come after any modifications of PATH.
It's been a while since I've used RVM (I no longer recommend it), but I think it's supposed to automatically add this line to your shell file:
source $HOME/.rvm/scripts/rvm
Assuming you installed RVM properly, here's what I would try:
Open your shell file. It should be ~/.zshrc if you're using oh-my-zsh.
Look for any lines that start with export PATH=, and if they mention /Applications/MAMP/Library/bin/ruby, remove that directory from the PATH. Also make sure any PATH lines come before the lines added by RVM.
Quit and restart iTerm2
If you don't see any RVM-related lines in ~/.zshrc or ~/.zprofile or ~/.profile, then RVM was not properly installed.
If you really want to use RVM, try uninstalling and reinstalling it. If all you care about is having a working Ruby environment, I would recommend chruby and ruby-install. You can install them by following my step-by-step guide to install Ruby on Mac.

Setting up React Native on Mac

I'm trying to install React Native on Mac but I'm not able to get past the first step.
npm install -g expo-cli
This seems to work but when I run the next step expo init AwesomeProject I'm getting this error.
-bash: expo: command not found
I also do not have a .npm-global folder. I'm running npm 6.13.4 on Mac OS X 10.15.2.
This might be a local environment issue.
Your computer should know where to look for the commands you're using, it's likely that your mac is not looking for the correct folder.
In order to expo command works, you must have /Users/yourUser/.npm-global/bin in your $PATH commands.
Open your global bash_profile file vim ~/.bash_profile.
add export PATH=$PATH:~/.npm-global/bin.
Save the changes, and right after in your command line:
source ~/.bash_profile
Now you can try the command again!
Important Note: .bash_profile will run only on login shells. For non-login shells, you would need to create or edit .bashrc with this line above.

Can't access conda after changing name of mac user account

When I first got my Macbook Pro, I set it up where my home folder was named
/Users/monicaheddneck/
I installed all the software I needed, like python, etc, and went about my business.
Last night, I decided to change the name of my folder to simply
/Users/monica/
and did it this way.
Fine.
Today, I decided to run jupyter notebook for the millionth time, and realized I may have borked all paths for all the libraries I have...and who knows what else.
For example,
conda --version
tells me I don't even have conda installed:
-bash: conda: command not found
My question: is there any way to fix the broken path to conda?
I am using Mac High Sierra, version 10.13.3
When using the conda installer, it asks if you want to add and export line with the path to conda in your bashrc file. My guess is that it wasn't updated when you changed the name of your account.
Have a look at your bashrc (hidden file) which should be in your home and update it as necessary ! The line should look like this:
export PATH="/Users/monicaheddneck/xxxconda/bin:$PATH"
and should be fixed appropriatly:
export PATH="/Users/monica/xxxconda/bin:$PATH"
You will then have to source your new bashrc file or restart a terminal.

Homebrew version of vim won't open files

I installed vim via brew so I could have the latest version (7.4) and get syntax highlighting for Clojure. No big deal. Unfortunately, the brew version of vim seems to be broken on my system. I also aliased the vim command:
brew install vim # Install went successfully
alias vim=/usr/local/Cellar/7.4.052/bin/vim # Shouldn't be any problems here
When I open the brew version of vim, it fails to load any of my plugins (I use spf13) throwing a bunch of "Undefined variable" and "Invalid expression", etc errors for every plugin in my bundle directory; I just hit enter to continue. My .vimrc loads properly. When I open a file, it opens two tabs, both blank. One is a new file, the other is the file I tried to open, except there's nothing in it.
Potentially useful information: echo $VIM returns an empty line, while echo $ZSH returns /User/bsima/.dotfiles as expected.
Here are my dotfiles, but I don't think the problem lies in those configuration files.
Is this a known bug? Or is something wrong with my vim install?
I have no idea what's going on and I really miss my vim :( As good as Textmate is, I can't be without vim forever.
Edit: MacVim, installed via Homebrew, kinda works. It still opens 2 tabs on startup, but it does open files for editing and saves.
I found the problem: it was with my spf13 vim config. The following commands fixed the issue, in addition to double-checking that symlinks such as ~/.vim and ~/.vimrc were correct:
> which vim # This should output /usr/local/bin/vim since I'm using Homebrew
/usr/local/bin/vim
> cd ~/.spf13-vim-3
> ./bootstrap.sh # Basically re-installs spf13

Can I run the bundle open command inside of MacVim?

When I issue the bundle open command in the terminal, the "vi" editor comes up, but it doesn't seem to have all the defaults and settings I'm used to, and it looks fairly ugly as well. Is there a way to have bundle open start-up in MacVim outside the terminal, or can I issue bundle open in MacVim so it comes up there?
You can have bundle open send the file to MacVim for you. First, you need to make sure the mvim script that comes with MacVim is installed; instructions here.
Then, as #Randy Morris said in a comment, you need to set your EDITOR environment variable to mvim. You could add that to your .bash_profile file in your home directory to make it permanent; pretty much every Unix command that launches an editor will use it.

Resources