NSIS and PATH env variables - nsis

In my installer, I embed cmake and others installers.
During installation the user install, through my installer, cmake and add cmake to the path.
At this point if I open a command prompt and type cmake, it is actually recognized.
But in the installer I run the following command:
ReadEnvStr $1 %COMSPEC%
ExecWait '"$1" /c cmake XXX'
But it tells me cmake isn't recognized. How is that possible? I just open a command prompt before in c:/windows/system32/cmd.exe and type cmake and it was recognized so why this code does not work?
It is like the paths env variables was not updated somehow. Of course if I reboot it works fine but I would like to avoid it.
Thanks for your help.

Environment variables are inherited from their parent process by default. Explorer.exe is the only application that listens for environment changes and therefore if you start a new process from the start menu it will run with the updated environment.
You can update the installer process environment and it will be passed to the ExecWait child:
System::Call 'kernel32::SetEnvironmentVariable(t "foo", t "bar")'
When dealing with long path strings you really should be using the EnvVar plug-in.

Related

NSIS EnvVarUpdate visible in System Properties, but not working

I am installing 7-ZIP using NSIS and then looking in the registry to see where it has been installed. Having detected the install location I am taking the path and creating a system variable named 7-ZIP using the NSIS command below.
${EnvVarUpdate} $0 "7-ZIP" "A" "HKLM" "<Install Path>"
I then append the 7-ZIP var to the PATH var.
After the install has finished I can see the new System var in the System Variables list.
The new 7-ZIP variable has also been amended to the PATH variable as the image below shows.
Now the issue I have is that when I start a cmd window and type 7z I would expext it to run the 7z.exe located in the C:\Program Files\7-Zip directory, but it does not and complains it cannot find it. If I then close the CMD window and edit the 7-ZIP variable, but don't actually chang anything. The same command then works when i try again with a new CMD window.
I just wonder whether anyone else has experienced this issue and if they found a work around?

How to manage the environment PATH used by the Android NDK build?

I use swig from my within Android.mk. I reference it directly relying on the $PATH variable to contain the path to it's executable.
The issue is that the $PATH variable is different depending on where the android-ndk tool is run from.
Background
In my Android.mk file:
# some stuff ...
#echo "$(PATH)"
swig # swig parameters here...
# more stuff ...
From the terminal, we see the system path includes the path to swig:
which swig
/usr/local/bin/swig
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:
Issue
When the android-ndk is run from within Android Studio I get the following for PATH (note: it's missing the swig path):
/usr/bin:/bin:/usr/sbin:/sbin
This causes my build to fail because "swig" isn't recognised:
make: swig: Command not found
However, if I run the android-ndk directly from the terminal, then the PATH used is the same as my system path and the build works fine:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:
Bad solution
Yes, I could add the path manually to my Android.mk file:
export PATH:=/usr/local/bin/:$(PATH)
However, I'd prefer not to define specific paths for my machine knowing that the whole team uses this file.
Question
I'd prefer the Android.mk file to use my systems PATH instead.
Any ideas how to do this?
Thanks!
The thing in my opinion is that environment variables may be different whether the process is launched from terminal or from the GUI (launchpad, spotlight, ...).
The former would use PATH as set in bashrc (or other shell related startup files) while the other will not.
I think you might find interesting information on how to change the environment variables for the launch deamon in the following question:
Setting environment variables in OS X?

'node' is not recognized as an internal or an external command, operable program or batch file while using phonegap/cordova

I am using phonegap/cordova.
Everthing is installed propelry i.e cordova, phonegap, ant,sdk,jdk.
But now it says "node is not recogzed as an internal or external command"
In Windows, you need to set node.js folder path into system variables or user variables.
1) open Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables
2) in "User variables" or "System variables" find variable PATH and add node.js folder path as value. Usually it is C:\Program Files\nodejs;. If variable doesn't exists, create it.
3) Restart your IDE or computer.
It is useful add also "npm" and "Git" paths as variable, separated by semicolon.
Great answers, but you could just open the command prompt and type in
SET PATH=C:\Program Files\Nodejs;%PATH%
Worked for me by running the command prompt as an administrator
Add a system variable named "node", with value of your node path.
It solves my problem, hope it helps.
If you install Node using the windows installer, there is nothing you have to do. It adds path to node and npm.
You can also use Windows setx command for changing system environment variables. No reboot is required. Just logout/login. Or just open a new cmd window, if you want to see the changing there.
setx PATH "%PATH%;C:\Program Files\nodejs"
As you're using Windows, installation should automatically edit the %PATH% variable. Therefore, I suspect you simply need to reboot your system after installing.
Be aware that the Path is case sensitive. I tried setx PATH and it didn't work. In my case it was setx Path. Make sure your CMD run as Administrator.
setx Path "%PATH%;C:\Program Files\nodejs"
Now just restart your command prompt (or restart the PC) and the node command should be available.
Also, try to run nvm on to turn on the node. Worked for me.
If you already have node installed, your path variable is set up and you suddenly start getting this error; try updating to the latest version.
This worked for me going from 6.9.2 to 6.10.
In my case, I'm using NVM and it installed Node v16.2.0, which for some reason has node.exe named as node64.exe. I changed it to node.exe and everything just worked.
In windows search bar type "enviroment variable" open it and set path
C:\Program Files\nodejs;
After adding path in system enviroment variable, If problem still occurs then follow steps
Close cmd and open new cmd, try "node" command.
For VS code close all windows and reopen then try "node" command.
If above steps didn't work then restart system.(this one worked for me)
I tried the solutions above but uninstall and reinstall of nodejs from installer the only one worked for me.
In my case I was using nvm-windows and JetBrains Rider. The required paths were specified in environment variables, but MSBuild wasn't picking them up. Apparently I haven't rebooted my PC after installing NVM. Rebooting the PC fixed the problem.
Please install node through nvm
following command will give you the path where node is installed .
nvm root
Current Root: C:\Users\u725561\AppData\Roaming\nvm
node would be present inside the subdirectory of nvm root .
add the directory C:\Users\u725561\AppData\Roaming\nvm\v12.22.2 to path environment variable.
I had the same problem. My solution was just restart :/
If you have this problem, you should just try restart first...
Try to add the version at the end in the PATH variable
C:\Program Files\nodejs\16.x.x
**Wnidows-11**
control panel---Advance system setting----Enviornment Variable---new----Variable Name(Path) Varibale value(C:\Program Files\nodejs or whichever your path)
Afterwards restart your cli and node -v then boom!!
enter image description here
Make sure that the node.exe exists in C:\Program Files\nodejs\, then add it to the path. ( See above answers to see how)
I am using chocolate package manger for installing nodejs by running choco install nodejs. Surprisingly in some versions the node.exe was not created in C:\Program Files\nodejs\ !
So make sure the node.exe is in C:\Program Files\nodejs\
I went through all the comments here, none of them worked. I found I had to uninstall and reinstall node.js and then it worked. Probably not the best solution but try this answer at the bottom of the list if all else fails...
For me I just click on empty session and it works for me

