Symfony cannot install new bundles because of composer permission issue - composer-php

While try to install new bundles into my project composer issue happens which is regarding permission, issue follows
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile handling the symfony-scripts event terminated with an exception
Installation failed, reverting ./composer.json to its original content.
[Symfony\Component\Filesystem\Exception\IOException]
Failed to copy "/var/www/html/myProject/vendor/sensio/distribution-bundle/Composer/../Resources/skeleton/app/check.php" to "bin/symfony_requirements" because target file could not be opened for writing.
Thank you...

this might help you:
sudo chmod -R 777 bin/symfony_requirements
check if other directory and files need permission, for example in my case:
sudo chown -R $USER web/
was also needed.
furthermore if you had problem with cache and logs you may find following useful:
rm -rf var/logs
rm -rf var/cache
rm -rf vendor
and then using composer install

You have wrong permissions on file bin/symfony_requirements. Fix it and all will work like a charm

Related

Laravel 8 is not working correctly, error "file_put_contents"

I'm having some weird problem with Laravel 8.
I installed the framework and started working with it, but when I try to edit / delete some controller, my Ubuntu asks for a password.
Another problem. My controller displays records on a page with paginate(15) pagination, but instead of the usual numbers, I get the Previous & Next direction, and when I try to change something in the html template, I get an error file_put_contents(/var/www/storage/framework/views/c6d615eb91fe3a0edd449165e94d034703bbb84d.php): failed to open stream: Permission denied and this problem can only be cured by clearing the cache, but this should not be the case.
Error #1: Your user does not have write permissions for those files/directories. Did you use sudo while installing or copying anything? Do you have these files outside of your home directory? (/home/username/)
Error #2: Your webserver (nginx, apache, etc.) probably does not have access to the application's /storage/ directory.
SSH into the server.
Navigate to the projects root folder.
Run the following commands to make the directories writable:
sudo chmod -R gu+w storage/
sudo chmod -R guo+w storage/
sudo chmod -R gu+w bootstrap/cache/
sudo chmod -R guo+w bootstrap/cache/

How Can I Solve Permission Denied in React Native Project?

anyone faced this issue after a run
react-native run-android/ios
android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java
(Permission denied)
when i write sudo before any command like npm install/yarn add etc it's work very well
otherways i got errors related to Permission
You might check the permissions on android/gradlew
They should be 755 not 644
Run chmod 755 android/gradlew inside your app root folder
then run react-native run-android
And it should work again
Finally remove the node modules and re-install using rm -rf node_modules && npm install
It looks like you have no permission- try this
sudo chmod -R 777 {path}
deleting node_modules folder from project and then running command npm i worked for me in existing react-native project

Laravel 5 - ErrorException failed to open stream: Permission denied

