Symfony2 Assetic: Path to node executable could not be resolved - symfony

When running app/console assetic:dump, I am getting:
Path to node executable could not be resolved
What does it mean and how to fix this?
When trying to browse project via app_dev.php, I am getting an HTTP 500 errors when browser tries to download css and js files.

First make sure you have node installed and find the path to node. You can usually find this by using which node which will return something like /usr/local/bin/node. If it returns something like /usr/bin/which: no node in ... you need to install node.
Next configure symfony. Open your config.yml (./app/config/config.yml) and the path to node to you assetic config, i.e.:
# app/config/config.yml
assetic:
node: /usr/local/bin/node

This worked for me
sudo apt-get remove nodejs
sudo apt-get remove npm
sudo curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install nodejs

I add the exact same error while doing
php app/console assetic:dump --env=prod
On Ubuntu there is a confusion between node and nodejs binary.
To solve this you need to install node binary.
In my case the binary was nodejs, so it didn't work.
On Ubuntu the command which node will tell you if node is instaled.
Try which node and if it doesn't work try which nodejs.
So to be sure there is no confusion I did :
sudo apt-get remove nodejs
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
Check on node website for the correct url in the curl command. You might want node 5.X.
Now when you do
which node
/usr/bin/node
You have the correct binary name (node instead of nodejs).
After this it should work. If not check the node path in config.yml (check that there is no other declaration in config_prod and config_dev )

I've found that even if you specify /usr/bin/node in your config.yml you might still find assetic is trying to use /usr/local/bin/node.
The quick and dirty way to fix this is:
ln -sf /usr/bin/node /usr/local/bin/node
If you are in doubt, temporarily edit vendor/kriswallsmith/assetic/src/Assetic/Filter/UglifyJs2Filter.php
Edit near line 136:
if (127 === $code) {
throw new \RuntimeException('Path to node executable could not be resolved.');
}
->
if (127 === $code) {
throw new \RuntimeException('Path to node executable could not be resolved.' . $this->nodeBin);
}
This will tell you where assetic expects node to be next time assetic fails.
I found in my set up assetic was configured to look to /usr/local/bin in dev mode but /usr/bin in prod mode.
So it's worth checking config.yml, config_dev.yml and config_prod.yml.

Are you using some filters like uglify ?
If this is the case, Assetic raises this error because the process exists with code 127, which means the node executable was unable to run.
Check the path in your config.yml :
# app/config/config.yml
assetic:
filters:
uglifyjs2:
bin: /path/to/uglifyjs
And make sure it is executable :
chmod +x /path/to/uglifyjs

Just make a composer update (php composer.phar update) then try dumping your assets.
It may not work the first time, so update composer again.

Related

.composer is full ? No space left on device

When I deploy my project with capistrano (for Symfony), I have this error :
INFO [72050b7f] Running /usr/bin/env composer install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader as dome#XX.XXX.XXX.XXX
DEBUG [72050b7f] Command: cd /var/www/dev/Dome/releases/20160812073355 && ( export SYMFONY_ENV="prod" ; /usr/bin/env composer install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader )
DEBUG [72050b7f] The disk hosting /var/www/.composer is full, this may be the cause of the following exception
DEBUG [72050b7f]
DEBUG [72050b7f]
[ErrorException]
ZipArchive::extractTo(): No space left on device
Can you help me ?
Just clear cache of composer use composer clear-cache
Reference
Use df -h to check all partitions (make sure to check the relevant partition, there can be multiple) and free space if possible.
Alternative options;
You can try changing the Composer home directory to another partition/location using the environment variable COMPOSER_HOME=/new/path.
You can disable the cache directory by using COMPOSER_CACHE_DIR=/dev/null.
The disk hosting /var/www/.composer is full.
The message is quite expressive, you have run out of ROM memory on your disk / partition, and can no longer download even source-code packages with composer.
I suggest you to either change of disk, or if it is a virtual partition, to improve the memory-size.
This does not seem to be related with either Capistrano, Symfony, Composer or PHP.
You have no permission to run the commands, if it works with sudo you did your deploy with root privilegies in the first place.

