Laravel "valet install" not found - laravel

I am trying to set up Laravels Valet (Valet is a Laravel development environment for Mac). Everything works until it comes to the command "valet install". This command must be executed in terminal. But I got the error "command not found". Any ideas, why? Do I have to update my PATH or something else?
I switched to OS X a few days ago. Before that, I was a windows user. So I am a total newbie.

Yes, you need to make sure that ~/.composer/vendor/bin directory is in your system's PATH, you can check this by running:
echo $PATH
If you can't see it there, then you need to add this to your ~/.bash_profile:
export PATH=$PATH:~/.composer/vendor/bin

If you're getting the error message "valet: command not found", it's likely that PHP's Composer is not in your PATH variable, for instance:
$ valet install
-bash: valet: command not found
You can confirm if Laravel Valet was successfully installed by running the following command:
ls -al ~/.composer/vendor/bin/valet
If successfull, you'll see the symlink for Valet in Composer's bin directory pointing to Laravel in the vendor directory:
~/.composer/vendor/bin/valet# -> ../laravel/valet/valet
To test whether your PATH is missing Composer, try running the Valet command directly:
~/.composer/vendor/bin/valet --version
If you're shown the Laravel version number, (e.g. Laravel Valet 2.0.4), this indicates Valet is installed but you need to update your PATH variable to include Composer for the valet command to work globally.
In your Terminal, execute the following command which will append Composer to your shell's PATH:
export PATH=$PATH:~/.composer/vendor/bin
For the changes to take effect, you'll need to exit and re-open your Terminal window or tab.
Alternatively, you can simply source your shell's profile, which doesn't require quitting your active session:
source ~/.bash_profile
If you have a different shell environment or you're using a shell other than Bash, you will need to source its configuration profile instead (e.g. .bashrc, .zshrc, config.fish).

I'm using oh-my-zsh so:
echo "export PATH=$PATH:$HOME/.config/composer/vendor/bin" >> ~/.zshrc
source ~/.zshrc
You may replace .zshrc with .bashrc

you just have to use:
export PATH="$PATH:$HOME/.composer/vendor/bin"
then
valet install
ready :)

Make sure that ~/.composer/vendor/bin directory is in your system's PATH, you can check this by running:
echo $PATH
If not there, open your ~/.bash_profile and add this code:
export PATH=$PATH:~/.composer/vendor/bin
Then run:
composer global require laravel/valet --dev
Once it is done, run:
valet install

If valet install doesn’t work, but ~/.composer/vendor/bin/valet --version does work, try installing it via
~/.composer/vendor/bin/valet install
To See if that worked, check
valet --version

If you're using zsh, you cannot use ~ as path to home dir, use $HOME instead.
In .zshrc file, instead of adding this:
export PATH=$PATH:~/.composer/vendor/bin
Add this and the path will resolve:
export PATH=$PATH:$HOME/.composer/vendor/bin

If you have a fresh installation, you may not have the PATH variable contains your home path. So, adding the $HOME variable would require like the following:
export PATH="$PATH:$HOME/.composer/vendor/bin

This command might solve your problem
test -d ~/.composer && bash ~/.composer/vendor/bin/valet install || bash ~/.config/composer/vendor/bin/valet install

In Ubuntu 18.04 do this:
echo "export PATH=$PATH:$HOME/.config/composer/vendor/bin" >> ~/.bashrc
source ~/.bashrc

with new composer installation, you need to add a new path which is
export PATH=$PATH:~/.config/composer/vendor/bin
Then you need to
chown YOUR_USERNAME ~/.config
for accessing composer packages without sudo command.

I have installed Composer version 2 and found that composer default path is ~/.config/composer/ and similarly valet is also installed on /.config/composer/vendor/bin/valet.
So to solve this issues I added the composer path to ~/.bashrc file as:
export PATH=$PATH:~/.config/composer/vendor/bin

Add ~/.composer/vendor/bin directory to your PATH variable.

For me worked
write in console
cd ~/.composer/vendor/bin
pwd
copy pwd command result
export PATH=$PATH: (pwd command result)
valet install
I think I explained well

I found a fix on this website, and it fixed my issue.
test -d ~/.composer && bash ~/.composer/vendor/bin/valet install || bash ~/.config/composer/vendor/bin/valet install
https://hidayatabisena.medium.com/solving-issues-command-not-found-laravel-valet-install-on-macos-mojave-2a7629759a9f

In my case I've to update /etc/profile file
added
export PATH=$PATH:~/.composer/vendor/bin
in
/etc/profile
then
source ~/etc/profile

In my case I found the valet location by manual search
Then add the the valet file path to PATH variable
echo 'export PATH="$PATH:$HOME/.config/composer/vendor/bin"' >> ~/.bashrc
Then I ran the install command and it worked
valet install

