I'm trying to set up a dev environment on my Mac Mini running Bir Sur 11.2.3. I can add commands to the .zshrc file, but they only seem to work in my home directory. For example...
chris#chriss-mac-mini an_app % which flutter dart
flutter not found
dart not found
chris#chriss-mac-mini an_app % cd ~
chris#chriss-mac-mini ~ % which flutter dart
dev/flutter/bin/flutter
dev/flutter/bin/dart
My .zshrc file looks like this...
chris#chriss-mac-mini ~ % cat .zshrc
export PATH="$PATH:dev/flutter/bin"
Why am I unable to use the flutter command in other directories on this machine?
Short answer: change the line in your .zshrc to this:
export PATH="$PATH:$HOME/dev/flutter/bin"
Long answer: the path you added to your PATH environment variable, dev/flutter/bin, doesn't start with "/" so it's a relative path, meaning it'll be resolved relative to wherever your current working directory happens to be. If you're in /Users/cjmcqueen (or whatever your home directory is), it'll resolve to /Users/cjmcqueen/dev/flutter/bin, which is presumably where the actual binaries are. But if you're in /random/other/path, it'll resolve to /random/other/path/dev/flutter/bin, which probably doesn't even exist (let alone contain binaries for the flutter, dart, etc commands).
To solve this, you need to add a full absolute path to the binaries, instead of a relative one. In some situations, ~ will expand to the path to your home directory (so ~/dev/flutter/bin will work), but not in all situations. In this particular situation, $HOME is better because the shell will expand it to the absolute path to your home directory before storing it in the PATH variable, so you don't have to depend on something else resolving it later.
export PATH="$PATH:dev/flutter/bin" is referencing a relative path.
dev/flutter/bin should be something like /Users/<user>/dev/flutter/bin.
In the terminal, go to the directory for your flutter bin folder and type pwd. This is the full path it should reference.
Related
So I wanted to install MySQL on my MBP and I edited my bash_profile, added a path variable, however when I run echo $PATH from iTerm2 I get my path as:
Robs-MBP:~ Rob$ echo $PATH
/usr/local/mysql/bin
Ive tried a lot of commands and even used sudo and it just says command not found. My fear is that I have completely messed up, and now nothing works. Please help.
You've made a simple mistake: all you've done is reset the PATH env variable. To correctly do this, you should always add the existing PATH to the end of whatever you're adding. In you case:
PATH=/usr/local/mysql/bin:$PATH
To fix your problem from the terminal, you'll need to reset your PATH to somewhere with a text editor. I don't know where this is located on OSX, so you'll have to find it. After you know where your path should point, run:
$ export PATH=<YOUR_PATH_HERE>
Then edit your bashrc to include the original path as described above, and restart the terminal.
Alternatively, open .bashrc with a GUI text editor and make the change from there. Your PATH decleration should always end in :$PATH to include the PATH created by your system.
I want to add destination of iCloud drive folder to PATH in terminal.
I tried to add this line to .bash_profile (that path works with cd command)
export PATH="~/Library/Mobile\ Documents/com~apple~CloudDocs/Scripts:$PATH"
and nothing happened. Even ...com\~apple\~CloudDocs... doesn't work.
After calling echo $PATH, there was added entire path to iCloud drive exactly how I wanted. But when I call any of scripts located in that path No such file or directory error occurs.
When I rewrite .bash_profile file to export export PATH="~/.Scripts:$PATH" and relocate scripts there, everything works.
After doing a little bash code analysis, it looks like if your path beings with ~, then any subsequent ~ in the path is affected.
From tilde.c
/* Scan through STRING expanding tildes as we come to them. */
while (1)
Instead of using ~/Library/...,
try /Users/[user]/Library/...
I tried to make iverilog command s.t I can run verilog program on my Macbook Air.
After few steps for installing the files, the tutorial told me to type:
export PATH=~/bin:/usr/local/iverilog/bin
It worked in terms of iverilog command, i.e, I can compile .v file. However, normal command like ls, man,etc.
I guess it is the problem of the PATH of the command sets, which means those normal unix command is not located.
Can someone tell me how to fix it and I dont need to export the PATH everytime?
You didn't add your paths to the current paths established by the OS. Instead, you replaced it with your paths. This is what you need to do in order to add paths to your PATH variable:
export PATH=$PATH:~/bin:/usr/local/iverilog/bin
The $PATH part is your current PATH value, which is added (concatenated actually) to the list of new paths you want to add. This is turn is assigned to PATH variable.
To make this additions permanent, you may want to add the above line to the end of your .profile file, or .bash_profile (whatever you have in OS X)
You can also do as this:
http://architectryan.com/2012/10/02/add-to-the-path-on-mac-os-x-mountain-lion/
Which says that you can edit the file /etc/paths and add whatever paths you want to add, one per line, then save that file and your added paths are available. In this case, just remember to use absolute paths. That is, paths starting with / . The first one you use: ~/bin is not an aboslute path. You need to convert it to an absolute path. To do this, remember that ~ is a shortcut to your HOME directory: something like /Users/myloginname. Type echo $HOME to find it out.
I'm learning Laravel and found this direction on their documentation:
"Make sure to place the ~/.composer/vendor/bin directory in your PATH so the laravel executable is found when you run the laravel command in your terminal." http://laravel.com/docs/4.2/installation#install-laravel
Question:
How exactly I make sure the folder is on my PATH? What's the command?
If I'm not on the PATH, how to get there? I tried to find /.composer/vendor/bin but got nothing.
I'm using Windows 8 64bit.
1) windows: PATH | grep -oP ".composer.*bin"
If it's in the path You'll get a response if it's not you'll get nothing.
2)
~/ refers to home path on linux doing %HOMEPATH% on windows results in the same thing, which in your case would be %HOMEPATH%/.composer/vendor/bin
Doing /somefolder Will go to the root path in linux and try to find a folder there called somefolder but won't do anything in windows, I'm not sure what the equivalent in windows is, might be referring to root of the drive, I.e. C:\ or D:\ etc.
To add .composer/vendor/bin to your home path you need to go to your environmental variables and add it into the path you can go here and follow the steps in the answer or the question.
The important bit:
Example of windows SETX command:
Print the PATH environment variable:
C:\Users\Charity>echo %PATH% C:\windows\system32;C:\windows and
space;C:\foobar Use setx to set the environment variable:
C:\Users\Charity>setx PATH "%PATH%;C:\zombiepoke" SUCCESS: Specified
value was saved. Close and re-open cmd terminal, then run:
C:\Users\Charity>echo %PATH% C:\windows\system32;C:\windows and
space;C:\foobar;C:\zombiepoke You have to be careful with double
quotes. If you let quotes get into your path variable it might break
something. However they are necessary for specifying addendums to the
original %PATH%.
Make note though that this only sets it for the current user context, to set it for all users you have to to use setx /M.
for those who also needs the answer for this question, I found it here.
Basically, all you need is to write:
cd %APPDATA%\Composer\vendor\bin
I am looking to enable my terminal with the MacVim/mvim command so that I can access macvim through the terminal.
Following directions, I have downloaded and unzipped the MacVim files.
To be able to access MacVim through the terminal, one requires to set the VIM_APP_DIR environment variable with the value being the location of mvim script or the MacVim path.
By attempting the following command:
export VIM_APP_DIR = "the filepath"
I carried out printenv and VIM_APP_DIR does not exist in the set of environment variables.
Now that sounds more like a problem within a problem. The problem is I am unable to find a way to enable my Mac OS X Lion to be Vim powered and the above was the recommended route towards glory, however leave glory, the actor wasn't even there (VIM_APP_DIR).
First, you may not have to set the VIM_APP_DIR environment variable if you put the MacVim.app bundle in one of the “usual” locations:
~/Applications/ (the Applications folder in your home directory)
/Applications/ (the main Applications folder on the computer)
/Applications/Utilities/
It actually checks a few more locations, too: some relative to the location of the mvim script, and in a vim/ directory under the described directories.
In most cases, you should only need to set VIM_APP_DIR if mvim complains like this:
Sorry, cannot find MacVim.app. Try setting the VIM_APP_DIR enviro
nment variable to the directory containing MacVim.app.
Second, if you have to set VIM_APP_DIR (because you keep MacVim.app in an “unusual” location), the value of the environment variable should be the directory that contains MacVim.app, not the location of MacVim.app or mvim itself.
For example: If, you moved MacVim.app to /MyFavoriteApps/MacVim.app and have mvim available somewhere in your PATH, then you would need to set VIM_APP_DIR to /MyFavoriteApps (not /MyFavoriteApps/MacVim.app).
Third, in bash (the shell you are probably using), parameter assignments must not have spaces around the equal sign. It should look like this:
export VIM_APP_DIR=/MyFavoriteApps
If the pathname has spaces or special characters, then you may need to quote it. Single quotes are a good choice because they represent a literal string (you can include any character except a single quote itself).
export VIM_APP_DIR='/My Favorite Apps'
Last, you will probably want to put this “assignment and export” in your shell’s initialization file to make sure the value is set in all your future shell instances. A good choice is usually ~/.bashrc.
I don't know where you're getting this from. All that is required is to put the mvim script in your path, e.g., /usr/local/bin, and MacVim.app in a "normal" location such as /Applications or ~/Applications. Full list here: https://github.com/b4winckler/macvim/blob/master/src/MacVim/mvim (line 20).