How to run PMD in bash - pmd

I'm currently trying to run PMD on git bash with the command "run.sh pmd -d -f -R" but I get an error saying 'Could not find or load main class net.sourceforge.pmd.PMD'. I've tried setting the classpath in the environment variable but still get the error. Does anyone know what the problem is ?

This seems to be a bug in the PMD run.sh script. It supports the cygwin environment, but the git bash environment doesn't seem to be a vanilla cygwin environment (although all required cygwin commands are there).
The script builds up the classpath. Since it runs under a cygwin-like environment, the classpath looks like "/c/pmd-bin-5.5.4/lib/pmd-core-5.5.4.jar:...". However, the Java Runtime runs under Windows (and not cygwin), so the path needs to be translated into "C:\pmd-bin-5.5.4\lib\pmd-core-5.5.4.jar;...". Note, that the Windows notation of paths are used (the drive letter and semicolon as path separator).
The script uses the uname command, to determine, whether it runs under a cygwin-like environment. It only checks for "CYGWIN". But git bash uses e.g. "MINGW64_NT-10.0".
There is the new issue #305 now, it should be fixed soon.
You can manually fix the script bin/run.sh, by changing the function is_cygwin to:
is_cygwin() {
case "$(uname)" in
CYGWIN*|MINGW*) # look also for MINGW!!
readonly cygwin=true
;;
esac
# OS specific support. $var _must_ be set to either true or false.
if [ -z ${cygwin} ] ; then
readonly cygwin=false
fi
}

Related

VS Code works in one WSL but not in other

So I have two WSLs (version 2). Kali and Ubuntu. The code command works in Kali but Ubuntu says Command not found. Since it works in WSL, CMD and PowerShell, it is there in PATH variables. Any help?
edit: Ubuntu doesn't read VS Code in PATH variables, while Kali does. I opened the Environment Variables Wizard. VS Code is there.
In a "normal" case, like you are seeing in your Kali instance, WSL's init appends the Windows path to your Linux path. There are two things that I can think of that would cause that to not be happening correctly under your Ubuntu instance:
You or a script that you ran in Ubuntu modified your shell's startup files (assuming Bash, typically ~/.bashrc or ~/.profile) to edit the PATH, possibly removing the Windows elements, or at least the VSCode element.
Try running that instance without any Bash startup files (from PowerShell or CMD) with:
PS> wsl -d Ubuntu -e bash --noprofile --norc
and then try code .. This, of course, assumes that your Ubuntu instance is named Ubuntu. If it's named something else (wsl -l) then edit the -d Ubuntu as needed. You might also try launching it as wsl -d Ubuntu -e sh -c 'code .'
If that works, examine your startup files for any modifications to PATH.
Less likely (because you should know if you did this one), is that you can disable the WSL feature that appends the Windows PATH in a particular distribution/instance. Check for the existence of a /etc/wsl.conf file -- If it exists, the line appendWindowsPath=false would cause the behavior that you are seeing as well. Simply change the offending setting to true. Exit your Ubuntu instance, run wsl --terminate Ubuntu (again, substituting the correct distro name) and then restart. Check your PATH and try code . again then.

Set global environment variables in VS Code with remote-ssh

I have the case that I need to use VS Code installed on Windows 10 and run it with the extension Remote - SSH on a RHEL 7.x.
The default RHEL 7.x runs with git 1.8.x. I have installed a newer git version but this is not in the default $PATH environment.
I have found this instructions https://code.visualstudio.com/docs/remote/wsl#_advanced-environment-setup-script which describe how to set the environment variables specifically for VS Code when usind WSL.
If you want to run additional commands or modify the environment this can be done in a setup script ~/.vscode-server/server-env-setup
This does seem to work only if you use WSL. Why does this not work with the Remote - SSH extension?
My special case is that I only want and need the git>=2 while usind VS Code. When I am connected regularly via ssh I would like and need the OS default tools and settings.
This gives me the special request that I don't want to edit the ~/.bashrc, ~/.cshrc or any other user environment files.
I would like to be able to edit the environment for VS Code only. Some kind, maybe like:
#!/bin/bash
export PATH=/opt/rh/rh-git29/root/usr/bin\:$PATH
export LD_LIBRARY_PATH=/opt/rh/httpd24/root/usr/lib64:$LD_LIBRARY_PATH
...
#!/bin/csh
setenv PATH /opt/rh/rh-git29/root/usr/bin\:$PATH
setenv LD_LIBRARY_PATH /opt/rh/httpd24/root/usr/lib64:$LD_LIBRARY_PATH
...
Is there anything I have not found yet where I can make my requests to work or would this be some kind of request to the VS Code Team?
Regards.
I think I found the solution in this issue comment and the follow-up response:
When vscode-server initially starts, it uses a login shell, sourcing .profile in your home directory.
However, any following interactive shells started through VS Code are non-login shells and thus only source .bashrc
A complication in fiddling with this is that vscode-server apparently caches the environment during its lifetimes, so changes to these dotfiles don't become visible until the server is restarted.
I have a better solution to minimize the proxy scope
export http_proxy=<proxy here>
export no_proxy=<no proxy here>
while IFS= read -r _file; do
if ! grep -s -q "export http_proxy=" "${_file}"; then
sed -i -e "/^ROOT/i export http_proxy=${http_proxy}" -e "/^ROOT/i export https_proxy=${http_proxy}" -e "/^ROOT/i export no_proxy=${no_proxy}" "${_file}"
fi
done < <(find ~/.vscode-server/bin -type f -name "server.sh")

