Cannot reinstall Composer on WAMP server - windows

I have uninstalled Composer using the Windows uninstaller (I'm on Windows 8) and now when I run the Composer installer I get:
Composer is already installed in the following directory:
C:\wamp\bin\php\php5.5.12
You must remove it first, if you want to continue this installation.
Since obviously Windows did not completely remove it can anybody with more skills than me give me a tip on how to fix?

Remove the path C:\wamp\bin\php\php5.5.12 from your Environment variable, named Path in the System properties.

Related

Defaulting to user installation because normal site-packages is not writeable

When I pip install AnyPackage I receive output telling me that it is "Defaulting to user installation because normal site-packages is not writeable":
I have tried uninstalling Python, but it does not solve the problem.
I am using an admin account on windows-10 Home Edition, and running python-3.9, (downloaded directly from python.org), installed using the "add to path" option.
It is worth noting that I can't access any package from cmd, for instance:
P.S Why does it install the package in AppData\Roaming\Python\Python39\Scripts, when Python is installed to C:\Program Files\Python39?
As for my goal, I would like to avoid any future problems this might cause me.
I would also like to be able to create a virtual environment, using virtualenv.
For me not using my IDE with virtual environment solved the problem and to install all modules using administrator privileges.
Use bash to install packages instead of Powershell

Anaconda Installation Error

I am trying to reinstall anaconda 64 bit on Windows 10 to use Python 3.6 and the installations works right till the end but it fails executing the post install script with following error.
You have some missing files, try to uninstall and download it again. Don't try to pause the files, it might cause these kind of errors.
I got it running after installing in a different directory. Just make sure you don't install it in the default location provided. I made a new directory in C-Drive and installed anaconda in it. My install location is C:\Anaconda3. And it worked finally

How to use composer with WampServer?

I am trying to use composer with my WampServer.
My path for all the files is C:\wamp64\www, but when I run composer it will install the vendor file and other stuff somewhere else.
I don't even know where and I can't change the path of where is my project.
I tried everything already and it still dose not seem to install the vendor file in my project folder.
Although it is an old post, it maybe useful as far as Wampserver exists, so the easiest fix is this:
Go to the "bin/php" folder inside you wampserver, usually at C:\wampXX\bin\php, and look for the php version used in your wampserver. You can navigate to http://localhost to find that, or click in the Wampserver icon on Windows taskbar (If yours doesn't have the version number aside, click on PHP -> Version and you'll see the checked one):
In the "bin/php" folder open the corresponding folder to your PHP
version, in my case "7.0.33" and copy this path:
Go to Windows Environment Variables, and in System Variables add that PHP's folder path you copied to Path variable (You can search on Google how to change a Path variable on your Windows version).
P.S.: In case you switch PHP version it won't work anymore, and you'll have to do that again. But now, changing for the correct PHP version folder.
After doing that, go to composer site download the windows installer.
CD into your projects root directory and run (which must contain a composer.json file):
composer install
That's it. Maybe a lot of work, but at the end it's all quite simple.
I don't use this hack any more. I think there are better tools to solve this problem, such as Laragon, LocalWP (if you develop Wordpress plugins/themes) or Devilbox (you need to install Docker to use Devilbox).
I don't know if the poster will read and vote this answer. I had this problem and solved it, and I want to share my research with other people.
TL; DR
In Windows 10, you can have Composer without producing an error in Wampserver if you install it on the Windows Subsystem for Linux (WSL) environment.
Install PHP on WSL
Then install Composer on WSL
The problem
In Windows, Composer requires to set the system variable PATH to work properly during the installation; it doesn't matter if it is installed globally using the Windows Installer or locally, following this procedure
However, inserting the executable PHP file location in PATH causes an error in Wampserver, the ERROR C:/wamp64 or PHP in path. You can see the error message if you left-click on the Wampserver icon in the notifications area of the task bar.
Although Wampserver may work as usual, it could eventually fail according to the answer to this question on the official Wampserver forum:
Wampserver does not create paths in PATH system environment variable.
Wampserver does not use PATH system environment variable.
Some content - paths to PHP or mysql versions - of the PATH system environment variable can create Wampserver malfunctions because PHP configuration files (php.ini) or MySQL (my.ini) are searched first in the paths indicated by the contents of the PATH environment variables before being searched in the Apache, PHP or MySQL folders.
That is why, with version 3.1.3, the content of the PATH environment variable is checked and you are notified if there is a problem.
If your Wamperserver installation suffers already of this error, then
follow the advice from the Wampserver forum,
back up the content of your www folder,
uninstall Wampserver,
reinstall Wampserver.
If you have Windows 10 and followed the previous steps, then you are ready to implement the solution I propose.
The solution
The only solution I found in my research was explained in this tutorial by Jeff Geerling. My answer follows this tutorial in a somewhat loose way.
My starting point
These were the settings of my PC when I began this procedure:
Windows 10 Home Edition 64-bit
WampServer Version 3.1.3 64bit, reinstalled and with no errors
Windows Subsystem for Linux (WSL) Ubuntu installed
Visual Studio Code as text editor, with WSL bash as default integrated terminal
Although Visual Studio with the WSL integrated terminal is not strictly necessary, I had it set because I intended to install and use Composer with it.
1 - Install PHP on WSL
To work correctly, Composer needs PHP but WSL does not come installed with it. So it is necessary to install PHP in this enviroment. According to this answer in AskUbuntu.com, the easiest way to install PHP on WSL is adding Ondřej Surý's PPA. In the Visual Studio Code WSL integrated terminal, type:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
Test that PHP was installed correctly typing php --version. If PHP was installed correctly, the terminal will return a message like:
PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
2 - Install Composer on WSL
There are two ways to do it:
The easier one: just type on the integrated terminal sudo apt-get install composer and that will be it.
The second one, and a better approach in my opinion: go to the Composer download page and get the installation code:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Warning: Do NOT copy/paste the code provided in this tutorial to install Composer. According to the Composer download page, the installation code
will change with every version of the installer.
The best practice here is to get the installation code directly from the download page.
I think this method is a better approach because, with the given code, it is possible to verify the SHA384 of the file and make sure it has not been tampered with.
If you installed Composer through the installation code from the developer website, in order to put that file into the global path on WSL, move the composer.phar file into the /user/bin/local folder with the bash command:
sudo mv composer.phar /user/bin/local/composer
If you installed Composer with the first command, this last step won't be necessary.
To check that the software was installed correctly, type composer on the integrated terminal. You should view a list of composer calling options and available commands.
Keep in mind that, to use Composer, you will need to type the commands in the WSL terminal.
Just run composer on your project folder.
Say your project path is on C:\wamp64\www\project0. So, just run composer install inside project0 folder. Composer will create vendor folder inside this project0 folder. This folder contain some folders of installed libraries.
Composer also generate a file composer.lock. This file contain information of installed libraries.
Then, when you want to use the libraries, please add this code inside your php file.
require_once "vendor/autoload.php";
This will call autoloader, so you don't need to use require_once anymore to load PHP Classess. Just call the Class using use keyword.
use Library0/Class0;
use Library1/Class1;
use Library2/Class2;
I used a different approach. I admit that it is dirty, and every time I switch PHP versions, I need to remember to update what I did, but well... it works :)
Go to C:\ProgramData\ComposerSetup\bin. There is a file there: composer.bat. This is executed every time you enter a composer install or a composer update command. Edit it with a notepad or any other text editor. You should see something like this:
#ECHO OFF
php "%~dp0composer.phar" %*
What we want to do is to give a direct path to php.exe, so let's comment out the current command and write our own:
#ECHO OFF
REM php "%~dp0composer.phar" %*
C:\wamp64\bin\php\php5.6.40\php.exe "%~dp0composer.phar" %*
Now everything works. But once you switch to another PHP version in Wampserver, you should update this file too.
By the way: a similar change can be done to make PHP sniffer or PHPUnit work too. Their bat files are in C:\Users\[your windows user]\AppData\Roaming\Composer\vendor\bin folder.
That answer is pretty bad. I have figured it out already on my own. I had to use cd commned in commend lines to get in this folder.
So after CMD i would type cd C:\wamp64\www\project0 thats proper answer to my problem.

