manually executing script on cygwin works but not remote - cygwin

I am trying to figure out what exactly an issue is, below is the step i am trying :
on Windows 2019, installed cygwin64, directly from cygwin terminal, executing beloow "configure" script works fine, below is the configure command :
bash configure --with-freetype=bundled --with-tools-dir=/cygdrive/c/progra~2/micros~1/2017/Enterprise/VC/Tools/ --with-boot-jdk=/cygdrive/c/jdk-10.0.2/ --with-jtreg=/cygdrive/c/jtreg-5.1-b01/ --with-version-pre=sncmid --with-version-build=$build --with-version-opt=
However when i automate using jenkins which will execute on windows slave node, it is failing with this below
configure: Found potential Boot JDK using configure arguments
configure: Potential Boot JDK found at /cygdrive/c/jdk-10.0.2/ is incorrect JDK version (Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8); ignoring
configure: (Your Boot JDK version must be one of: 10 11)
configure: error: The path given by --with-boot-jdk does not contain a valid Boot JDK
configure exiting with result code 1
Wondering why the difference between "direct execute on cygwin works fine" and "from jenkins job" where i called using "c:\cygwin64\bin\bash.exe -l script.sh" this script.sh executes configure script.
Invocation of the script
c:\cygwin64\bin\bash.exe -l '%WORKSPACE%\script.sh' %BUILD_NUMBER% /cygdrive/c/openjdk11windows
content of script.sh:
#!/bin/bash
echo $1
build=$1
source ~/.bash_profile
source ~/.bashrc
bash configure --with-freetype=bundled --with-tools-dir=/cygdrive/c/progra~2/micros~1/2017/Enterprise/VC/Tools/ --with-boot-jdk=/cygdrive/c/jdk-10.0.2/ --with-jtreg=/cygdrive/c/jtreg-5.1-b01/ --with-version-pre=sncmid --with-version-build=$build --with-version-opt=
If any one has idea about this, please share.

Related

Running xjc command for Java 11-works in git bash but not cygwin

Interesting issue. I'm working on a Java 11 upgrade and ran into a problem running XJC locally. As XJC is no longer part of the JDK I've downloaded our own XJC and the needed jaxb libraries. However, when I run it locally via Cygwin it errors stating that it 'Could not find or load main class com.sun.tools.xjc.XJCFacade'. After some debugging I pulled out the command being run which produces the error, but with a minor change it works in Git Bash. I'm trying to figure out why it works in Git Bash but not Cygwin (in Windows, as it works on my Linux VM), to maybe gain some insight into what to fix.
XJC works successfully on Linux VM (so I know the script is valid)
Command (listed below) works with Git Bash on Windows 10 with Java 11
Commands (listed further below) FAIL in Cygwin on Windows 10 with Java 11
Working Git command
/c/Programs/Amazon_Corretto/jdk11.0.5_10/bin/java -cp /c/Programs/jaxb-ri/lib/jaxb-xjc.jar:/c/Programs/jaxb-ri/lib/jakarta.xml.bind-api.jar:/c/Programs/jaxb-ri/lib/jaxb-impl.jar:/c/Programs/jaxb-ri/lib/jaxb-jxc.jar:/c/Programs/jaxb-ri/lib/jakarta.activation.jar com.sun.tools.xjc.XJCFacade -xmlschema /c/Development/Project_Folder/path/to/some/code/filename.xsd -d /c/Development/Project_Folder/path/to/some/code
Failed attempts with Cygwin
/cygdrive/c/Programs/Amazon_Corretto/jdk11.0.5_10/bin/java -cp /c/Programs/jaxb-ri/lib/jaxb-xjc.jar:/c/Programs/jaxb-ri/lib/jakarta.xml.bind-api.jar:/c/Programs/jaxb-ri/lib/jaxb-impl.jar:/c/Programs/jaxb-ri/lib/jaxb-jxc.jar:/c/Programs/jaxb-ri/lib/jakarta.activation.jar com.sun.tools.xjc.XJCFacade -xmlschema /c/Development/Project_Folder/path/to/some/code/filename.xsd -d /c/Development/Project_Folder/path/to/some/code
/cygdrive/c/Programs/Amazon_Corretto/jdk11.0.5_10/bin/java -cp /cygdrive/c/Programs/jaxb-ri/lib/jaxb-xjc.jar:/cygdrive/c/Programs/jaxb-ri/lib/jakarta.xml.bind-api.jar:/cygdrive/c/Programs/jaxb-ri/lib/jaxb-impl.jar:/cygdrive/c/Programs/jaxb-ri/lib/jaxb-jxc.jar:/cygdrive/c/Programs/jaxb-ri/lib/jakarta.activation.jar com.sun.tools.xjc.XJCFacade -xmlschema /cygdrive/c/Development/Project_Folder/path/to/some/code/filename.xsd -d /cygdrive/c/Development/Project_Folder/path/to/some/code
/cygdrive/c/Programs/Amazon_Corretto/jdk11.0.5_10/bin/java -cp /c/Programs/jaxb-ri/lib/jaxb-xjc.jar:/c/Programs/jaxb-ri/lib/jakarta.xml.bind-api.jar:/c/Programs/jaxb-ri/lib/jaxb-impl.jar:/c/Programs/jaxb-ri/lib/jaxb-jxc.jar:/c/Programs/jaxb-ri/lib/jakarta.activation.jar com.sun.tools.xjc.XJCFacade -xmlschema /cygdrive/c/Development/Project_Folder/path/to/some/code/filename.xsd -d /cygdrive/c/Development/Project_Folder/path/to/some/code
So I have identified the issue being the pathing format.
After alot of trial and error and some brainstorming I figured out the path for the jar files must be in Windows format with a semi-colon delimiter. Somehow during my trials I ended up using a Windows path with ':' delimiter, and later when I correctly used both Windows format and semi-colon delimiter I was using the 'cygpath -w' which is not needed.
So
"java -cp "C:\Program File\Path\jaxb-xjc.jar;C:\Program File\Path\jaxb-impl.jar..." com.sun.tools.xjc.XJCFacade.