Pyenv activate does not run activate script with Fish Shell

My pyenv is working just fine, but it does not seem to be running my activate script located at /usr/local/var/pyenv/versions/project/bin/activate.fish
When activating my environment it gives the following output, but it does not echo anything from the activate script, which indicates that it is not running.
dani#localhost ~/d/project> pyenv activate project
pyenv-virtualenv: prompt changing not working for fish.
Of course I can just source the file manually, but I'm too eager to find out why it is not running. Is there some kind of debug mode? I'm not sure how to approach.
Actually,
Virtual environment is activated but the message just says that your prompt wasn't changed. Updating prompt was intentionally removed from fish shell.
you can find detailed information here;
https://github.com/pyenv/pyenv-virtualenv/issues/153
If you want to see virtual environment is really activated or not,
run the following command;
pyenv which python
it should print something like;
.pyenv/versions/{your-virtual-env}/bin/python
try this:
set PYENV_ROOT $HOME/.pyenv
set -x PATH $PYENV_ROOT/shims $PYENV_ROOT/bin $PATH
pyenv rehash

Updating environmental variables in Visual Studio Code on Linux

I changed the environmental variable LD_LIBRARY_PATH from the Ubuntu terminal (because I was receiving an error) and the changes were applied when I ran code (a Python code) from the terminal. But when I ran the same script from the Visual Studio Code, the error remains. How to update the environmental variable so that Visual Studio Code sees it, as well?
Environment variables are passed from parent process to child process; they are not (say) global to the system or the user. If you change a variable in one shell, the change is only seen in that shell and any processes started from that shell. So the simplest solution is to change the variable and then start VSCode from that same shell:
$ export LD_LIBRARY_PATH=/some/useful/path
$ code
If you want to keep using that shell for other things, run it in the background:
$ code >/dev/null 2>&1 &
The redirection to /dev/null is needed because otherwise VSCode prints logging information periodically, and that output will be mixed with whatever else you're doing.
If you want to set the variable permanently, see the question How do I set a user environment variable? (permanently, not session). After following those instructions, you'll need to start a new shell (and possibly even logout and login) first so the settings take effect. Then launch VSCode from the new shell.

How to get JBoss 7.1.3 to use my $JAVA_HOME environment varaible?

I'm using Mac 10.9.5 with JBoss 7.1.3.Final. I am launching JBoss through the termianl (bash shell), like so
Daves-MacBook-Pro:core davea$ cd $JBOSS_HOME/bin
Daves-MacBook-Pro:bin davea$ sudo sh standalone.sh
Within the shell, I can see that $JAVA_HOME is defined ...
Daves-MacBook-Pro:bin davea$ echo $JAVA_HOME
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
However, JBoss is not picking up this environment variable (it is using a Java 8 installation that I also have on my machine), forcing me to uncomment the following line in my $JBOSS_HOME/bin/standalone.conf file ...
JAVA_HOME="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home"
Although this is straightforward, I would prefer a solution that is more automatic. Does anyone know what I have to do to get JBoss to recognize the $JAVA_HOME environment variable I have set in my shell without my having to hard-code the value in a Jboss config?
Edit:
(In response to the commnent posted) Keep in mind I’m doing all this from the same shell. So here is where I have shown I have the $JAVA_HOME environment var defined …
Daves-MacBook-Pro:bin davea$ echo $JAVA_HOME
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Then I edit my $JBOSS_HOME/standalone/bin/standalone.conf file in the way you suggest …
echo JAVA_HOME=$JAVA_HOME
echo "DONe with echo"
#JAVA_HOME="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home"
and when I re-run the startup script, this is what prints out …
JAVA_HOME=
DONe with echo
If you really want to use sudo, you have to add the -E parameter to preserve the environment variables.