'Message: Set sys_temp_dir in your php.ini after installed composer
I've tried to install composer for my CodeIgniter project.
The installation was successful. But, when I type on command-line composer --version
, it shows:
PHP temp directory (C:\Users\petik\AppData\Local\Temp) does not exist or is not writable to Composer. Set sys_temp_dir in your php.ini
Composer version 1.4.2 2017-05-17 08:17:52
Can anyone help?
Solution 1:[1]
Change TEMP folder in php.ini. look for entry sys_temp_dir
in your php.ini file and change the tmp location and set correct permissions.
Solution 2:[2]
Or if you use Windows you have to run your command line like an administrator "Run as administrator"
Solution 3:[3]
I have same error on an debian where /tmp partition was full. Purge rm -rf /tmp/*
, and message gone. May this help.
Solution 4:[4]
For this error, If you don't have permission to edit php.ini file. My temporary solution is:
php -d open_base_dir="." -d sys_temp_dir="." /usr/local/bin/composer -v
You can run all your composer commands like this:
php -d open_base_dir="." -d sys_temp_dir="." /usr/local/bin/composer install
php -d open_base_dir="." -d sys_temp_dir="." /usr/local/bin/composer update
You can also use this command in other operations e.g.: In magento2 for phpcbf:
php -d open_base_dir="." -d sys_temp_dir="." vendor/bin/phpcbf --standard=Magento2 magento2/app/code/example/StockReserve --report-file="StockReserveAutoFixed.txt"
php -d sets variable in command line.
Solution 5:[5]
In my case I got the solution by doing the following steps:
- Search view advance system settings then go to environment variables then in user variables edit TEMP and TMP both. And change them to C:\Users\Bappy\AppData\Local\Temp (here Bappy is User name)
- Then go to
xampp>php>php.ini
and findsys_temp_dir
and setsys_temp_dir = "/temp"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Dileep Kumar |
Solution 2 | norbertsari |
Solution 3 | Jean-Luc Barat |
Solution 4 | Prakash Lakhara |
Solution 5 | Undo |