No response from terminal with hhvm command - php

when I input hhvm command. Terminal deoesn't response.
[environment]
Ubuntu 15.10
HipHop VM 3.11.0
Composer 1.0-dev
vagrant#vagrant-ubuntu-trusty:/var/www/html$ cat test2.hh
<?hh
require_once 'vender/facebook/xhp-lib/init.php';
echo <p>test</p>;
vagrant#vagrant-ubuntu-trusty:/var/www/html$ sudo hhvm test2.hh
Why??
If I remove .hhconfig file and input "touch .hhconfig" command, "hhvm test.hh" success one time.
But, I re-try "hhvm test.hh" and no-response....
vagrant#vagrant-ubuntu-trusty:/var/www/html/project$ sudo rm .hhconfig
vagrant#vagrant-ubuntu-trusty:/var/www/html/project$ sudo touch .hhconfig
vagrant#vagrant-ubuntu-trusty:/var/www/html/project$ sudo hhvm test.hh
<p>test</p>vagrant#vagrant-ubuntu-trusty:/var/www/html/project$
vagrant#vagrant-ubuntu-trusty:/var/www/html/project$ sudo hhvm test.hh
^Cvagrant#vagrant-ubuntu-trusty:/var/www/html/project$
I guess some service got lock of .hhconfig file...
Does someone give me hint??

I strongly suspect you are running into this issue with hh_client, which affects hhvm since the latter calls into the former. We are investigating it now, and will release 3.11.1 to fix it when we pin down the problem.
In the meantime, you can use the 3.9 LTS, or you can try passing -d hhvm.hack.lang.auto_typecheck=0 when invoking hhvm. (Though if you do the latter, make sure to stop doing that when 3.11.1 is out, since it removes protection against Hack type errors sneaking into your code!)

Related

Laravel Dusk error: Failed to connect to localhost port 9515: Connection refused