linux eclipse: run a shell command as the pre-build command

How can I have the pre-build step in eclipse/CDT (Linux) run a simple shell command, echo specifically. I think eclipse has a screwed up value for PKG_CONFIG_PATH and want to see what Linux thinks the value is.
Under the covers, Eclipse uses "make". You can simly edit the project's makefile:
help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.cdt.doc.user/concepts/cdt_c_makefile.htm
You can also create an:
"External Tool", which is up there beside the Debug and Run buttons in
the toolbar. Then I tell the external tool to run the shell with the
configure script and any of it's arguments as arguments to the tool.
http://www.eclipse.org/forums/index.php/t/61866/

Node.JS - How to Run Node Command from any path?

I have installed the latest node.js from here . I see the %Path% variables have been set for Node.js. But, When i run node from C:\ , i get a "Node is not an recognized comman". But node command is working fine from "C:\Program Files (x86)\nodejs" path. Can i not run Node commands from C:\ or Say from an other path if i set the Env variables right? Please help. I am running a Win7 X64.
Thank You,
Faraaz
I had the exact same problem, but in my PATH variable I had: C:\Program Files\nodejs\.
After changing it to C:\Program Files\nodejs I could access it from anywhere.
What happens if you run node --version? I have never tried node.js from windows but if that doesn't work there is something wrong with your paths.
What do you get when you run echo %PATH%?
You should check if the path C:\Program Files (x86)\nodejs is present in your %PATH. If not, add it via the system properties (persistent change). In any case, restart your command prompt, it'll reload the %PATH variable. If you're lucky, it should work now :)
Most likely it happens because there is no Node path in your PATH environment variable.
I see two ways to solve this
Just add Node path into the end of PATH.
Reinstall Node as administrator
run 7-zip (or some file manager) with administrator privileges >>
browse to node-installer.msi >> open it, install node >> enjoy
My Sublime was working with Nodejs fine. I could press Alt-R and see the output from Node in Sublime. Then at some point I upgraded Sublime. I now have version 2.02 build 2221
And at some later point I tried Alt-R and got this infamous message
'node' is not recognized as an internal or external command
But it had worked, so what changed?
The steps I took to fix it were to install git bash and then
$ git clone https://github.com/tanepiper/SublimeText-Nodejs.git
$ cd SublimeText-Nodejs/
$ git checkout 095ba03344
Back in Sublime I clicked Preferences > Browse Packages. This opened up Windows Explorer with the folder:
C:\Users\me\AppData\Roaming\Sublime Text 2\Packages
I replaced the contents of the Nodejs folder with the git version. Re-started Sublime and then Alt-R sprang back into life.
Other things that turned out to be irrelevant were changing the file Nodejs.sublime-settings and tampering with system environment variables. The only thing that worked was 095ba03344 as described here
https://github.com/tanepiper/SublimeText-Nodejs/pull/39

Resources