Where is the `sdk` command installed for sdkman

I just installed sdkman for installing grails on my machine (MacOS). When I run which sdk command I don't get any output. But when I run the sdk help command the shell is able to resolve it and give the right output. I checked all the directories mentioned in $PATH environment variable but I could not find any executable sdk. So my question is how is shell able to resolve the sdk command?
Note: I also checked in Ubuntu and I see the same behavior.
As you mentioned correctly "sdk" is not a command, its a declared function created by sdkman-main.sh (in ~/.sdkman/src) once called from ~/.sdkman/bin/sdkman-init.sh
This is the reason why the installation page of sdkman asks for appending the following steps in the .bash_profile which declares this function each time the bash profile is loaded :
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
[[ -s "/home/dudette/.sdkman/bin/sdkman-init.sh" ]] && source "/home/dudette/.sdkman/bin/sdkman-init.sh"
This is also the reason "which" command doesn't pick it up as it checks for the installed commands on the linux PATH
OK. So I found it out. As #that-other-guy mentioned in the comment above, I used type -a instead of which, which showed me that it was a function defined.

Linux executable on cygwin terminal [duplicate]

This question already has answers here:
Executable file generated using GCC under cygwin
(5 answers)
Closed 7 years ago.
Let me tell you my problem. I've a shell script which execute a Linux executable. I don't have access to the source code of this exe.
When I run the script on the Linux machine, there is no problem.
But, if I try to run the script on my Windows laptop, using cygwin, I have the error "cannot execute binary file".
There is any solution ?
Thanks !
From https://stackoverflow.com/a/4144536/5704102:
"... Cygwin is a compatibility layer, which aims to implement as much as possible of the POSIX and Linux APIs within Windows. This means that programs have to be compiled specifically for Cygwin ..."
What does this script look like? Is it a bash script? If so, you may want to try sh <scriptfile> in Cygwin. If this doesn't work, and it is a bash script, make sure you have sh.exe. Type sh and hit tab twice to check.
Another potential issue if it is a bash script is that you don't have something installed that Cygwin requires to run the script. Make sure all the commands the script is trying to run will work. If not, you may have to run the Cygwin installer and install whatever is needed to run the script.
Also, you may want to check permissions.
If the file has an exe extension, it SHOULD work on Windows unless it was compiled for 64 bit architecture and you're running a 32 bit OS. Otherwise, you could be missing some .dll files that the executable relies on.
Edit:
If this is the contents of your script:
echo START
/oper/file.exe
then it's likely you have the incorrect path. Cygwin paths typically start with /cygdrive/c/ in Windows. Go to where the file exists and type pwd to get the correct path, then modify your script accordingly.
Content of Script.sh in oper folder :
echo START
/cygdrive/c/Users/jo/oper/file.exe
In Cygwin terminal (in the right folder):
sh Script.sh
(Path updated)

ERROR: executing command 'ant' - After installation and setting ANT_HOME

