Describe the bug
It seems that because I already have NPM in the path of my Windows host (as WSL apparently copies the path of Windows tools), n refuses to install NodeJS.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
node and npm installed, running them uses the version in Pengwin
Actual behavior
Installation fails with
n-install: ERROR:
Aborting, because n and/or Node.js-related binaries are already
in the $PATH:
/mnt/c/nvm/v10.13.0/npm
Please remove any existing n, Node.js installation, then try
again.
and the linux version of node and npm is obviously missing, making attempts to run either fail.
(BTW, your issue template is missing this Actual behavior section)
Additional context
Workaround: Remove npm from the path.
The base problem seems to be that n is rather picky with these thing. I'm not sure if that is fixable, though. To me, nvm seems like a better option (OTOH, I haven't really tested nvm for this issue, so it might be just as bad here, but in general it just works).
~(To make matters worse, it seems even if n installs correctly, the PATH isn't adjusted properly, so you need to find out where it dumped the install)~ (edit: It seems it does actually add it to .bashrc, just not to the running shell)
Basic Troubleshooting Checklist
The rest is not really relevant. It's easily fixable, but it is a really, _really_ clumsy experience. Especially since first-time setup is likely among a lot of other packages, so you won't really see the problem, and get confused since the npm that will run is really the Windows one, making it fail with a semi-cryptic error message.
Pengwin Version
1.2.3.0
Windows Build
OS Name: Microsoft Windows 10 Pro
OS Version: 10.0.17134 N/A Build 17134
Sharing PATH between Windows and Linux is a feature of WSL. We are going to have to think carefully about how we solve this without breaking other things. We could truncate Windows nodejs from PATH on install, but you're going to later have two nodejs in your PATH. We could truncate similarly on each Pengwin launch but there'd be no way to restore it when you closed Pengwin. A lot of our users are probably going to have nodejs already installed on Windows, so we need to think on this.
Putting the n bin path before the paths imported from Windows should work fine. Then the n/Pengwin-installed npm and node will be found first.
I don't think it's even possible to share the other way (from Pengwin/WSL back to Windows), so I don't believe it would conflict.
is it possible to do both a (comand -v node) and then a (node) and trap the second call's stderr to see if it's a nix or windows binary.
as a workaround I trimmed my path
PATH=$(echo "$PATH" | sed -e 's/\/mnt\/c\/Program Files\/nodejs://')
PATH=$(echo "$PATH" | sed -e 's/\/mnt\/c\/Users\/jburkholder\/AppData\/Roaming\/npm://')
PATH=$(echo "$PATH" | sed -e 's/\/mnt\/c\/Program Files (x86)\/Yarn\/bin://')
YMMV
We can ask the user before installing node if we find it in windows path to override this every time that pengwin starts
All the Linux paths should appear before Windows paths. They both should be there (because having Windows interop is nice) and if node is installed on Windows already and is getting installed in WSL, simply edit the path to ensure the WSL path of node is read prior to the path to Windows for install, as mentioned above, simply truncate the Windows paths and undo when install is complete. That override option would probably be a good idea to alert the user of potential conflict in case the Path doesn't get fixed.
I'm having the same issue :(
Hello,
The last commit of https://github.com/WhitewaterFoundry/pengwin-setup/pull/167 has the fix for this. Basically the @fishstick22 solution in an automated and generic way.
Regards
Moved into development branch.
nodejs in my PATH env has / at the end of it, so this sed isn't removing it from PATH while trying to install n.
Hello,
This commit
https://github.com/WhitewaterFoundry/pengwin-setup/commit/cea92cd2438e522d1d81accc43e6884e8d762b62
fixes the issue with the slashes.
It will be released this week.
Regards,
Carlos
El dom., 23 de junio de 2019 22:51, Jordan Janzen notifications@github.com
escribió:
nodejs in my PATH env has / at the end of it, so this sed isn't removing
it from PATH while trying to install n.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/WhitewaterFoundry/Pengwin/issues/400?email_source=notifications&email_token=ACACEQZCIHKFHUF4HOSWGNDP37O5ZA5CNFSM4HFDUXD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYLGYII#issuecomment-504785953,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACACEQ6YZIGK6RADWW6G4WTP37O5ZANCNFSM4HFDUXDQ
.
This seems to be related to what I'm seeing on my installation.
Windows 10 Pro
Version 1903
Pengwin version 1.2.5
In Pengwin, after trying to install node and npm, I get this warning:
/mnt/c/Program Files/nodejs/npm: 6: /mnt/c/Program Files/nodejs/npm: Syntax error: word unexpected (expecting "in")
I do have node and npm previously installed on Windows
node v12.3.1
npm v6.9.0
Hello @darrell24015 ,
With the latest pengwin-setup it should take care of the Windows installation of node. Try again with the latest pengwin-setup. If it still doesn't please run it again passing --debug and send us the output to check.
Regards
I'm getting an error when I try to install Node on Pengwin. It asks me if I want to hid Node on Windows and I say yes. I always get this error:
`n-install: ERROR:
Aborting, because n and/or Node.js-related binaries are already
in the $PATH:
/mnt/c/Users/Brian/AppData/Roaming/npm/npm
Please remove any existing n, Node.js installation, then try
again.`
I'm not very experienced with WSL so I'd appreciate some help.
Here is my complete debug output.
`Running in debug/verbose mode
++ shift
++ [[ 0 -gt 0 ]]
++ wslpath 'C:\'
+++ cmd-exe /c 'echo %HOMEDRIVE%%HOMEPATH%'
+++ tr -d '\r'
++ readonly 'wHomeWinPath=C:\Users\Brian'
++ wHomeWinPath='C:\Users\Brian'
+++ wslpath -u 'C:\Users\Brian'
++ readonly wHome=/mnt/c/Users/Brian
++ wHome=/mnt/c/Users/Brian
++ readonly CANCELLED=CANCELLED
++ CANCELLED=CANCELLED
++ SetupDir=/usr/local/pengwin-setup.d
++ readonly GOVERSION=1.12
++ GOVERSION=1.12
if ( which cmd.exe >/dev/null ); then
WIN_NPM_PATH="$(dirname "$(which npm)")"
WIN_C_PATH="$(wslpath 'C:\')"
if [[ "${WIN_NPM_PATH}" == "${WIN_C_PATH}"* ]]; then
PATH=$(echo "${PATH}" | sed -e "s#${WIN_NPM_PATH}##")
fi
WIN_YARN_PATH="$(dirname "$(which yarn)")"
if [[ "${WIN_YARN_PATH}" == "${WIN_C_PATH}"* ]]; then
PATH=$(echo "${PATH}" | sed -e "s#${WIN_YARN_PATH}##")
fi
fi
++ cat /etc/profile.d/rm-win-npm-path.sh
if ( which cmd.exe >/dev/null ); then
WIN_NPM_PATH="$(dirname "$(which npm)")"
WIN_C_PATH="$(wslpath '\''C:\'\'')"
if [[ "${WIN_NPM_PATH}" == "${WIN_C_PATH}"* ]]; then
PATH=$(echo "${PATH}" | sed -e "s#${WIN_NPM_PATH}##")
fi
WIN_YARN_PATH="$(dirname "$(which yarn)")"
if [[ "${WIN_YARN_PATH}" == "${WIN_C_PATH}"* ]]; then
PATH=$(echo "${PATH}" | sed -e "s#${WIN_YARN_PATH}##")
fi
fi'
++ which cmd.exe
++++ which npm
+++ dirname '/mnt/c/Program Files/nodejs/npm'
++ WIN_NPM_PATH='/mnt/c/Program Files/nodejs'
+++ wslpath 'C:\'
++ WIN_C_PATH=/mnt/c/
++ [[ /mnt/c/Program Files/nodejs == /\mn\t/\c/* ]]
+++ echo '/home/brian/.pyenv/plugins/pyenv-virtualenv/shims:/home/brian/.pyenv/shims:/home/brian/.pyenv/bin:/home/brian/.rbenv/plugins/ruby-build/bin:/home/brian/.rbenv/shims:/home/brian/.rbenv/bin:/home/brian/go//bin:/usr/local/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/iCLS:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/iCLS:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/PuTTY:/mnt/c/Program Files (x86)/Plantronics/Spokes3G:/mnt/c/Program Files/Intel/WiFi/bin:/mnt/c/Program Files/Common Files/Intel/WirelessCommon:/mnt/c/Program Files/nodejs:/mnt/c/Ruby25-x64/bin:/mnt/c/Users/Brian/AppData/Local/Yarn/config/global/node_modules/.bin:/mnt/c/Users/Brian/AppData/Roaming/Composer/vendor/bin:/mnt/d/Laragon/bin:/mnt/d/Laragon/bin/apache/httpd-2.4.35-win64-VC15/bin:/mnt/d/Laragon/bin/composer:/mnt/d/Laragon/bin/laragon/utils:/mnt/d/Laragon/bin/mysql/mysql-5.7.24-winx64/bin:/mnt/d/Laragon/bin/nginx/nginx-1.14.0:/mnt/d/Laragon/bin/ngrok:/mnt/d/Laragon/bin/notepad++:/mnt/d/Laragon/bin/php/php-7.2.11-Win32-VC15-x64:/mnt/d/Laragon/bin/putty:/mnt/d/Laragon/bin/redis/redis-x64-3.2.100:/mnt/d/Laragon/bin/telnet:/mnt/d/Laragon/usr/bin:/mnt/c/Users/Brian/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/JetBrains/PhpStorm 2019.1/bin:/mnt/c/Users/Brian/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/Brian/AppData/Local/hyper/app-3.0.2/resources/bin:/mnt/c/Users/Brian/AppData/Roaming/npm:/home/brian/n/bin'
+++ sed -e 's#/mnt/c/Program Files/nodejs##'
++ PATH='/home/brian/.pyenv/plugins/pyenv-virtualenv/shims:/home/brian/.pyenv/shims:/home/brian/.pyenv/bin:/home/brian/.rbenv/plugins/ruby-build/bin:/home/brian/.rbenv/shims:/home/brian/.rbenv/bin:/home/brian/go//bin:/usr/local/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/iCLS:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/iCLS:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/PuTTY:/mnt/c/Program Files (x86)/Plantronics/Spokes3G:/mnt/c/Program Files/Intel/WiFi/bin:/mnt/c/Program Files/Common Files/Intel/WirelessCommon::/mnt/c/Ruby25-x64/bin:/mnt/c/Users/Brian/AppData/Local/Yarn/config/global/node_modules/.bin:/mnt/c/Users/Brian/AppData/Roaming/Composer/vendor/bin:/mnt/d/Laragon/bin:/mnt/d/Laragon/bin/apache/httpd-2.4.35-win64-VC15/bin:/mnt/d/Laragon/bin/composer:/mnt/d/Laragon/bin/laragon/utils:/mnt/d/Laragon/bin/mysql/mysql-5.7.24-winx64/bin:/mnt/d/Laragon/bin/nginx/nginx-1.14.0:/mnt/d/Laragon/bin/ngrok:/mnt/d/Laragon/bin/notepad++:/mnt/d/Laragon/bin/php/php-7.2.11-Win32-VC15-x64:/mnt/d/Laragon/bin/putty:/mnt/d/Laragon/bin/redis/redis-x64-3.2.100:/mnt/d/Laragon/bin/telnet:/mnt/d/Laragon/usr/bin:/mnt/c/Users/Brian/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/JetBrains/PhpStorm 2019.1/bin:/mnt/c/Users/Brian/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/Brian/AppData/Local/hyper/app-3.0.2/resources/bin:/mnt/c/Users/Brian/AppData/Roaming/npm:/home/brian/n/bin'
++++ which yarn
+++ dirname ''
++ WIN_YARN_PATH=.
++ [[ . == /\mn\t/\c/* ]]
/mnt/c/Users/Brian/AppData/Roaming/npm/npm
Please remove any existing n, Node.js installation, then try
again.
++ cat /home/brian/.bashrc
++ grep '^.N_PREFIX.$'
++ cut -d# -f 1
Maybe node is installed, but not in the PATH?
Note that running as sudo can change envs.
PATH=/home/brian/.pyenv/plugins/pyenv-virtualenv/shims:/home/brian/.pyenv/shims:/home/brian/.pyenv/bin:/home/brian/.rbenv/plugins/ruby-build/bin:/home/brian/.rbenv/shims:/home/brian/.rbenv/bin:/home/brian/go//bin:/usr/local/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/iCLS:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/iCLS:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/PuTTY:/mnt/c/Program Files (x86)/Plantronics/Spokes3G:/mnt/c/Program Files/Intel/WiFi/bin:/mnt/c/Program Files/Common Files/Intel/WirelessCommon::/mnt/c/Ruby25-x64/bin:/mnt/c/Users/Brian/AppData/Local/Yarn/config/global/node_modules/.bin:/mnt/c/Users/Brian/AppData/Roaming/Composer/vendor/bin:/mnt/d/Laragon/bin:/mnt/d/Laragon/bin/apache/httpd-2.4.35-win64-VC15/bin:/mnt/d/Laragon/bin/composer:/mnt/d/Laragon/bin/laragon/utils:/mnt/d/Laragon/bin/mysql/mysql-5.7.24-winx64/bin:/mnt/d/Laragon/bin/nginx/nginx-1.14.0:/mnt/d/Laragon/bin/ngrok:/mnt/d/Laragon/bin/notepad++:/mnt/d/Laragon/bin/php/php-7.2.11-Win32-VC15-x64:/mnt/d/Laragon/bin/putty:/mnt/d/Laragon/bin/redis/redis-x64-3.2.100:/mnt/d/Laragon/bin/telnet:/mnt/d/Laragon/usr/bin:/mnt/c/Users/Brian/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/JetBrains/PhpStorm 2019.1/bin:/mnt/c/Users/Brian/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/Brian/AppData/Local/hyper/app-3.0.2/resources/bin:/mnt/c/Users/Brian/AppData/Roaming/npm:/home/brian/n/bin
Hello Brian,
It looks like you have npm installed on two places on Windows, but I need to check more deeply. I'll come back later.
Regards
In my installation, c/Users/Brian/AppData/Roaming/npm/ is empty, but in yours, you have npm installed. Try to delete one of your npm installations in Windows.
I made a fix t take account more than one installation of npm in Windows: https://github.com/WhitewaterFoundry/pengwin-setup/pull/190
Most helpful comment
Hello,
The last commit of https://github.com/WhitewaterFoundry/pengwin-setup/pull/167 has the fix for this. Basically the @fishstick22 solution in an automated and generic way.
Regards