Php may be not installed
Use your prefered version with:
brew install php
// or
brew install php#8.0
// or
brew install php#7.4
This solved my issue.

Related

Why doesn't shell scripts in Shortcuts see my utilities?

i tried using shortcuts. i wanted to run scripts there, but i constantly get an error that the brew utility was not found. it feels like the scripts run in isolation.
i tried use
brew link php
eval 'brew link php'
sh fileWithMyScript.sh
and always got error. how to fix it?
The brew command is not in macOS default PATH. You will either have to use the full path to the command or set PATH before calling the command:
/opt/homebrew/bin/brew link php
PATH=$PATH:/opt/homebrew/bin brew link php
PATH=$PATH:/opt/homebrew/bin cd ~/utils && sh php_8.1.sh
Use a different directory than /opt/homebrew/bin if homebrew is installed elsewhere.

Why doesn't zsh recognize command from globally installed npm package?

After installing oh-my-zsh and reinstalling node and npm again, I install npm-check-updates globally and try to call 'ncu' (the npm-check-updates command). However, I get an error: zsh:
command not found: ncu. Does anyone know how to fix this?
I have corrected this problem with the following instructions:
sudo npm install -g npm-check-updates
Make sure the 'ncu' package can be found in the $PATH environment variable. Try this, to find where 'ncu' is supposed to be installed:
which ncu
If it still gives you trouble, try to see if it's in /usr/bin, $HOME/npm/bin, /usr/local/lib or /usr/sbin, and check that your $PATH environment variable contains a way to 'ncu'. Your $PATH environment variable, which can be found in
$HOME/.bashrc (Linux)
$HOME/.bash_profile (MacOS)
should look something like this:
export PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$HOME/npm/bin
After an install you can run rehash so zsh will analyse what new executables are available on $PATH.
Not sure if that would fix the problem, I know it fixes the missing tab completion entry after install.
FYI I am using a OSX.
The problem was that my export path in my .zshrc was wrong.
This was what it was previously:
export PATH=$HOME/bin:/usr/local/bin:$PATH.
Notice there is nothing pointing at npm or any of the packages I installed globally.
For anyone who has this problem in the future...
Ensure that npm is installed and that you can still run npm commands (if not uninstall then install npm). Then run npm -g list --depth 0 to list all your global packages.
Go into your home folder and press ⌘+Shift+. (shows all hidden files/folders), there should be a .npm folder there, ensure the packages in the list you obtained in the previous step matches what's in the bin folder.
Edit your export PATH string accordingly:
export PATH=$HOME/bin:/usr/local/bin:**$HOME/.npm/bin**:$PATH.
This worked for me!

need to manually create symlinks every time i install something

For example, I'm trying to install pipenv using the following commands:
$ pip3 install --user pipenv
$ cd ~/Documents/myproject
$ pipenv install requests
zsh: command not found: pipenv
It seems that the issue can be resolved if I run sudo ln -s ~/.local/bin/pipenv /usr/bin. Is this a safe thing to do? I've also been having this issue with several other packages, like tensorboard and xflux. Is there something wrong with my system that makes it such that I need to manually create a symlink every time? How can I change things so that packages can install normally without me having to do this every time?
The problem you are having is that the tools you are installing are being installed in non-standard locations and are not being included in your PATH. One way to resolve this would be to include the paths in your PATH environment variable. In order for these programs to be in your path every time you login, do this (assuming you are using zsh as your shell):
1) Open ~/.zshrc using vim or any other editor:
vim ~/.zshrc
2) Append the following to this file:
export PATH=$PATH:/path/to/dir/containing/pipenv
Remember to replace /path/to/dir/containing/pipenv with the appropriate path.
3) Source your ~/.zshrc so that the path is included in your current session:
source ~/.zshrc
4) Now everytime you login, the paths should be available in your environment and you won't need to create symlinks.

Golang installation

