Problem with the command-line JSON processor JQ in Windows 10, 64 bit - json

I have downloaded the program jq-win64.exe from 'https://stedolan.github.io/jq/' and installed the program in a folder C:\Program Files\jq\ on my computer.
I have also added the PATH to the program to the end of the systemvariable string in Windows 10 : . . . ;C:\Program Files\curl\;C:\Program Files\jq\
In one terminal window in Visual Studio Code I am running a server.
In another terminal window I am trying to execute the command curl -s localhost:3000 | jq
Terminal window 1:
C:\Users\SteinarV\PROFF_JAVASCRIPT\PROJECT\smartHouse
node server.js
API running on port 3000
Terminal window 2:
C:\Users\SteinarV\PROFF_JAVASCRIPT\PROJECT\smartHouse>curl -s localhost:3000 | jq
'jq' is not recognized as an internal or external command,
operable program or batch file
... and do not understand why jq is not recognized.
Can someone help ?

I have downloaded the program jq-win64.exe from 'https://stedolan.github.io/jq/' and installed the program in a folder C:\Program Files\jq\ on my computer.
As you have indicated, you have a file called jq-win64.exe but you are trying to execute the command jq. You either need to rename the file to jq.exe or you need to use the command jq-win64.
For a detailed explanation of how Windows finds and executes a program in your path when you enter a command, see The Windows NT Command Shell: Command Search Sequence. Specifically:
...The shell now searches each directory specified by the PATH environment variable, in the order listed, for an executable file matching the command name. If a match is found, the external command (the executable file) executes...
...If the command name does not include a file extension, the shell adds the extensions listed in the PATHEXT environment variable, one by one, and searches the directory for that file name. Note that the shell tries all possible file extensions in a specific directory before moving on to search the next directory (if there is one)...
You indicate in the comments the same error persists even when the filenames match. Note that each running program has its own set of environment variables, and these aren't updated by global changes. You need to close and reopen cmd.exe windows after making a global change. See also Adding directory to path environment variable in windows. You can use the path command to verify whether a particular terminal session has inherited the PATH variable you defined, thus narrowing your problem.
You indicate that the problem still persists. You need to use the tools available to you to narrow it down further:
Try running the program with its full path:
"C:\Program Files\jq\jq-win64.exe" --help
This will confirm that the program is present where you think it is and can be run from the terminal.
Try running the program with no path and its extension:
jq-win64.exe --help
If this works but running the program without an extension doesn't, you might have set PATHEXT to something that doesn't include ".EXE".
Try setting the path explicitly in the terminal to contain only the program directory and nothing else, then run it with its full extension:
set PATH=C:\Program Files\jq
jq-win64.exe --help
(Note that after this test you'll need to close the terminal window and start a new one to reset the path.)
If this works, perhaps you have a mismatch in your path.

Related

I have installed MySQL and have added the directory to my PATH but it still isnt working [duplicate]

This question already has an answer here:
VS code terminal can't find AWS SAM even though windows terminal can
(1 answer)
Closed yesterday.
So I downloaded the MySQL installer from https://dev.mysql.com/downloads/installer/. I then went through the process of setting it up via the installer etc. After this was complete, I went to test the command in both Windows PowerShell and CMD, but neither worked.
I looked everywhere I could online to find out what the issue was, but nothing really worked. I found a post that said to add the MySQL path to the main system PATH and so I did. The command I used was:
SET PATH=%PATH%;C:\Program Files\MySQL\MySQL Server 8.0\bin
I also manually edited my environment variables and checked everything there. HOWEVER, a really weird thing is that when I run that command in cmd the mysql --version command WORKS! When I run the same command in Powershell it doesn't, and when I close Windows Terminal and re-open it, the command no longer works in cmd! I really have no idea whats going on. The error message I receive in PowerShell is:
PS C:\Users\User> mysql --version
mysql: The term 'mysql' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
And the error message I receive in CMD is:
C:\Users\User>mysql --version
'mysql' is not recognized as an internal or external command,
operable program or batch file.
If anyone could give me a hand, that'd be amazing, thanks.
Adding to the PATH the way you did is only temporary. It lasts as long as the terminal is open, and when the terminal is gone, so is the change to the path. Use setx instead of set to make it permanent, or make the change using the UI in Windows settings. To do the latter, open the Settings dialog and type Environment into the search box, and then choose the option to change the system environmental variables. When the System Properties dialog appears, click the Environmental variables button at the lower right.

PHP Mysql laravel 5.4 terminal issue

i am new to laravel i just figured out how to install composer laravel etc etc on my local machine MAMP on windows , Now i am confuse with the command on terminal which is
C:\project>mysql -uroot -proot
'mysql' is not recognized as an internal or external command,
operable program or batch file.
How can i fix this ?
setting Environment will solve the issue
Go to Control Panel -> System -> Advanced
Click - Environment Variables
Go to- System Variables find PATH and click on it.
add the path to your mysql\bin folder to the end paths. (ex: E:\xampp\mysql\bin) and add ; end of the line
Close all the command prompts you opens.
Re open and try it.
Setting the PATH to point to the MYSQL bin folder is normally the first thought, but I find that dangerous as things get left lying around when you change software.
I normally create a little batch file in the projects folder or in a folder that it already on your PATH, like this
mysqlpath.cmd
echo off
PATH=C:\mamp\path\to\the\mysql\bin;%PATH%
mysql -v
The mysql -v will output the mysql version number but it is a handy way of knowing that the correct folder has been added to the PATH. This adds the folder to the PATH but only for the life of the command window.
Then just run this from any command window when you want to use MYSQL from the command line
> phppath
You may also like to create one for PHP as well
phppath.cmd
echo off
PATH=C:\mamp\path\to\the\php\;%PATH%
php -v

Strange response (about MySQL) for heroku login on windows (closed)

I have heroku toolbelt installed on Windows7 (x64 HomeEd). When i'm trying to login to heroku, i recieve strange message about MySQL (though MySQL already works fine with all software installed):
Microsoft Windows [Version 6.1.7601]
(c) Microsoft Corp., 2009. All rights reserved.
C:\windows\system32>heroku login
"MySQL" is not recognized as an internal or external command,
operable program or batch file.
"MySQL" is not recognized as an internal or external command,
operable program or batch file.
C:\windows\system32>
Exactly like shown - two times. As I found, heroku.bat does not invoke MySQL at any step. I think that OS runs some script (a kind of autoexec) just before or in parallel with heroku.bat, but i can't find the way used to do this. This is confirmed by the fact that when i start the other bat files the same two messages about MySQL appears.
Can you help me find how that strange script is invoked?
Detailed research shown that the reason is MySQL component, named "MySQL Fabric 1.5.3 & MySQL Utilities 1.5.3 1.5". During installation MySQL added it's location to Path environment variable. This caused to break Path variable contents with "&" symbol and any invocation of Path variable cause error
It seems that at some point a script tries to call MySQL.exe and this file can't be found. To solve this problem you should add the Directory containing MySQL.exe to %PATH%. First make sure MySQL.exe is located on your system. If you are not sure where it is, start CMD, go to your root directory (CD \) end enter dir /S MySQL.exe. This will search your drive for the file and show you the path, where it can be found. Save the path somewhere.
Now that you know where the file is is, you have to add it's location to %PATH%. To do so enter setx PATH "<NEWPATH>;%path%;" where is the path to the directory containing MySQL.EXE. Dont forget ;%path%;, this is very important. If you don't put it there it wil mess up your %PATH%.
Close the console, open a new one and type heroku login. This should fix the problem.
Now if you are not interested in fixing the error and just want to know where it comes from, you should post the code of the batch file that is executed by calling heroku login.
Just remove the C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\Doctrine extensions for PHP\; from your path (It is breaking things up, it gets added during MySQL installation)and add the MySQL bin path. For me it is C:\Program Files\MySQL\MySQL Server 5.7\bin

How do I extend the $PATH that Sublime Text 2 uses?

I just installed Sublime-jshint (and the requisite node.js + jshint) but get this error when I try to invoke JSHint from within ST2:
[Errno 2] No such file or directory
[cmd: [u'jshint', u'PATH-TO-THE-JS-FILE-I-AM-LINTING', u'--reporter', u'/home/cmg/.config/sublime-text-2/Packages/JSHint/reporter.js']]
[dir: DIR-MY-JS-FILE-IS-IN]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/cmg/bin]
[Finished]
The final item in the given path is in the home dir of my user (cmg), so it's been customized somehow... but I don't recall how, so I don't know how to add the dir I need (~/node_modules/.bin).
I've added it to $PATH in my shell (via both .bashrc and .bash_profile) but ST2 doesn't pick it up.
(I'm on Ubuntu 14.04. All the usable stuff I've found via Google on this subject has been either OS X specific or related to ST's build system).
Basically, the exec command, which the jshint package uses internally, allows you to set/extend the PATH of the spawned subprocess. (docs)
The package actually uses this path argument on OSX, but has it hardcoded (I am partly guilty of that as I rewrote the command because it was just horrible before). It should allow for a setting to specify the path to your jshint executable, so I suggest you create an issue for that.
I don't know why ST dosn't pick up your PATH from somewhere else since I have very little experience with that.
Open /etc/profile in Sublime (using sudo) and add the following line at the very bottom:
export PATH=/home/cmg/node_modules/.bin:$PATH
and save the file. Restart completely, and your PATH should be updated.

TortoiseHg: ‘hg’ is not recognized as an internal or external command, operable program or batch file

I'm unable to find the command line tools in Mercurial-TortoiseHg version 2.7.2. I checked for hg.exe file and it is present at C:\Program Files\TortoiseHg path but whenever I try running the command it fails and throws the error :
‘hg’ is not recognized as an internal or external command, operable program or batch file.
I have also added it to the windows PATH= ; C:\Program Files\TortoiseHg.
Not sure what else to look for. Please help.
Notes:
As mentioned in "Mercurial not working after TortoiseHg update", TortoiseHg v2.X.X no longer uses the hg command, but rather thg.
That means your PATH might not be updated properly to reference hg.exe of TortoiseHg.
to update your PATH, make sure not add any extra space:
set PATH=%PATH%;C:\Program Files\TortoiseHg
(no space between ';' and 'C:\...')
As mentioned by the OP Sowmya Guru, if you modify the user environment variable, a restart (or at least a new DOS windows) is necessary.
Posting my answer related to vanilla Mercurial install (not 'TortoiseHg') as it was the first page in search results, my solution was to use the 'Mercurial-3.4 (64-bit msi)' installer instead of the 'Mercurial-3.4 (64-bit exe)' from this page.