How do i run 'composer' command via SSH? - ssh

I want to reload my project's custom classes in Laravel so they become accessible, but on a shared hosting enviroment. To my understanding, so far, locally, I've been achieving the desired by using this command:
composer dump-autoload
however, running that via putty's SSH gives me:
-bash: composer: command not found
Any idea?

please try:
php composer.phar dump-autoload
Because composer is only avaialble when installed globally, into /usr/local/bin/composer path.
Hope that helps!

You have to install composer on the remote machine that your are ssh'ing to. You can find installation instructions on the composer homepage.

Try this command: # php-cli composer.phar --help
In some servers Composer should be invoked via the CLI

Try:
php composer.phar dump-autoload
or
php composer.phar update

In webfaction is: php54 composer.phar dump-autoload

If you are running in a production environment make sure to run:
[path to composer.phar] dump-autoload --optimize
This will autoload ony the necessary classes and GREATLY increase performance of your Laravel app.

If you are working with shared hosting, you probably need to put the full path to your composer executable. So it was in my case. Following the recommendations in this answer SSH Shell commands not found (composer, npm), I managed to run composer from the bash script:
which composer // In remote machine manually
This command shows the path where composer is installed on the remote server. You can also see the path by doing:
echo $PATH // you can surely add it
If composer is not on the $PATH, You can add it, if shared hosting gives you enough privileges, or you can just run the command in your bash script by calling composer with the full path. In my case it was to run:
$/opt/cpanel/composer/bin/composer install

Related

Environment variables (zsh terminal) installed through npm on MacOS 12.4 Monterey - SOLVED

Background:
Dear Stackoverflow community. I recently switched from Windows to MacOS and am at a loss how to configure environment variables. Many of the previous questions asked here are about bash instead of zsh.
Goal:
I am trying to install an npm package globally. For instance:
npm install -g vercel
or any other package, and use it in my Visual Studio Code terminal (also zsh). If I want to deploy code I have to use 'npx vercel deploy' every time. I want to be able to use "vercel deploy" but instead I get:
zsh: command not found: vercel
What I tried so far:
Installing the package in zsh and visual studio code terminals (didn't work)
Setting the path equal on both VS and terminal: export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
I learned that you need to add environment variabels to a .zshrc file. I don't seem to have a zshrc file. When I do:
sudo ~/.zshrc
Password: XXXXXX
sudo: /Users/vincent/.zshrc: command not found
I am getting another error.
I read in the zsh man file that you should use $HOME/.zshrc instead. Again I am getting the same errors:
vincent#Vincents-MacBook-Air-2 ~ % $HOME/.zshrc
zsh: permission denied: /Users/vincent/.zshrc
vincent#Vincents-MacBook-Air-2 ~ % sudo $HOME/.zshrc
sudo: /Users/vincent/.zshrc: command not found
Update 1:
#slebetman Thank you for your explanation. When I open the terminal I go to home via "cd $HOME" which puts me in in the home directory. However there is no way for me to create a .zshrc file in that directory. Neither via touch or vs code. I am getting the following error: "Unable to write file '/home/.zshrc' (Unknown (FileSystemError): Error: ENOTSUP: operation not supported on socket, open '/home/.zshrc')"
Update 2:
I did manage to find the .zshrc file in visual studio code under /etc. I hope this will work. I was able to overwrite the file with Sudo and add environment variables to it.
Add this to the file .zshrc file under /etc and force overwrite it:
export vercel=/Users/vincent/.npm-global/bin/vercel
Screenshots below for those who will try in the future:
Image with .zshrc file layout
Final remarks:
I don't understand how it is so difficult to add environment variables on Mac while everything else is so easy.
I have read many different questions on stackoverflow, and I can't seem to solve it. Also since I am a newbie I am not allowed to comment on there so I post here in the hope that anyone can help me :)
Best,
Vincent
Note that when you do:
npx vercel deploy
Npm will execute vercel for you without installing it. It does that by temporarily downloading vercel. If you want to run vercel directly without using npx then simply don't use npx. Install it instead:
npm install -g vercel
The -g flag installs the module globally and if the module has a CLI it will be available globally as well (note that depending on your setup you may need admin/sudo privileges to use the -g flag). Now you can run vercel by simply typing:
vercel deploy
This works in all operating systems supported by node.js and npm. That means you can even do this in Windows. In fact I use npm to distribute my tools in a simple cross-platform way so I don't have to support multiple package managers like chocolatey (Windows), homebrew (Mac OS), deb (Debian based distros), rpm (Redhat based distros) etc. (npm does not require your software to be written in node.js - I have published packages on npm written in tcl and bash).

How we could dockerizing a Proton-Native App and see the GUI?

I'm trying to dockerize a Proton-Native App, buy i'am not able of see the basic proyect
This is my Dockerfile
FROM node:13
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
RUN npm install
COPY . ./
RUN npx proton-native-cli init .
CMD ["npm", "start"]
Then I run
docker build -t sample:dev .
and
docker run sample:dev
Assuming that is posible see the GUI, not only access the docker image. What would be the correct way to complete the configuration?
Thanks for read! :)
This idea, dockerizing a Proton-Native App for see the gui, is not a simple task, requires "a lot of extra work to get the display to show up at all (including installing extra host software on non-Linux hosts) and even more work to get access to user preferences and data files", like #DavidMaze explains