Cannot install PEAR mail package XAMPP on Windows

From the cmd line:
C:\Users\Lemur>pear install --onlyreqdeps Mail
Did not download optional dependencies: pear/Net_SMTP, use --alldeps to download automatically
pear/Mail can optionally use package "pear/Net_SMTP" (version >= 1.4.1)
downloading Mail-1.3.0.tgz ...
Starting to download Mail-1.3.0.tgz (23,110 bytes)
........done: 23,110 bytes
ERROR: failed to mkdir C:\php\pear\tests\Mail\tests
I see a newly created Mail folder in xampp\php\pear\Mail, which is correct, but the folder has no contents.
Also, the Error shows that install is attempting to put something at C:\php\pear\tests\Mail\tests. There is no such directory C:\php\pear...
What is wrong? Include_path in php.ini is correct (C:\xampp\php\pear).
Thanks in advance.
Found the answer here: http://davehiren.blogspot.com/2011/04/how-to-install-or-uninstall-pear.html. I'm using XAMPP and didn't realize all the path variables that needed to be changed. Once I altered all the path variables, the Mail package installed just fine.
For working with PEAR using XAMPP in Windows, it's important to avoid the command line in Windows and instead use the XAMPP Shell. Simply open the XAMPP Control Panel and click on XAMPP Shell on the right:
In the XAMPP Shell, you can enter your PEAR package installation command as you normally would and the packages will get installed in their proper place within XAMPP's PHP directory:
pear install --onlyreqdeps Mail