After wrestling with my environment variables to get the proper directory set, I can now get the version with:
C:\Projects\TestProj>ant -version
Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ant appears to be working:
C:\Projects\TestProj>ant
Buildfile: build.xml does not exist!
Build failed
I still get the error when I try:
C:\Projects\TestProj>cordova -d platform add android
cordova library for "android" already exists. No need to download. Continuing.
Checking if platform "android" passes minimum requirements...
Creating android project...
Running command: C:\Users\Administrator\.cordova\lib\android\cordova\3.4.0\bin\c
reate.bat --cli C:\Projects\TestProj\platforms\android com.company.testproj
TestProj
C:\Users\Administrator\.cordova\lib\android\cordova\3.4.0\bin\node_modules\q\q.j
s:126
throw e;
^
Error: ERROR : executing command 'ant', make sure you have ant installed and add
ed to your path.
From all of the posts that I have read, this is an issue with ANT_HOME, but it appears I have that part of it tackled. Edit I've installed ant 1.9.3 to program files, and bin resides in:
EDIT Changed to just ant, instead of apache-ant-1.9.3-bin\apache-ant-1.9.3
C:\Program Files\ant
Echo home:
C:\Projects\TestProj>echo %ANT_HOME%
C:\Program Files\ant
And of course I have %ANT_HOME%\bin in my path. Any help identifying the issue would be appreciated.
I think the path you use for ANT_HOME is wrong. C:\Users\Administrator\AppData\Roaming\npm\node_modules\ant\ant seems to be the path to the ant npm module but not the ant command.
Ant command more probably is somewhere in program files. In a cmd, run where ant to know where in your path ant is found and use this path for ANT_HOME. (in the folder you should see ant, ant.cmd and ant.bat)
After further investigation, I think your problem is caused half by cordova not correctly checking node errors and half because of registry setting in your computer (a cmd autorun parameter).
You can check answers in those posts for more info:
nodejs child_process exec 'java -version'
Windows CMD.exe "The system cannot find the path specified."
Check if you have a registry key HKCU\Software\Microsoft\Command Processor\AutoRun
after setting the variables, restart your machine. Closing command prompt etc will not help.
Even I was stuck for quite a long time and next day when I started my system, it was working fine :P

How to detect whether tomcat and ant are installed on linux machine

I am trying to install Tomcat and Ant on my linux machine, but before installing them i just need to check whether they are already installed or not.
Regarding tomcat:
I googled a lot and searched on my machine in the following directories for tomcat
/usr/local/, /opt/, /usr/share/
but i din't find tomcat folder in any of the above path, whether it indicates that tomcat is not installed ? so actually
1. what is the path to `look/find` exactly to know/check whether tomcat is installed or not in
all linux machines
2. what will be the path the tomcat will be installed exactly after installation
3. How to find the version of tomcat on any linux machine (if tomcat already installed)
4. Whether there are any commands to look for both whether `tomcat` installed and `ant`
installed
Regarding Ant:
I googled and got the below command due to which i got the below result after executing
it
sh-4.2$ ant -v
result
sh-4.2$ ant -v
Apache Ant(TM) version 1.8.2 compiled on November 21 2011
Trying the default build file: build.xml
Buildfile: build.xml does not exist!
Build failed
so actually
1. Does the above result mean that `Ant` is installed ? or not ?
2. what is the path to `look/find` exactly to know/check whether ant is installed or not in
all linux machines
3. what will be the path the `ant` will be installed exactly after installation
4. How to find the version of `Ant` on any linux machine (if Ant already installed)
Generally, you can check whether they are on the $PATH, if they are not on the $PATH, install one.
For ant:
ant -v stands for verbose, ant -version prints out its version.
-help, -h
print help on the command line options
-projecthelp, -p
gives information on possible targets for this project
-version
prints the version number and then exits ant
-quiet, -q
be extra quiet
-verbose, -v
be extra verbose
-debug, -d
print debugging information
-emacs, -e
produce logging information without adornments
-logfile <file>, -l <file>
use the given file to output log to
-logger <classname>
the class which is to perform logging
-listener <classname>
add an instance of the given class as a project listener
-noinput
do not allow interactive input
-buildfile <file>, -file <file>, -f <file>
use the given buildfile instead of the default build.xml file.
This is the ant equivalent of Makefile
-D<property>=<value>
use value for the given property
-keep-going, -k
execute all targets that do not depend on failed target(s)
-propertyfile <file>
load all properties from file with -D properties taking prece-
dence
-inputhandler <class>
the class which will handle input requests
-find <file>, -s <file>
(s)earch for buildfile towards the root of the filesystem and
use it
-nice number
A niceness value for the main thread: 1 (lowest) to 10 (high-
est); 5 is the default
-nouserlib
Run ant without using the jar files from ${user.home}/.ant/lib
-noclasspath
Run ant without using CLASSPATH
-autoproxy
Java 1.5+ : use the OS proxies
-main <class>
override ant's normal entry point
For tomcat:
if tomcat/bin is on the $PATH variable, version.sh will print out the version.
For linux ubuntu 18.04:
Go to terminal and command:$ sudo systemctl status tomcat
This command also show is tomcat running or not (if already installed)

Resources