As the title says, I've go a clean install of Laravel 5.4 and the latest Homestead (1.0.1). However, when I run a simple Dusk test case I get the following error:
Failed to connect to localhost port 9515: Connection refused
Anyone know how to deal with this? I tried changing the port to something else such as 8888 to no avail.
EDIT:
I've been able to dig a little deeper and found out that the chromedriver executable was not actually executable (chmod). Now that I've fixed that I get this error when I manually try to run it.
./chromedriver: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
For those looking for a solution on Mac, I've just had to restart Chrome. Yes, Chrome, the browser. It seems it'd a pending update (it said that in the upper right corner).
Restarting it, and later chromedriver, make everything went fine
I had this issue today and the solution is on Laracasts.
Here's a copy.
# makes sure all your repos are up to date
sudo apt-get update
# chrome dependencies I think
sudo apt-get -y install libxpm4 libxrender1 libgtk2.0-0 libnss3 libgconf-2-4
# chromium is what I had success with on Codeship, so seemed a good option
sudo apt-get install chromium-browser
# XVFB for headless applications
sudo apt-get -y install xvfb gtk2-engines-pixbuf
# fonts for the browser
sudo apt-get -y install xfonts-cyrillic xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable
# support for screenshot capturing
sudo apt-get -y install imagemagick x11-apps
# Once all this has run through, you need to fire up xvfb on your homestead box. If you’re planning to # do this on a regular basis, you’ll want to get this setup on boot, but for the sake of testing things out:
Xvfb -ac :0 -screen 0 1280x1024x16 &
On Ubuntu Linux 16.04, I got this to work:
Install Chromium & dependencies for headless testing
sudo apt-get -y install chromium-browser xvfb gtk2-engines-pixbuf xfonts-cyrillic xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable imagemagick x11-apps
Create a customDuskCommand
Which extends the original, with this handle method:
public function handle()
{
$xvfb = (new ProcessBuilder())
->setTimeout(null)
->setPrefix('/usr/bin/Xvfb')
->setArguments(['-ac', ':0', '-screen', '0', '1280x1024x16'])
->getProcess();
$xvfb->start();
try {
parent::handle();
} finally {
$xvfb->stop();
}
return;
}
This will start Xvfb for headless testing before executing the tests and stop the process after testing completes.
Edit: And make sure vendor/laravel/dusk/bin/chromedriver-linux is executable.
Failed to connect to localhost port 9515 after 0 ms: Connection refused
Solution:
php artisan dusk:install
php artisan dusk:chrome-driver 65
It appears your chrome-driver installation is broken.
You can try to install it from scratch
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
wget -N http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -P ~/
unzip ~/chromedriver_linux64.zip -d ~/
rm ~/chromedriver_linux64.zip
sudo mv -f ~/chromedriver /usr/local/bin/chromedriver
sudo chown root:root /usr/local/bin/chromedriver
sudo chmod 0755 /usr/local/bin/chromedriver
This should help you download the latest version of chrome driver and unpack it properly.
LATEST_VERSION=$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE) && wget -O /tmp/chromedriver.zip https://chromedriver.storage.googleapis.co /$LATEST_VERSION/chromedriver_linux64.zip && sudo unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/;
Create a customDuskCommand
namespace App\Console\Commands;
use Symfony\Component\Process\Process;
class DuskCommand extends \Laravel\Dusk\Console\DuskCommand {
public function handle() {
$xvfb = (new Process(['/usr/bin/Xvfb', '-ac', ':0', '-screen', '0', '1280x1024x16']))
->setTimeout(null);
$xvfb->start();
try {
parent::handle();
} finally {
$xvfb->stop();
}
return;
}
}
Thanks to https://stackoverflow.com/a/44322930/470749. It was outdated and didn't work, so I'm providing an updated answer that works.
UPDATE:
I personally don't follow this approach anymore. After I deployed to production, I got this error: E_ERROR: Class 'Laravel\Dusk\Console\DuskCommand' not found because I'd forgotten that my composer.json only installed Dusk in the dev environment rather than also in production. If you adhere to the principle that "test code" shouldn't be deployed to production, then this approach of writing a custom class that extends \Laravel\Dusk\Console\DuskCommand probably is not for you (since the DuskCommand dependency won't exist in production).
I will leave this answer here anyway since it's hopefully a valuable warning to people. Please comment if you think I should delete it instead. By the way, Jonas Staudenmeir tends to have great answers, so this looks interesting as an alternative.
With the latest laravel/homestead box v.6.0.0 it's working out of the box
https://app.vagrantup.com/laravel/boxes/homestead

How to run bundle from PHP script