NVM for Windows not working?

I just installed NVM for Windows, but it doesn't seem to be working:
Any ideas?
First examine your actual "C:\Program Files\nodejs" directory. Most of us already have a "nodejs" directory from a prior install, before we decided (or were told) to install nvm.
In the end, this "C:\Program Files\nodejs" directory will actually be a shortcut to where nvm manages the versions it installs (see C:\Users\xxx\AppData\Roaming\nvm). It seems that nvm is simply switching the shortcut, when we call "nvm use ...".
Ok, so here is what I did to fix the situation where "nvm use ..." was not taking effect.
Delete/remove/uninstall the version of node in your "C:\Program Files\nodejs" directory. To the point where there is no more "nodejs" directory at all.
Delete the existence of nvm (C:\Users\xxx\AppData\Roaming\nvm), basically, manually delete the nvm dir.
Download your desired version of nvm (https://github.com/coreybutler/nvm-windows/releases)
Open a CMD prompt (run as administrator), and install the downloaded version of nvm, nvm-setup.exe, from within this CMD command prompt.
From within the admin level command prompt, run "nvm install 7.2.1", or whatever node version you want to install. Probably you will be installing multiple versions, so repeat as needed.
Now do the usual "nvm use ...", "nvm list", etc...
I dont know if this is the best way, but it worked for me...
Having the same issue after installing latest node with nvm. node command was not recognized in console. Closing and opening command windows did not work. checked nvm arch to which the response is
C:\WINDOWS\system32> nvm arch
System Default: 64-bit.
Currently Configured: -bit.
Had to set the node again with arch setting
C:\WINDOWS\system32> nvm use 7.4.0 x64
Now using node v7.4.0 (64-bit)
C:\WINDOWS\system32> nvm arch
System Default: 64-bit.
Currently Configured: 64-bit.
C:\WINDOWS\system32> nvm list
* 7.4.0 (Currently using 64-bit executable)
4.5.0
C:\WINDOWS\system32> node -v
v7.4.0
Rename "C:\Program Files\nodejs" to "C:\Program Files\nodejsx"
nvm use x.x.x
This worked for me. Maybe it will work for you too.
Most likely what is happening is that the system %PATH% is being updated outside of the command prompt instance. Only opening a new command prompt will pick up these new external changes.
I had the same problem in Windows 10, and the solution for me was in #pleverett answer in https://github.com/coreybutler/nvm-windows/issues/191
Symptoms: no bit architecture and no default version
C:\WINDOWS\system32> nvm arch
System Default: 64-bit.
Currently Configured: -bit.
C:\WINDOWS\system32> nvm list
8.9.4
6.13.0
Solution:
After uninstalling node, make sure the directory where node was originally installed has been removed and not just empty. For Windows 7 ad 10, 64-bit, the default is "C:\Program Files\nodejs".
If the "nodejs" directory still exists then the "nvm use" command can't make the symbolic link to the node version under nvm's control.
I had the same problem until I manually deleted the "nodejs" directory.
Make sure you delete all old nodejs.
Install nvm
Install node
Open new terminal prompt
run 'nvm on'
run 'nvm list'
run 'node --version'
In my case I was using git bash -- switching to cmd.exe worked.
More suggestions at: https://github.com/coreybutler/nvm-windows/issues/58
I had to manually set the PATH variable in System environment variables of Windows to fix this issue.
Here are the steps:
Before installing nvm, delete the following path:
C:\Program Files\nodejs
C:\Program Files (x86)\nodejs
after installing nvm execute:
nvm use
After the use command you can find a shortcut 'C:\Program Files\nodejs' is created by
nvm in this path.
The problem i found was the path 'C:\Program Files\nodejs' was not set in the windows system evnironment PATH variable.
i appended 'C:\Program Files\nodejs' to the %PATH% variable to fix this issue.
I had to open the installer with admin permissions.
Then I opened the command line and I was able to install and use nvm properly.
nvm install 10.0.0
nvm use 10.0.0
node --version
// version 10 is used.
I installed nvm-windows in order to get multiple versions of node to work. After installation I got the error that most folks complained about which is that it was unable to find the file settings.txt. There are two things required to get nvm-win to work and the installer only does the first of these two. So after installation just check that points 1 and 2 are covered and you should be good. There is no need to uninstall prior versions of node as far as i can tell.
update the system path variable to the directory where you installed nvm and where the nvm.exe is located. ex. c:\nvm
add a new variable NVM_HOME to the system variables.
open a new command window after verifying 1 and 2.
Problem 2 switching between versions
Switching between versions gives a success message but it will not actually work properly unless you manually update the windows system path variable to point to the location that you installed your target version in, for example C:\Users\adamm>nvm list
10.15.1
* 6.4.0 (Currently using 64-bit executable)
So it appears to work but if you type node -v it will show whichever version is currently in your path variable until you edit the path variable to use 6.4.0
I was getting the same issue. I installed node using nvm but 'node' and 'npm' were not recognized by the system.
So, what I did was I didn't delete any folders or anything I just ran the command prompt as administrator and did the nvm install 'desired-version' and everything started to work fine.
I understand this is an old question.
However, what fixed it for me isn't in any of the answers above, which is why I decided to answer this in case new persons find this page and none of the above answer works for them...
All I had to do was run nvm on which creates the symlink (supposedly, nvm use <version> is supposed to work, but it wasn't), turning on nvm before using a version worked for me.
Steps:
nvm install <version> -> Installs a node and npm of <version>
nvm on -> Turns on nvm, and creates the nodejs symlink needed
nvm use <version> -> To use a specific version
node -v -> prints out version of node
npm -v -> prints out version of npm
Hopefully, it fixes your issue too.
For me,
nvm list
Then I remove v8.9.4 folder out of nvm.
After that:
nvm list
Then, I move v8.9.4 back.
For me it was I installed node using nvm on a non-admin cmd.
Running cmd as admin worked for me.
open a new cmd with admin rights then run this command.
run 'nvm on'
Why isn't node version changing with nvm for windows even when nvm on ?
when nodejs is already installed, the enviroment variable NVM_SYMLINK which created when nvm for windows is installed will point to C:\Program Files\nodejs(which is default)
what is the expected behavior ?
when we run nvm on and then nvm use x.x.x, we should able to switch to the desired node version without any hassle.
how to fix ?
uninstall the nodejs using uninstall/remove programs from control panel and delete C:\Program Files\nodejs if exists
check (once) if NVM_SYMLINK in environment variables is changing automatically when running nvm use x.x.x
if not changing automatically then uninstall and reinstall nvm for windows (remove any other node remains)
Note: I am able to switch to the desired versions of node by changing the user environment variable NVM_SYMLINKto C:\Users\Charlie\AppData\Roaming\nvm\vx.x.x without uninstalling the node.
At my work we are assigned a user account and an administrative account which we use to install and manage software for our machines. NVM was installed under this admin account and therefore, none of the answers above worked for me.
I had to manually add %NVM_HOME% and %NVM_SYMLINK% to my user account's path before I could get node --version to display anything.
So if you have to deal with a regular account and an administrative account then the following will work for you:
Install NVM (which will have to be installed using your admin account)
Manually added %NVM_HOME% and %NVM_SYMLINK% to your user account's path (if you check your admin account's path you'll see these 2 were added there during the NVM installation)
nvm install latest
nvm on
nvm use x.x.x
Restart computer so your IDE recognizes the changes
$Profit$
To me the issue was that I had problems with the download, I had to download the zip file manually and place its contents int he nvm folder C:\Users\xxx\AppData\Roaming\nvm
Try nvm run node --version
You can also get the path to the executable to where it was installed:
nvm which 5.0
Something that fixed it for me: Comb through your PATH variable. I had multiple links to different node versions and it worked perfectly after I cleaned up all of them, leaving NVM's variables in tact.
If executing where node comes back with more than one path this is likely your issue.
This work fine for me:
In the C:\Program Files\ folder use cmd to run mklink /D /J nodejs C:\Users\[user]\AppData\Roaming\nvm[node version]
Please note that cmd run in administrator mode.
Detail here: https://github.com/coreybutler/nvm-windows/issues/321#issuecomment-407876718
For me, the issue was that I was using the nosetup way and downloaded the zip in my user Downloads folder. When I switched to setup installer, it worked for me.
You need Administrator access for installing node. Since you got into problem before knowing solution, follow below step.
Note down all installed node version(Optional)
"C:\Program Files\nodejs" (Optional but Recommended)
Delete "C:\Users\xxx\AppData\Roaming\nvm"
Reinstall nvm
Run cmd as Administrator
nvm install x.x.x
I had same issue. C:\Program Files\nodejs shortcut folder was present but was not pointing to anywhere.
I simply deleted the C:\Program Files\nodejs symlink and executed the below command
nvm use 0.10.36
This created new C:\Program Files\nodejs symlink and it worked properly.
Aside to all other solutions described here, there is another issue with nvm. Nvm switches between version of Node.js. Node.js builds are grabbed from Node.js repository.
If you can switch between some versions, but not all, and specifically you can not switch to versions you just grabbed, that answer is for you.
The situation happens because Node.js rebuilds old builds. For example, there is a build 10.14.1 you can grab from their repository, and that nvm grabs. But it is not a build from the past. Node.js rebuilds old builds too regularly.
Unfortunately, they don't take care about backwards compatibility. It means that if your operating system is not supported by Node.js, not only the latest build won't be supported. All old builds will also be broken for your system.
Currently, Node.js supports Windows 10+. It means that all old Node.js packages has been rebuilt in a way, that break them for Windows 8.x and Windows 7.
What is astonishing, there is no place to grab the old, working builds. Once they rebuild old releases, they break backwards compatibility.
As for now, there is no solution for that. The only thing you can do, is to grab releases while they are supported on your system. For example now, you can grab versions for Windows 10, because when they announce Windows 11 is a minimum requirement, all Node.js builds will break on Windows 10.
From the nvm perspective, you can see any kind of errors during the installation. During switching the visible result is that you can not switch between versions. The version you choose is not the current one and not marked with an asterix in the npm list result.
For me there were 2 things I needed to do:
Run nvm install as administrator
Specify the exact version (major.minor.point) with nvm use
Steps:
Open Terminal as Administrator
Run nvm install 14
Run nvm use 14.20.0
Open Terminal as non-admin
Run node -v to verify it's using 14.20.0
If I tried nvm use 14 without minor or point version, it did not work, which differs from NVM on Mac. I also could not run nvm use in a non-admin terminal, it gave "Access is denied".
For me deleting npm and npm-cache folder from AppData works
For me running nvm install 14.0.0 from PowerShell with admin rights did the job.
You must delete your C:\Program Files\nodejs directory.
Check the version of the node available with nvm list.
If you have your version, run command nvm use x.x.x.
otherwise run nvm install x.x.x and run command nvm use x.x.x.
For me setting up environment path variable also didn't work. Finally I got the cause and it was incompatible node version, once I downgraded my node from 14 to version used in my frontend application i.e. v8.11.3, it worked for me.

Resources