I just followed the installation guide for golang (ubuntu 16).
I extracted the archive at /etc/usr
I added env variable in /home/user/.profile
I just tested a basic go build on the hello world code.
I get the following error:
The program 'go' is currently not installed. You can install it by typing: sudo apt install golang-go
Why does it ask me to install it (again?)?
open the go documentation download
https://go.dev/dl/
choice your os and go version
download then extract the file
extract the file
open the file and open the terminal
6.Add /usr/local/go/bin to the PATH environment variable.
export PATH=$PATH:/usr/local/go/bin
then check the go version
go version
The location of the binary go is not in your path. Ubuntu does not find it and suggests to install it. Add this line to your file /etc/profile, or better $HOME/.profile:
export PATH=$PATH:/usr/local/go/bin
This is documented in the docs: https://golang.org/doc/install#install
If you want to try this solution before editing any files, you can just execute the above command and try to execute the go command in the shell.
There are paths which needs to be set correctly for you go installation to work
GOROOT points to directory where go is installed
export GOROOT=/usr/lib/go
GOPATH points to you workspace directory
export GOPATH=$HOME/go
These paths need to be added in global path variable.
export PATH=$PATH:$GOROOT/bin
You need to put the go executable in your system path. which you can do by
export PATH=$PATH:/etc/usr/go/bin
You can put the same in /home/user/.profile
just use asdf for installation. You can have several version also :D
Docs: https://asdf-vm.com/#/core-manage-asdf
downlaod the installer form enter link description here, choose intaller for linux that suit your device and then you go to your CLI and use wget or curl :
$ wget https://storage.googleapis.com/golang/go1...
and then extract the file to /usr/local :
$ tar -C /usr/local -xzf go1...
add path binary Go to PATH environment variable :
$ echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.bashrc
$ source ~/.bashrc
and then use go version to check if the Go already installed
If You are using linux then open your terminal and run this command.
sudo apt install golang-go
This command will Install Go lang. in your system. ThankYou
Steps for Go installation:
sudo apt-get update && sudo apt-get -y upgrade    
wget https://dl.google.com/go/go1.17.5.linux-amd64.tar.gz
sudo tar -xvf go1.17.5.linux-amd64.tar.gz
sudo mv go /usr/local/
export GOROOT=/usr/local/go
Add in .bashrc
vi .bashrc
export GOPATH="/root/go"
export GOROOT=/usr/local/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
Download latest version from https://golang.org/doc/install
tar -xzf go1.15.7.linux-amd64.tar.gz
move to /usr/lib/ to folder with version number
sudo mv go /usr/lib/go-1.15
create symkink link on /usr/bin/
ln -s /usr/lib/go-1.15/bin/go /usr/bin/go

Issue with activating virtualenv

I installed python environment by means of commands:
SYS_INSTALL="apt-get install -y"
PIP_INSTALL="pip install"
# Be sure to install setuptools before pip to properly replace easy_install.
$SYS_INSTALL git
$SYS_INSTALL python-dev
$SYS_INSTALL python-setuptools
$SYS_INSTALL python-pip
$PIP_INSTALL virtualenv
also was able to create new virtual environment:
virtualenv .env
However, after running a command like:
. .env/bin/activate
I got
-bash: .env/bin/activate: No such file or directory
After reviewing folder .env/bin I found only one python file. Whole list of files here:
.env/lib:
python2.7
.env/include:
python2.7
.env/bin:
python
What is the issue here?
SOLUTION add --always-copy
virtualenv .env --always-copy
For me it works when I do these steps:
Go to the directory/folder that you want
run virtualenv .env
then run source .env/bin/activate
The accepted answer is incomplete! The suggested code left out your error, but didn't comment on it.
The command . .env/bin/activate would indeed do the same as source on the file activate in the folder .env/bin. In fact, apparently the command "source" is an alias for the command ".", and not the other way around. Note that . here has a space after it, and used differently from the . discussed below (which makes files and folders hidden).
What I notice is that you are calling your folder .env, which is not standard practice. Files and folders preceded by . are made "hidden" by Mac OS X. Standard practice is to call a virtual environment directory env or venv, and to call the virtual environment specification file .env.
So, if your spec file is called .env and your virtual environment directory is called env, you can run either
source env/bin/activate
or
. env/bin/activate.
I had the same issue and the following steps resolved it:
$mkdir annotateNLP
$cd annotateNLP
$python -m venv env
$source env/Scripts/activate
Try these commands in the terminal:
$ mkdir djangoapp
$ cd djangoapp
$ python3 -m venv myvenv
$ source myvenv/bin/activate
You can't go straight into activate command without first creating your virtual environment.
you forgot to include source before activating command is
source env/bin/activate
this question is similar to your's
virtualenv is not compatible with this system or executable
where it creates virtualenv but,python file instead of activate in bin
After going to your virtual environment folder .\Scripts\activate.
In my case, I need to install
sudo apt-get install python3-venv
$ virtualenv env
$ cd env/Scripts/
$ . activate
I was facing this same issue. I uninstalled the virtualenv in Ubuntu and then I installed it again. After this nonsense, it works and now I am able to activate my virtualenv through -$source py3/bin/activate.
If installed venv on a Windows machine, run this command (assuming you are in the working directory that has your venv folder):
In bash terminal: source venv/Scripts/activate
In cmd terminal:
venv\Scripts\activate
where venv is the folder name for your virtual environment
For windows using git bash, run the below command:-
source env\Scripts\activate

Resources