I'm writing a webhook to automatically publish a site when I push to GitHub. Part of the process requires that I build the site with
bundle exec middleman build --clean
I'm trying to invoke that with a PHP script, the script called by the GitHub webhook, so the user is www-data. No matter what I try, however, I'm getting an error that bundle cannot be found.
How can I run a bundle command from a PHP script?
I was able to figure this out. First, I installed rvm as a multi-user installation to ensure the www-data account can access it.
$ curl -sSL https://get.rvm.io | sudo bash -s stable
Install the desired ruby version, in my case 2.3.1, then set rvm to use it:
$ rvm install 2.3.1
$ rvm use 2.3.1
Run gem to install any gems that are needed. Because rvm is a multi-user installation, these gems are stored to the system and not your specific user.
$ gem install packagename
I don't know if this is necessary, but I would close the SSH session and reopen it. rvm messes with environment variables, so better safe than sorry.
Run env to print all environment variables. printenv also works if env doesn't for some reason. You'll get a big list of everything set, you only need the ruby-related ones. Do not copy/paste these values, they are examples I pulled from my system. Yours will be different!
PATH=/usr/local/rvm/gems/ruby-2.3.1/bin:/usr/local/rvm/gems/ruby-2.3.1#global/bin:/usr/local/rvm/rubies/ruby-2.3.1/bin:/usr/local/rvm/bin:/home/steven/bin:/home/steven/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
rvm_bin_path=/usr/local/rvm/bin
GEM_HOME=/usr/local/rvm/gems/ruby-2.3.1
IRBRC=/usr/local/rvm/rubies/ruby-2.3.1/.irbrc
MY_RUBY_HOME=/usr/local/rvm/rubies/ruby-2.3.1
rvm_path=/usr/local/rvm
rvm_prefix=/usr/local
rvm_ruby_string=ruby-2.3.1
GEM_PATH=/usr/local/rvm/gems/ruby-2.3.1:/usr/local/rvm/gems/ruby-2.3.1#global
RUBY_VERSION=ruby-2.3.1
Now we need PHP to recognize these variables. You'll need to find the right file on your system, which can be tricky. I don't have a way of knowing which one is correct, I used trial and error.
The file on my system is /etc/php/5.6/fpm/pool.d/www.conf. Add all of the environment variables you previously grabbed into this file with the below format. Note that you DO need PATH in here as well!
env[rvm_path] = /usr/local/rvm
env[rvm_prefix] = /usr/local
Now restart php-fpm. Your service name may be different from mine; I'm using the 5.6 build from ondrej/php.
Ubuntu 15.04 and newer (systemd):
$ sudo systemctl restart php5.6-fpm
Ubuntu 14.10 and newer:
$ sudo service php5.6-fpm restart
Finally, in the script itself you'll need to cd to the directory you're running the bundle command from. My short script is this:
cd /opt/slate
/usr/bin/git reset --hard
/usr/bin/git pull
bundle exec middleman build --clean
cp -R /opt/slate/build/* /var/www/docs
Works for me!

Starting PHPBrew FPM on system start

I am trying to build a vm, where exactly one user (as sudo or not) can brew and start a custom php build.
The current "default" php version should be started as phpbrew fpm process on system start. I was putting something like
phpbrew fpm start
in /etc/rc.local which seems to result in starting up the process. But the process is terminated as soon, as the rc.local script finished. It seems, that without an active login session, the process can't live.
Any suggestions, as how to make the fpm process survive?
Many thanks in advance.
You can modify this config according your needs.
phpbrew 1.22.0 now supports "fpm setup --systemctl" command to help you setup the service.
be sure to enable --with-fpm-systemd when building your php.
In phpbrew build directory it is exists ready file. For example:
~/.phpbrew/build/php-7.0.22/sapi/fpm/init.d.php-fpm
But more comfortable way is: temporary change owner of /etc/init.d to current user, then run command
phpbrew fpm setup --initd
then return back
sudo chown root:root /etc/init.d
sudo chown root:root /etc/init.d/phpbrew-fpm
and then
sudo update-rc.d phpbrew-fpm defaults
If you run it in macOS.
sudo PHPBREW_PHP=$PHPBREW_PHP phpbrew fpm setup --launchctl
and then add it to your launchctl list.
# Activate a system-wide daemon to be loaded whenever the system boots up (even if no user logs in):
sudo launchctl load /Library/LaunchDaemons/<path_to_phpbrew>.plist

Composer install/update not working

I have a problem with Composer Package Manager. System is Ubuntu 12.04. I just can't make it work. I pulled my git project and try to run 'composer install', but it seems that nothing actually happens. I just get an information
Installing dependencies (including require-dev)
then nothing actually happens. This is my log from this command run with -vvv parameter:
here
Does anyone have any idea what can be wrong ? I tried to clear cache, it did not help. I am sure this repo works well as I pulled it to my Windows machine and it downloaded everything just fine. 'composer diagnose' also returned OK.
Thanks for any tips.
In first place You should try clearing composer cache.
rm -rf ~/.composer/cache
But more probably it's issue connected with available memory. Increasing memory_limit should help.
Try to view a verbose report:
composer install -vvv
or:
composer update -vvv
If last line shows that process is killed, you need to increase your swap memory:
sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
swapon -s
if it continues killing the process, you need to increase 512k to 1024k or maybe 2048k
I had this issue and realised I had xdebug enabled. Disabling it fixed the issue for me.
Try with this one and make sure that the composer.json file exist in your project directory.
COMPOSER=composer.json composer update
Though similar answer has already been posted above but still , if composer install / update is not working try doing composer diagnose..
please refer..
https://getcomposer.org/doc/articles/troubleshooting.md
worked for me after updating my composer..
also sometimes internet might be the issue..
Happy Coding! :D

Composer killed while updating

I got a problem, I tried to install a new package to my Laravel 4 project.
But when I run php composer.phar update I get this:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Killed
I have looked for the problem in the Internet and saw that the memory is the problem, I think I don't have enough RAM available, I've checked this I have about 411mb free.
Does composer really need more RAM?
The "Killed" message usually means your process consumed too much memory, so you may simply need to add more memory to your system if possible. At the time of writing this answer, I've had to increase my virtual machine's memory to at least 768MB in order to get composer update to work in some situations.
However, if you're doing this on a live server, you shouldn't be using composer update at all. What you should instead do is:
Run composer update in a local environment (such as directly on your physical laptop/desktop, or a docker container/VM running on your laptop/desktop) where memory limitations shouldn't be as severe.
Upload or git push the composer.lock file.
Run composer install on the live server.
composer install will then read from the .lock file, fetching the exact same versions every time rather than finding the latest versions of every package. This makes your app less likely to break, and composer uses less memory.
Read more here: https://getcomposer.org/doc/01-basic-usage.md#installing-with-composer-lock
Alternatively, you can upload the entire vendor directory to the server, bypassing the need to run composer install at all, but then you should run composer dump-autoload --optimize.
If like me, you are using some micro VM lacking of memory, creating a swap file does the trick:
#Check free memory before
free -m
mkdir -p /var/_swap_
cd /var/_swap_
#Here, 2G ~ 2GB of swap memory. Feel free to add MORE
sudo fallocate -l 2G swapfile
chmod 600 swapfile
mkswap swapfile
swapon swapfile
#Automatically mount this swap partition at startup
echo "/var/_swap_/swapfile none swap sw 0 0" >> /etc/fstab
#Check free memory after
free -m
As several comments pointed out, don't forget to add sudo if you don't work as root.
btw, feel free to select another location/filename/size for the file.
/var is probably not the best place, but I don't know which place would be, and rarely care since tiny servers are mostly used for testing purposes.
Unfortuantely composer requires a lot of RAM & processing power. Here are a few things that I did, which combined, made the process bearable. This was on my cloud playpen env.
You may be simply running out of RAM. Enable swap: https://www.digitalocean.com/community/search?q=add+swap (note: I think best practice is to add a seperate partition. Digitalocean's guide is appropriate for their environment)
service mysql stop (kill your DB/mem-hog services to free some RAM - don't forget to start it again!)
use a secondary terminal session running top to watch memory/swap consumption until process is complete.
composer.phar update --prefer-dist -vvv (verbose output [still hangs at some points when working] and use distro zip files). Maybe try a --dry-run too?
Composer is apparently know to run slower in older versions of PHP (e.g. 5.3x). It was still slow in 5.5.9 for me...
DigitalOcean fix that does not require extra memory - activating swap, here is an example for 1gb:
in terminal run below
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
The above solution will work until the next reboot, after that the swap would have to be reactivated. To persist it between the reboots add the swap file to fstab:
sudo nano /etc/fstab
open the above file add add below line to the file
/var/swap.1 swap swap sw 0 0
now restart the server. Composer require works fine.
I've got this error when I ran composer install inside my PHP DOCKER container,
It's a memory issue.
Solved by increasing SWAP memory in DOCKER PREFERENCES from 512MB to 1.5GB
To do that:
Docker -> Preferences -> Rousources
Increase the memory limit for composer
php -d memory_limit=4G /usr/local/bin/composer update
Run composer self-update and composer clearcache
remove vendor and composer.lock
restart your local environment and then run
php -d memory_limit=-1 /usr/local/bin/composer install
If you're using docker you can use COMPOSER_PROCESS_TIMEOUT
environment:
COMPOSER_MEMORY_LIMIT: -1
COMPOSER_PROCESS_TIMEOUT: 2000 #seconds
Also in big projects composer needs more RAM than 2GB, you can check that with ps -aux while it is running.
You will have to add it manually inside docker options, nothing else will help.
Here's how I succeeded in installing maatwebsite\excel package from composer in Laravel Framework:
I download composer.json file and composer.lock file from my remote server.
I run composer update from local command prompt (then wait until all the install process finished).
Upload composer.lock file to remote server.
run composer install on remote server (then wait until all process finished).
DONE
composer 2 update have reduced the memory usage
composer self-update
composer update
composer require xxx
Fix for AWS ec2 Ubuntu Server Php Memory Value Upgrade For Magento 2.3.X
Php 7.2 / 7.3
nginx
ubuntu
composer 1.X
mariaDB
magento 2.3.X
Error : Updating dependencies (including require-dev)
Killed
for
Ram Must at least 4GB
Change instance type to suitable or Upgrade Ram
Php Memory Value change
Server Restart
Try to install the same package again
PHP value update
may locate under '/etc/php/7.2/fpm/php.ini'
depend on your server and PHP fpm X.XX version
Using Seed command 'change as your server requires'
on my case >> /etc/php/7.2/fpm/php.ini
memory limit type as "3.5G" or "3500MB"
Php 7.2.X
sudo sed -i "s/memory_limit = .*/memory_limit = 3.5G/" /etc/php/7.2/fpm/php.ini
Php 7.3.X
sudo sed -i "s/memory_limit = .*/memory_limit = 3.5G/" /etc/php/7.3/fpm/php.ini
Test if applied on 'free -h' command
free -h
Install-Package Again#
Install extension via Composer
go to your Magento 2 installation directory
cd /var/www/html/
with 'superuser' privileges
sudo su
Start installation
composer require XXXXXX/XXXXXXX
Enable Module s
php bin/magento module:enable XXXXXX/XXXXXXX
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
Restart
sudo reboot
Enjioy
I was facing this same issue on my ec2 instance, following steps worked for me :
Copied composer.lock file from my local environment to ec2.
then run sudo composer install and its simply installed all the dependencies for my project.
I solved it maintaining the below steps in my ubuntu server. Hope it will works for you.
Stop my apache server
sudo service apache2 stop
Run composer update
sudo composer update
Start my apache server
sudo service apache2 start
php -d memory_limit=5G composer.phar update
I get this problem caused for a package that don't update correctly with wildcards, I use directly the last version and it works finally.
"l3/cas-bundle": "~1.0" -------> "l3/cas-bundle": "1.1.13"
Solved on Laravel/Homestead (Vagrant Windows)
Edit Homestead.yaml and increase memory from 2048 to 4096
vagrant up
vagrant ssh
Install Symfony with this line on the folder you choose (must be without files)
COMPOSER_MEMORY_LIMIT=-1 composer create-project symfony/website-skeleton . -s dev
I was using:
Virtualbox
4096 Gb RAM
2 CPU
10 GB HDD (500 MB swap)
Ubuntu 20.04
Running:
composer update in a laravel 8 project folder
I didn't set the swap for the virtual machine, so Virtualbox created a 500Mb swap space, which was NOT enough.
So composer was using 4Gb of RAM plus swap.
I gave more swap space to the VM and then it worked.
As the picture below, composer used all my RAM + 2GB of swap
System Monitor
You can try setting preferred-install to "dist" in Composer config.
I was getting this error in a local Docker environment. I solved it by simply restarting Docker.

Categories