apidocjs not returning anything in response

I have installed 'apidoc' after installing 'npm' and 'node' for my API documentation by the help of following command:
npm install apidoc -g
After installing apidoc globally, I simply ran below command on my project directory (assuming apidoc will consider its default template file):
apidoc
In result no errors and no documentation generated.
Similarly, I have tried:
apidoc -i ~/PROJECTS/jruby/project/webservice/ -o ~/PROJECTS/apidocs/apidoc/ -t ~/PROJECTS/apidocs/mytemplate/
But nothing happens, in that case I had nothing on 'mytemplate' directory.
Can you guys please tell me what I've missed to install/consider? and why nothing is appearing on command execution?
Note: I'm using this for my ruby application, but unable to install its gem as we're running our application on ruby 1.9 and it requires ruby 2.0. I need an independent solution that should works for other projects as well.
Thank you.
I got the solution; copied 'package.json' file from https://github.com/apidoc/apidoc and ran below command for npm
npm install
after getting success install nodejs properly by following steps:
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install nodejs
then went to the project directory and ran the following command:
apidoc
after success of above command got html document in doc/ directory inside project. Cheers !

Deploying Laravel 4 with Capistrano. Permission denied during `composer install`

I'm trying to use Capistrano to deploy my Laravel 4 site and when I try to:
run "cd #{current_path} && composer install --no-dev"`
in my deploy.rb I get this error:
sh: 1: composer: Permission denied
and a few lines later:
failed: "sh -c 'cd /var/www/public/mysite/current && composer install --no-dev'" on root#my.ip.add.ress
If I comment out the run command above then Capistrano is able to complete the deployment successfully. However, I then have to manually run composer install from the current release directory of my site in order to get everything on my site working properly.
I've tried running my deploy with the -d flag to go through the deployment step by step, I've tried fixing permissions in case they were incorrect, but neither seems to fix this error. Also, I've looked all over for a possible answer and can't find anyone else with this specific issue.
So, I have two questions:
Any ideas of a fix to this?
It seems like running composer install each time I deploy is just creating more work than is necessary. Would it be better to either:
a) not ignore the vendor folderin my local repository therefore removing the need to runcomposer install` on each deploy? Or,
b) run composer install in the root directory (at the same directory level as current and releases) and then change the path to vendor/autoload.php in the bootstrap directory to point to this new directory so I never need to run composer install again?
I figured it out. Instead of:
run "cd #{current_path} && composer install --no-dev"
I'm doing this instead:
run "cd #{releases_path}/#{release_name} && php /usr/local/bin/composer/composer.phar install --no-dev"
(I changed #{current_path} to #{releases_path}/#{release_name} because Capistrano was executing rm -f /var/www/public/myapp/current AFTER the composer install command.

Urturn API ur: command not found

I am trying to install urturn api and write my own expression for urturn.com
following http://webdoc.github.com/urturn-expression-api/#!guides/start
After:
npm install urturn-toolbelt -g
I am trying to run sandbox with:
ur sandbox
and got error:
-bash: ur: command not found
Please help
P.S. I am on Mac Os
thanks
It is likely your nodeJS npm/bin folder that is not included in your PATH.
Can you check your PATH variable?
Node NPM package bin files are all symlinked in the same ./bin folder. If you installed NodeJS using Homebrew (brew install node), it should be /usr/local/share/npm/bin.
You can echo your current path using:
echo $PATH
If the folder above does not appear in the list, check your .bashrc or .bash_profile files and fix any problem.
A fix that is likely to work is to add the following line in ~/.bash_profile
PATH=$PATH:/usr/local/share/npm/bin