Symfony2 Travis CI Cannot open file "/home/travis/build/myname/myproject/app/bootstrap.php.cache"

I'm new to symfony2 and travis ci, so if this is a stupid question, I apologies in advance.
When I try to push a symfony2 project to travis I get the following failed message for my build: Cannot open file "/home/travis/build/myname/myproject/app/bootstrap.php.cache"
My .travis.yml file looks like this:
language: php
php:
- 5.5
- 5.6
before_script: phpenv config-add myconfig.ini
- cp app/config/parameters.yml.dist app/config/parameters.yml
- composer install
script:
- phpunit -c app/
notifications:
email:
- myemail#me.com
This error seems to get run after phpunit is called. So it seems like the build is okay, it's just that phpunit if failing on the above.
I tried adding chmod 777 app/bootstrap.php.cache just below my composer install instruction in .travis.yml, but that didn't seem to make any difference.
I guess it's a permissions issue, but not totally sure?
Thanks in advance.
Edit:
Actually, I'm not too sure if travis is creating the app/bootstrap.php.cache file. As I understand it, this should get done by the symfony bundle when composer install is run. But think this may be the root of the problem.
Try
1. sudo rm -rf app/cache/*
2. sudo chmod -R 777 app/cache/
3. sudo chmod -R 777 app/logs/
4. app/console cache:clear
5. sudo chomd -R 777 app/cache/
if it's doesn't help, tell me to know
If your bootstrap.php.cache is missing, just run
php vendor/sensio/distribution-bundle/Resources/bin/build_bootstrap.php
Sometimes the problem is that the file is missing, and it's not a matter of permission.

How to install Symfony 2.6 on Openshift?

I have tried the following guide to install symfony2 on Openshift.
But It does not work. After I visit the /url/app_dev.php, I have got a blank page (yes I removed the IP checking) with 500 error code.
I have no idea what is the problem. I did this tutorial 3 times, and still does not work. However it seems the composer installation does not work too, because I've got this message after a git push:
Could not open input file:
/var/lib/openshift/54a6c9f15973cac60f0000bd/app-root/data//composer.phar
Perhaps its a permission problem? Try chmod a+x on this file.
what you can do it via SSH log yourself into remote server using the rhc ssh command. Then got to app-deployment -> current -> repo -> php and within this directory run
"curl -sS https://getcomposer.org/installer | php"
this is how you have composer.phar within your installed app

Error "could not delete" with Composer on Vagrant

I have a Vagrant running Linux and I'm trying to install Symfony.
After the command composer create-project symfony/framework-standard-edition ./ "2.5.*" I have the error :
[RuntimeException]
Could not delete ./.git/objects/pack/tmp_idx_llwUKb:
If I try to composer update another project, I always have this kind of error Could not delete
Any ideas?
Edit: For a simple sudo composer update -vvv on another project:
- Installing sonata-project/admin-bundle (dev-master 8a022aa)
Failed to download sonata-project/admin-bundle from source: Could not delete /vagrant/crm_neo/vendor/sonata-project/admin-bundle/.git/objects/pack/tmp_idx_hchQhc:
Now trying to download from dist
- Installing sonata-project/admin-bundle (dev-master 8a022aa)
Failed: [RuntimeException] Could not delete /vagrant/crm_neo/vendor/sonata-project/admin-bundle/.git/objects/pack/tmp_idx_hchQhc:
[RuntimeException]
Could not delete /vagrant/crm_neo/vendor/sonata-project/admin-bundle/.git/o
bjects/pack/tmp_idx_hchQhc:
Exception trace:
() at phar:///usr/local/bin/composer/src/Composer/Util/Filesystem.php:193
Composer\Util\Filesystem->unlink() at phar:///usr/local/bin/composer/src/Composer/Util/Filesystem.php:151
Composer\Util\Filesystem->removeDirectoryPhp() at phar:///usr/local/bin/composer/src/Composer/Util/Filesystem.php:129
Composer\Util\Filesystem->removeDirectory() at phar:///usr/local/bin/composer/src/Composer/Util/Filesystem.php:35
Composer\Util\Filesystem->remove() at phar:///usr/local/bin/composer/src/Composer/Util/Filesystem.php:80
Composer\Util\Filesystem->emptyDirectory() at phar:///usr/local/bin/composer/src/Composer/Downloader/FileDownloader.php:108
Composer\Downloader\FileDownloader->doDownload() at phar:///usr/local/bin/composer/src/Composer/Downloader/FileDownloader.php:89
Composer\Downloader\FileDownloader->download() at phar:///usr/local/bin/composer/src/Composer/Downloader/ArchiveDownloader.php:35
Composer\Downloader\ArchiveDownloader->download() at phar:///usr/local/bin/composer/src/Composer/Downloader/DownloadManager.php:201
Composer\Downloader\DownloadManager->download() at phar:///usr/local/bin/composer/src/Composer/Installer/LibraryInstaller.php:156
Composer\Installer\LibraryInstaller->installCode() at phar:///usr/local/bin/composer/src/Composer/Installer/LibraryInstaller.php:87
Composer\Installer\LibraryInstaller->install() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:152
Composer\Installer\InstallationManager->install() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:139
Composer\Installer\InstallationManager->execute() at phar:///usr/local/bin/composer/src/Composer/Installer.php:548
Composer\Installer->doInstall() at phar:///usr/local/bin/composer/src/Composer/Installer.php:217
Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/UpdateCommand.php:128
Composer\Command\UpdateCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:252
Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:889
Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:193
Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:135
Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:124
Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:84
Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:43
require() at /usr/local/bin/composer:15
It happened once to me and it turns out that I was hitting composer's timeout.
You could take the following measures to gain some speed:
Increase composer process-timeout (default 300) (not really needed if the following settings will help you gain speed, but can't hurt)
Set dist as preferred install type.
Enable https protocol for github, which is faster.
~/.composer/config.json
{
"config": {
"process-timeout": 600,
"preferred-install": "dist",
"github-protocols": ["https"]
}
}
If you still have problems after that, you can also clear composer's cache:
rm -rf ~/.composer/cache
I was trying to update project dependencies (using composer update) during a Laravel Framework upgrade exercise in my local Homestead environment (having run vagrant ssh to login as the default "vagrant" user) and none of the previous answers in this thread made any difference to the...
Could not delete /home/vagrant/projects/projectname/vendor/kylekatarnls/update-helper/src/UpdateHelper
...error message I repeatedly encountered.
The only thing that worked for me was to include a composer option as follows:
composer update --no-plugins
Plugins are used to alter or extend the functionality of Composer. The above command disables all installed plugins. Unfortunately, I'm not clear as to why this command worked for me, as I certainly haven't written any plugins myself. All I can conclude is that there was an erroneous Composer plugin installed that was causing this issue.
TL;DR Switch to Docker. It is the industry standard.
I came across this issue and spent quite some time doing research. I've tried every possible option to fix it but none of them worked for me. For me, the bug occurred on GNU/Linux host with Vagrant and VirtualBox provider.
It turns out it's a VirtualBox bug related to the file system layer and race conditions when creating/deleting files. It occurs only for VirtualBox shared folders, not for regular ones. The sad part is that it seems like it's not going to be fixed any time soon.
Some guys reported that they were able to solve the problem using the following tricks:
Downgrading to VirtualBox version 6.0.4.
Using nfs or rsync instead of shared folders.
Patching composer to add some pauses after certain operations.
Disabling plugin usage with --no-plugins option.
But all of this seemed dirty to me. I personally was able to use a workaround suggested on GitHub which is to configure composer to install packages from sources. That's a simple and kind of clean trick which should not have significant negative side effects on your workflow. Try putting the following config into your ~/.config/composer/config.json. Or instead you can edit your composer.json accordingly depending on your needs. Keep in mind that composer.json will override your global config.
{
"config": {
"preferred-install": "source"
}
}
Just got the same issue.
I see the problem in accessing to some local files. In my case target directory was under "root" and I'm not the root user.
Solution
Change permissions/owner of your files/directory.
Redefine owner:
sudo chown myuser:myuser -R /path/to
Maybe there is some lack of permissions for group which you are in.
So, try to run:
sudo chmod g+rwX -R /path/to
Or maybe you may run your command with "sudo" if it works for you (not recommended). :)
P.S. Never use 777. It's not secure.
UPD1
Another thing, you may found out useful to solve the root of the cause, to wrap up your composer binary to run it always behalf a certain user.
$ cat /usr/local/bin/composer
#!/bin/bash
# run composer behalf www-data user
set -o pipefail
set -o errexit
set -o nounset
#set -o xtrace
[[ "${DEBUG:-}" = "true" ]] && set -o xtrace || true
composer_debug=$([[ 'true' != "${COMPOSER_DEBUG:-}" ]] || echo '-vvv' )
sudo -u www-data -- /usr/bin/composer ${composer_debug:-} $#
I had this problem when provisioning the machine, which was bootstrapped to run composer install. I simply exited the VM and ran composer install on the code on my host machine and it worked.
So, if you're facing this problem while running Composer inside the VM, just try running Composer from outside the VM.
Update: As pointed in the comments below, this can pose some problems with different versions of packages being installed owing to the difference in system configurations between the local and Vagrant environments, so exercise appropriate caution while trying this.
We're running into issues also. There are several people who seem to have this issue, a fix has not been provided. For more information you can look into github issues of vagrant-winnfsd.
for my case, I only used the NFS folders type instead of the shared folders and it works:
folders:
- map: ~/code/cs-cart-trial
to: /home/code/cs-cart-trial
type: "nfs"
Just run
sudo chmod -R 777 /folder/path
This will give you write access to the folder you are running composer in.
I know this is an old post but this works so I have to share it.
In my case I was trying composer update but I got
[RuntimeException]
Could not delete .../vendor/bin/php-parse:
Despite I'm using Laravel framework, this question was the first link in Google, so I decided to post an answer.
My solution was to grant ownership for vendor: sudo chown -R $USER:www-data vendor/ and
sudo chown -R $USER:www-data composer.json
Update: my host OS was Ubuntu 16.04.
Having the same issue for Cakephp 4.2.1
Error:
Could not delete /var/www/vendor/cakephp/plugin-installer/src:
Solution:
Based of https://stackoverflow.com/a/63139337/1110760
After trying out several options mentioned above, for me this was the easiest way to solve it.
composer install --prefer-source
The argument --no-plugins worked as well, sort of. It skipped some packages but my localhost seemed to work just fine. This is faster, but it's missing some.
On AWS I got this error while deploying Yii framework project there was this
/var/app/current/vendor/
folder i deleted everything inside it came back to my document root and ran composer update it fetched all the repos again.
In my case , by removing the plugin and re-create the box solve the issue.
For me it caused by composer's timeout. I checked my internet speed and found it dropped to 0.7M which is nearly unusable. After I reconnected the wifi and have my internet connection speed back to normal, the errors are gone.
This has something do to with the synchronization of the folders between host and guest OSes, the folder might be simply temporarily locked from your host machine.
The solution is simply to delete the offending .git folder from your host OS or reboot the machine and launch composer install again.
Ideally each OS has its own dependencies and different binaries, therefore you should isolate your /vendor folder out from the rsync/vagrant folder share, likewise you would do the same with /node_modules on a Nodejs project.
Another thing to check for, Composer needs to run in the context of a directory it has permissions to.
In my case I was trying to issue a create-project command from /var/www, aimed against /var/www/html. /var/www is owned by root, /var/www/html is owned by the same user I executed Composer as (www-data). I got the following error; Could not delete /var/www/html/:
Issued the same Composer command from within /var/www/html itself and it worked perfectly.
To me it helped to install a (new) version via command line from download homepage https://getcomposer.org/download/. I can exclude some file permissions as I was root with chmod +R 0777, though I had virtualbox mounted drive. Anyway since new version worked, would mean it was version, or running a new version via php phar, and the original bin belonged to root
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
I have solved the problem by creating a mount :
In /home/vagrant create a folder named vendor
then apply command : mount --bind /home/vagrant/vendor /path/to/source/vendor
It's a bit unrelated with the question, but in my case with Docker. It was failing because Webpack was watching and it didn't allow other files to be deleted.
It worked when I turned off Webpack.
I had same problems trying composer install
- Installing aws/aws-sdk-php (3.218.3): Extracting archive
Install of aws/aws-sdk-php failed
In Filesystem.php line 330:
Could not delete /home/vagrant/code/my-project/vendor/composer/cefa44c2/aws-aws-sdk-php-a1bd217/src:
What I did I comment it out
type: "nfs"
from my homestead.yaml
and make a fresh vagrant provision
I'm using Oracle Virtual box 6.1 on Windows 10.
Turn of Dropbox or other file sync
Best hack i found was to replace the unlink commands with the one below. I am running ubuntu.
sudo nano +219 /usr/share/php/Composer/Util/Filesystem.php
exec("sudo rm -rf $path");
return true;
For Windows users
Wow, I can't believe how long it took me to realize this, and sadly it has happened multiple times, and I'm finally writing this note so that I and others can quickly recover next time.
Just use Windows Explorer to go delete the /vendor/whatever_project_name folder instead of trying to delete it from the Vagrant command line.
Then run composer update to reinstall the dependencies.

Composer - uncommited changes (symfony 2.1)

I am using symfony 2.1 with composer and I'm trying to run composer update
However, I keep getting "has uncommitted changes", I don't remember changing any of the files in the vendors dir and it comes up with almost every package!
I tried composer install to revert any changes, but it doesn’t seem to have an effect. If I delete the lock file and try an install, I get error messages like "symfony 2.1 requires symfony 2.1 -> symfony 2.1 satisfiable". It just doesn’t make sense.
If I delete the contents in vendors I get the same error messages and nothing installs.
Nothing I do seems to work. Is there a way to update with "force" regardless of "uncommitted changes"
You can use composer status -v. Here's how you can detect a file change in vendor/ using this command, and how to fix it.
First, we verify that no package is modified:
➜ SymfonyApp git:(master) ✗ composer status
No local changes
Then, we change a vendor file
➜ SymfonyApp git:(master) ✗ echo "modification" >> vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php
We then ask composer to tell us about modified vendor files (note the -v option, to see the modified files)
➜ SymfonyApp git:(master) ✗ composer status -v
You have changes in the following dependencies:
/Users/adrienbrault/Developer/SymfonyApp/vendor/symfony/symfony:
M src/Symfony/Component/HttpKernel/Kernel.php
We then reset the vendor git repository to set the files back to their original state.
➜ SymfonyApp git:(master) ✗ cd /Users/adrienbrault/Developer/SymfonyApp/vendor/symfony/symfony
➜ symfony git checkout .
➜ symfony cd -
~/Developer/SymfonyApp
Finally, we check that the files are not seen as modified anymore by composer.
➜ SymfonyApp git:(master) ✗ composer status -v
No local changes
Update: composer should now help you to handle this
You can also set the discard-changes to true in the config parameter of your composer.json file, see https://getcomposer.org/doc/06-config.md#discard-changes.
{
"name": "test",
"description": "Demonstrating concepts",
...
"config": {
"process-timeout": 1800,
"discard-changes" : true
},
...
}
Because this affected various projects sharing dependencies on one server, since for example a vender author would ask me to test quick changes before filing bugs and committing to their repo, I ran this to globally set discard-changes to true:
php composer.phar config -g discard-changes 1

Resources