Getting a warning when trying to install composer on mac - macos

I tried today to install the composer on my mac from terminal. I used this command to download and install the composer inside my users folder
curl -sS https://getcomposer.org/installer | php
but when I press the enter I've got the following warning.
All settings correct for using Composer PHP Warning:
file_put_contents(/Users/test/.composer/keys.dev.pub): failed to open
stream: Permission denied in - on line 468
Warning: file_put_contents(/Users/test/.composer/keys.dev.pub): failed
to open stream: Permission denied in - on line 468 PHP Warning:
file_put_contents(/Users/test/.composer/keys.tags.pub): failed to open
stream: Permission denied in - on line 485
Warning: file_put_contents(/Users/test/.composer/keys.tags.pub): failed
to open stream: Permission denied in - on line 485 Downloading
1.2.0...
Composer successfully installed to: /Users/test/composer.phar Use it:
php composer.phar
Because the warning has to do with permissions I deleted the composer.phar that has been created and I executed again the same command using composer, but still getting the same warning. How I can fix this warning?
UPDATE
I did
curl -sS https://getcomposer.org/installer | sudo php
and it worked, but I want to know why. Thanks

Related

file_put_contents(./composer.lock): failed to open stream: Permission denied Even after running chown command

I am getting this error while installing Laravel latest version on ubuntu 18.04
[ErrorException]
file_put_contents(./composer.lock): failed to open stream: Permission denied
I have even run the following command as suggested by someone in response to the same question
sudo chown -R myuser ~/.composer
Still same error any ideas?
My error was exactly like below after this command: composer update.
[ErrorException]
file_put_contents(./composer.lock): failed to open stream: Permission denied
Solved it only adding sudo command in ubuntu. Full command will be:
sudo composer update
How do you run your php? If it starts when you visit page in browser, then user is www-data and of course there are no permissions.
I think you should try change group of this file:
sudo chgrp www-data ./composer.lock
But I am wondering why do you write into composer lock file? Are you ok?

Laravel installer error message 'failed to open stream: permission denied'

I keep receiving an error when trying to install Laravel.
I already run cmd as administrator and tried fixing this by un-ticking the folder attributes in properties which says
"Read-Only (Only applies to files in folder)"
with the hope that the permission is now accessible by Composer. The problem occurs when I run this command line:
composer global require laravel/installer
I still get this error message:
[ErrorException]
file_put_contents(C:\Users\fikri\AppData\Roaming\Composer): failed to
open stream: Permission denied
if you are windos user, open cmd or git bash with administrator privilege
if you are linux user install with super user privilege
sudo composer global require laravel/installer

Error during composer create-project laravel/laravel myproject on Debian

I'm on Debian and my PHP version is 7.0.27.
First I began installing Composer using curl -sS https://getcomposer.org/installer | php and then sudo mv composer.phar /usr/local/composer (sudo because that's outside of my home directory). Then I typed composer and it executed correctly.
Then I launched my XAMPP Apache server and I went to the /opt/lampp/htdocs folder. There I typed the command sudo composer create-project laravel/laravel myproject (again, sudo because that's outside of my home directory, but it throwed an alert : "Do not run Composer as root/super user! See https://getcomposer.org/root for details").
But then I got this error :
Your requirements could not be resolved to an installable set of packages.
and it printed a bunch of problems.
What did I do wrong?
Thank you for your help.
EDIT1: I must specify that the myproject folder was created nonetheless, but when I got to http://localhost/myproject/public it printed a PHP error :
Warning: require(/opt/lampp/htdocs/myproject/public/../vendor/autoload.php): failed to open stream: Aucun fichier ou dossier de ce type in /opt/lampp/htdocs/myproject/public/index.php on line 24
Fatal error: require(): Failed opening required '/opt/lampp/htdocs/myproject/public/../vendor/autoload.php' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/myproject/public/index.php on line 24
Laravel provides a list of what php extensions it requires for each version.
https://laravel.com/docs/5.6#server-requirements
Those are for the last version.
According to your error you are missing php-mbstring

Laravel Failed to open stream warning in Ubuntu 14

I am new in Ubuntu and try to migrate a laravel app to ubuntu.
Please take a look at below steps done.
1.Copied my laravel project and upload database.
2.Started my Xampp server and pointed my laravel app in browser, it showing error like.
Warning: require(/opt/lampp/htdocs/timegear/bootstrap/../vendor/autoload.php): failed to open stream: Permission denied in /opt/lampp/htdocs/timegear/bootstrap/autoload.php on line 17
Fatal error: require(): Failed opening required '/opt/lampp/htdocs/timegear/bootstrap/../vendor/autoload.php' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/timegear/bootstrap/autoload.php on line 17
When trying to update the composer with terminal throwing error like Mcrypt extension is required.
Please give me a solution for it.
Thanks and Regards.
You are missing the Mcrypt extension, to install:
sudo apt-get install php5-mcrypt
Then:
sudo updatedb && locate mcrypt.ini
Should show it located at /etc/php5/mods-available
locate mcrypt.so
Then edit mcrypt.ini with
chang thextension=mcrypt.so to extension=/usr/lib/php5/20121212/mcrypt.so (or whatever is the location of your mcrypt.so.
Next, create the symbol links
ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/cli/conf.d/20-mcrypt.ini
ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/apache2/conf.d/20-mcrypt.ini
and finally, restart apache
service apache2 restart
Hope this helps.
Install the mcrypt PHP extension.

Error installing composer on Yosemite

Running curl -sS https://getcomposer.org/installer | php gives me the following error:
#!/usr/bin/env php
All settings correct for using Composer
Downloading...
Could not create file /private/etc/apache2/users/composer.phar: fopen(/private/etc/apache2/users/composer.phar): failed to open stream: Permission denied
Download failed: fopen(/private/etc/apache2/users/composer.phar): failed to open stream: Permission denied
fwrite() expects parameter 1 to be resource, boolean given
Downloading...
Could not create file /private/etc/apache2/users/composer.phar: fopen(/private/etc/apache2/users/composer.phar): failed to open stream: Permission denied
Download failed: fopen(/private/etc/apache2/users/composer.phar): failed to open stream: Permission denied
fwrite() expects parameter 1 to be resource, boolean given
Downloading...
Could not create file /private/etc/apache2/users/composer.phar: fopen(/private/etc/apache2/users/composer.phar): failed to open stream: Permission denied
Download failed: fopen(/private/etc/apache2/users/composer.phar): failed to open stream: Permission denied
fwrite() expects parameter 1 to be resource, boolean given
The download failed repeatedly, aborting.
Not sure what permissions need to be changed to get this to work. I'm new to Mac OS. I've tried running the same command using sudo but to no avail. Any ideas on what needs to be changed in the apache2 directory to get this to work?
A simple chmod 777 on the users folder fixed the issue. Damn I feel like an idiot sometimes.

Resources