I've just git clone a repository of mine containing a Laravel 5.1 project. I've gone through the normal steps to get it up and running (setup the webserver, db, etc). I've now gone to the web address I configured and i'm getting the following error message:
ErrorException in compiled.php line 6648:
file_put_contents(/3c7922efc24ab13620cd0f35b1fdaa61): failed to open stream: Permission denied
Any idea's what folder it's trying to access?
I solved the problem with this solution, clarifying that if you have Windows, you apply lines 1 and 3 and it works the same.
php artisan cache:clear
chmod -R 777 storage/
composer dump-autoload
To solve this problem I needed to create a few folder's that were missing from my install. You require the following folders to be readable and writable by your www user:
/storage
/storage/cache
/storage/framework
/storage/framework/sessions
/storage/framework/views
/storage/framework/cache
/storage/logs
Also, set the folder permissions to 775. From the root directory run the command: sudo chmod -R 755 storage
If nothing help you and if you work on windows with docker it can be the issue that wrong symlink you have, you can try:
ln -s /var/www/storage/app/public /var/www/public/storage
And after that:
chown -R $USER:www-data storage
chmod -R 777 storage
on docker bash.
If you're using ubuntu, most likely you have to give permissions to that folder storage
cd into the project and
use the command -> sudo chmod 755 storage/*
I had similar problem in my localhost and the problem was that I was trying to upload a file larger than upload_max_filesize in my php.ini file .
just updating this to greater value and restart my server solved the problem ,, if you having similar problem this might be the case
If you are on a Linux distribution with SELinux enabled, here is what you need to do:
sudo chcon -R -t httpd_sys_rw_content_t /var/www/html/my-app/storage
sudo chown -R nginx /var/www/html/my-app/storage
sudo chmod -R u+w /var/www/html/my-app/storage
This should set the proper context for the storage directory, allowing the web server to write to it.
I had this problem lately with my tests, and resolved it through: composer dump-autoload
This is how I solve a similar issue since I don't have access to the terminal to run sudo chown -R www-data:www-data /thedirectory
in
config/filesystem.php
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
Then in my uploader controller
use Illuminate\Support\Facades\Storage;
$file_path= Storage::path('public/importable');
if (!is_dir($file_path)) {mkdir( $file_path,0775, true);}
This is a permission issue. I used few hours to resolve this problem. I found only 3 lines to give permissions. So first go to root folder f your Laravel application and run these 3 lines.
php artisan cache:clear
chmod -R 777 storage/
composer dump-autoload
For me it was because the single file was owned by root...written at some point when I setup the files, and the app couldn't read it. Solution could be to change ownership, get rid of it, etc.
For me solution was to change folder owner of laravel project. Ensure that is your own user and not root:www-data.
sudo chown -R username:group directory
Run the following command in the directory that is being triggered to check the permissions:
ls -lah
Then if there was any issue you can correct it with:
sudo chown -R username:group directory

How to properly duplicate a working Laravel 4 project

I have the latest Laravel 4 beta 5 build from Laravel's github repo.
I have built a simple web API and it is working fine. I wanted to duplicate the project to another folder and continue working on it from the copy. However, when I try that, I get the following error message:
InvalidArgumentException
Driver [native] not supported.
/Users/tolga/Sites/l4api-copy/bootstrap/compiled.php
Line 10908: throw new \InvalidArgumentException("Driver [{$driver}] not supported.");
Here is what I did in order to copy the project:
[/Users/tolga/Sites] $ cp -R l4api l4api-copy
[/Users/tolga/Sites] $ chmod -R 755 l4api-copy
It didn't work, so I've tried:
[/Users/tolga/Sites] $ chmod -R 777 l4api-copy/app/storage
Still no good, tried to run composer dump-autoload:
[/Users/tolga/Sites] $ cd l4api-copy
[/Users/tolga/Sites/l4api-copy] $ composer.phar dump-autoload
Generating autoload files
[/Users/tolga/Sites/l4api-copy] $
Same error. I have also tried to remove the app/storage folder and re-create it.
[/Users/tolga/Sites/l4api-copy] $ rm -Rf app/storage
[/Users/tolga/Sites/l4api-copy] $ mkdir app/storage
[/Users/tolga/Sites/l4api-copy] $ chmod -R 777 app/storage/
Here is a brand-new error:
ErrorException
Warning: file_put_contents(/Users/tolga/Sites/l4api-copy/bootstrap/../app/storage/meta/services.json):
failed to open stream: No such file or directory in
/Users/tolga/Sites/l4api-copy/bootstrap/compiled.php line 5507
Line 5507: return file_put_contents($path, $contents);
I have also run composer.phar dump-autoload command again, after emptying the app/storage folder.
And finally, I have also tried composer.phar install:
[/Users/tolga/Sites/l4api-copy] $ composer.phar install
Loading composer repositories with package information
Installing dependencies from lock file
Nothing to install or update
Generating autoload files
[/Users/tolga/Sites/l4api-copy] $
None of the above helped. What am I doing wrong? What is the proper way to duplicate a working project?
After a recent commit to the laravel/laravel repository a new session driver, native, has been introduced. From the looks of your errors you should update your application skeleton (the cloned develop branch of laravel/laravel), delete your bootstrap/compiled.php file and re-run composer update to pull in the latest framework changes.
In terms of copying the project you should copy over everything except the vendor directory then run composer install in the new location. You could copy the vendor directory but it's better to run a clean install and let composer dump a new autoload.
I've also seen Taylor mention a cleanup of your app/storage/sessions directory. Delete all the files in there.

Work with dir from www-user and from console in Mac OS x

I install Symfony and do:
chmod -R 777 app/cache app/log
Open from browser - all works great! When go to console and do:
php app/console cache:clear
and get error what i have not primission to delete file. Ok, i l'll do it with sudo:
sudo php app/console cache:clear
Great! But...
In browser i get:
RuntimeException: Failed to write cache file
Please
Probably you should do 2 things:
Make sure that you are running you web-server from the same user as you are.
Change owner or permission to the directory, in which your project is stored.
I'll explain point 2 little deeply.
Usually you create projects in /var/www folder. So, sudo chmod -R 755 /var/www would fix your issue.
P.S. Next time you should provide more details on your configuration setup. At least, some ls -l and pwd would help us to give you proper answer faster.
Cheers ;)

Resources