System cannot find path/command not found error in Powershell - powershell

I have an installation of Elasticsearch that has worked fine for months but has inexplicably gone missing according to Powershell. The only thing I can think of that has changed recently is that I updated Java.
When I try to run it using the full path I get the following error:
PS C:\> C:\elasticsearch\bin\elasticsearch.bat
The system cannot find the path specified.
The path exists and there is no spelling error as you can see here:
PS C:\elasticsearch\bin> dir
Directory: C:\elasticsearch\bin
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 8/7/2016 10:13 PM 5551 elasticsearch
-a---- 8/7/2016 10:13 PM 104448 elasticsearch-service-mgr.exe
-a---- 8/7/2016 10:13 PM 103936 elasticsearch-service-x64.exe
-a---- 8/7/2016 10:13 PM 80896 elasticsearch-service-x86.exe
-a---- 8/7/2016 10:13 PM 909 elasticsearch.bat
-a---- 8/7/2016 10:13 PM 3307 elasticsearch.in.bat
-a---- 8/7/2016 10:13 PM 2814 elasticsearch.in.sh
-a---- 8/7/2016 10:13 PM 2992 plugin
-a---- 8/7/2016 10:13 PM 1303 plugin.bat
-a---- 8/7/2016 10:13 PM 6501 service.bat
When I try to run it from within the directory itself, I get the following message:
PS C:\elasticsearch\bin> elasticsearch.bat
elasticsearch.bat : The term 'elasticsearch.bat' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ elasticsearch.bat
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (elasticsearch.bat:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [3,General]: The command elasticsearch.bat was not found, but does exist in the current location. Windows Pow
erShell does not load commands from the current location by default. If you trust this command, instead type: ".\elastic
search.bat". See "get-help about_Command_Precedence" for more details.
I don't have a strong knowledge of handling Powershell errors, so I have only tried a few things:
Reinstalling Elasticsearch
Adding the directory containing elasticsearch.bat to the path
Running elasticsearch.bat using the command ./elasticsearch.bat
None of these change anything.
Here's the content of elasticsearch.bat:
#echo off
SETLOCAL enabledelayedexpansion
TITLE Elasticsearch 2.3.5
SET params='%*'
:loop
FOR /F "usebackq tokens=1* delims= " %%A IN (!params!) DO (
SET current=%%A
SET params='%%B'
SET silent=N
IF "!current!" == "-s" (
SET silent=Y
)
IF "!current!" == "--silent" (
SET silent=Y
)
IF "!silent!" == "Y" (
SET nopauseonerror=Y
) ELSE (
IF "x!newparams!" NEQ "x" (
SET newparams=!newparams! !current!
) ELSE (
SET newparams=!current!
)
)
IF "x!params!" NEQ "x" (
GOTO loop
)
)
SET HOSTNAME=%COMPUTERNAME%
CALL "%~dp0elasticsearch.in.bat"
IF ERRORLEVEL 1 (
IF NOT DEFINED nopauseonerror (
PAUSE
)
EXIT /B %ERRORLEVEL%
)
"%JAVA_HOME%\bin\java" %JAVA_OPTS% %ES_JAVA_OPTS% %ES_PARAMS% -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" start !newparams!
ENDLOCAL

PS C:\> C:\elasticsearch\bin\elasticsearch.bat
The system cannot find the path specified.
Are you sure that's not the output of the batch file? In other words, something in the batch file cannot find a path specified (perhaps java.exe). If PowerShell can't find the file, you'll get an error message like your second attempt.
Speaking of your second attempt:
PS C:\elasticsearch\bin> elasticsearch.bat
As the error message states, this won't work for files in the current folder. You need to explicitly specify the current folder:
PS C:\elasticsearch\bin> .\elasticsearch.bat

Related

Terraform - Unable to intiate terraform

I am trying to initiate terraform on visual studio code - insiders.
Points:
I have downloaded the terraform executable file and i am able to launch it on command prompt.
When to run the command terraform init command on visual studio code - insider i get the following error message. Please find the error message below and also the location of the terraform index.
PS F:\terraform> terraform.exe init
Fatal error in launcher: Unable to create process using
'"c:\python38\python.exe" "c:\Python38\Scripts\terraform.exe" init':
the system cannot find the file specified.
PS F:\terraform> ls
Directory: F:\terraform
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 18-09-2021 22:21 .terraform
-a--- 18-09-2021 22:33 1035 .terraform.lock.hcl
-a--- 18-09-2021 22:48 219 main.tf
-a--- 18-09-2021 22:48 41 provider.tf
----- 18-09-2021 23:44 80807800 terraform.exe
I have tried to run the same code ps core 6 i get the above error message in the command prompt it works perfectly.
I really your inputs on what can be done.
Please help
Regards
Sudlo
Here the steps which I performed to fix the issue.
I launched PS core prompt went into the directory in my case
f:\terrform and passed the command terraform init I got the same error message.
went into the location C:\Python38\Scripts and located the terraform executable file deleted the file and copied it again and performed initialization command. This time there was no error.
Hope this helps

Another clarification on Azure DevOps Pipeline: -d--- and -a--- mode

I do a Download of My Build.SourceDirectories and what is get is of this format:
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 3/11/2021 8:51 PM ReleaseNoteScripts
d----- 3/11/2021 8:51 PM Flow_Tools_CodeGen_PS
-a---- 3/11/2021 8:51 PM 1319 README.md
I am using this Directory to run a powershell script to upload it in SharePoint. I am able to do it for files with mode d--- but it fails for file with mode -a--- . In this case, It gives me error as README.MD file is not found. What is -a--- mode and I am ok with README.md file not uploaded in SharePoint. How should I remove that my PowerShell Script don't take this file
Mode is a misnomer. It's really Attributes:
d is a directory, a is the archive bit set, r is read-only, s is system, h is hidden, etc.
Why this fails on the a entry suggests that your task to upload is only looking at directories and not files at that folder level. Would need to see more to say more.

How to view coverage report in HTML format for flutter/dart on windows

I'm write a unit test for my flutter project.
Next, i'm run test by command:
flutter test --coverage
This command run the test and create lcov.info file with coverage data.
SF:lib\cc_tracker.dart
DA:5,0
DA:7,2
DA:9,2
DA:11,2
DA:12,2
LF:5
LH:4
end_of_record
SF:lib\cc_data.dart
DA:2,0
LF:1
LH:0
end_of_record
SF:lib\cc_list.dart
DA:8,2
DA:10,2
DA:17,2
DA:19,2
DA:20,2
DA:23,2
DA:24,2
DA:25,2
DA:28,2
DA:29,0
DA:30,2
DA:35,2
DA:36,4
DA:37,4
DA:38,0
DA:39,0
DA:40,0
DA:41,0
DA:43,0
DA:44,0
DA:45,0
DA:47,0
DA:49,0
DA:50,0
DA:55,2
DA:56,4
DA:57,0
DA:58,0
DA:59,0
DA:60,0
DA:62,0
DA:63,2
DA:66,2
DA:68,2
DA:69,2
LF:35
LH:19
end_of_record
Does everyone convert it in practice to html report on windows environment?
In theory, there is a perl scripts (lcov.perl, genhtml.perl, ...). But genhtml isn't working on windows powershell. Its generate output in coverage/html/index.html:
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 10.03.2020 16:34 -p
d----- 10.03.2020 16:34 root
-a---- 11.03.2020 19:03 141 amber.png
-a---- 11.03.2020 19:03 141 emerald.png
-a---- 11.03.2020 19:03 10404 gcov.css
-a---- 11.03.2020 19:03 167 glass.png
-a---- 10.03.2020 16:34 4236 index-sort-b.html
-a---- 10.03.2020 16:34 4236 index-sort-f.html
-a---- 10.03.2020 16:34 4236 index-sort-l.html
-a---- 10.03.2020 16:34 4243 index.html
-a---- 11.03.2020 19:03 141 ruby.png
-a---- 11.03.2020 19:03 141 snow.png
-a---- 11.03.2020 19:03 117 updown.png
But content of report is empty:
Please, let me practical advice to this problem. Thanks!
On Windows: Try to replace backslash character ("\") with slash character ("/") in all file path lines (prefixed with "SF:") in the lcov.info file and then run genhtml.perl script. It should help (It helped me, at least).

How do I start SourceTree 2 from the command line on Windows?

SourceTree 2.0 is substantially different from SourceTree 1 in that it uses a rolling release model - eg:
$ ls $env:LOCALAPPDATA\sourcetree
Directory: C:\Users\mike\AppData\Local\sourcetree
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 27/04/2017 17:12 app-2.0.19.1
d----- 09/05/2017 10:44 app-2.0.20.1
d----- 09/05/2017 10:44 packages
-a---- 08/05/2017 16:25 3225 SquirrelSetup.log
-a---- 18/04/2017 23:51 1518408 Update.exe
So there's no static directory for SourceTree executables anymore.
Previous versions of SourceTree included an 'stree' command but the 'Install Command Line Tools' option but this is MacOS only.
How do I start SourceTree 2 from the command line on Windows?
Got it. As Steve Streeting mentions here you can get the current path the active version of SourceTree 2 from the registry.
Combining that with some powershell gives:
function stree {
$SourceTreeCommand = (Get-ItemProperty HKCU:\Software\Classes\sourcetree\shell\open\command).'(default)'.split()[0].replace('"','')
& $SourceTreeCommand -f .
}

vscode install failed with "install failed error" on windows7

I try to install vscode on windows7 and get "install failed error", no detailed information, is there someone get the same error? It is crazy that vscode can not be installed on windows.
Use something like 7Zip to extract the archived files to a VSCodeSetup folder, with the resulting files:
Mode LastWriteTime Length Name
---- ------------- ------ ----
----- 4/22/2015 8:28 AM 140782 background.gif
----- 4/27/2015 6:22 PM 60255967 Code-0.1.0-full.nupkg
----- 4/27/2015 6:22 PM 74 RELEASES
-a--- 4/30/2015 9:25 AM 1911 SquirrelSetup.log
----- 4/24/2015 11:12 AM 1492992 Update.exe
Then open PowerShell (a CMD window would also work). I cd'd into the VSCodeSetup folder and ran the following command:
PS>.\Update.exe --install=.
(You may need to run PS or the CMD window as Administrator)
Referenced post: VSCode Installation Failed - Failed to extract installer