bash: mvn: command not found - macos

I've been trying to solve this for quite a while now, but nothing seems to work.
I need to run "mvn clean deploy -P release" from the Terminal in IntelliJ (on Mac).
But it keeps giving me the same error.
bash: mvn: command not found
I was able to run this command about 2 hours ago, but after closing and reopening IntelliJ, I am no longer able to run this command from the Terminal in IntelliJ.
Does anyone know why this happens and how I can fix this?

I figured it out: you have to press CMD + ENTER in IntelliJ for the command to work.

Related

When I use a terminal or zsh I can't run commands, And this is what appears: /dev/fd/14:18: command not found: compdef

When I use a terminal or zsh I can't run commands, And this is what appears:
# /dev/fd/14:18: command not found: compdef #
Does anyone know how to reset the terminal to normal mode?
I tried to solve it and the only thing that got my terminal back to normal is the elapsed time, but the problem is not solved because this line keeps repeating again, and then I'm stuck
I understood what the problem was, I just installed the latest version of Node js, and that's why I had this problem, when I reverted to a previous version it solved the problem
I had a similar situation today, and after looking up the information, it was the reason why I installed Angular

Interactive Grails and Git Bash

Is anyone using Grails with Git Bash successfully on Windows? I have installed Grails (3 different versions) via SDKMAN using Git Bash. I cannot get an interactive Grails terminal to work, though. I call 'grails', get the Grails prompt, but then when I try a command like 'clean', say, it never completes, it just hangs there. What is more, Ctrl-C doesn't abort the command either, I have to close the console window.
I have found something which appears to work for this. If I call 'winpty bash' first, then the command becomes properly interactive and no longer hangs.

Jenkins pipeline fails with error : "docker : permission deinied"

I'm trying to run my react & nodeJs project on jenkins with docker, to create CI/CD ability. at the moment I just want to make sure it works in the most simple way.
I had an error on the same location at the pipeline with message : "docker:not found"
I've solved it using "-v $(which docker):/usr/bin/docker" when starting jenkins.
Now - I understand I need permission for jenkins to use docker, and I found this terminal command line that should solve it: "usermod -G docker -a jenkins" and I get an error (on a Mac) : "zsh: command not found: usermod"
any help would be appreciated, to modify or replace this line, or another idea that might work. thanks !
Mac does not come with the passwd package that contains usermod. An alternative to managing user groups is described here. usermod equivalent in OSX

How to use IntelliJ bundled maven in terminal?

Using MacOS Catalina. Installed IntelliJ. Maven works fine but in terminal mvn comand is not found. How to use IntelliJs maven in terminal?
Locating mvn installed using IntelliJ
If you are specifically looking for mvn location, installed using IntelliJ on MacOS: /Applications/IntelliJ IDEA CE.app/Contents/plugins/maven/lib/mvn
Executing mvn from terminal
Now, if you want to execute mvn from terminal, you need to add to your path.
Assuming that you'are using zshrc, which is my case, you'll need to add the following command to ~/.zshrc
export PATH="$PATH:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin"
Now, reopen your terminal, and you can call mvn.
Obs.: Thanks to nbro's answer
Solving "Permission Denied"
If you try to execute mvn and get "Permission Denied", you need to give execution permission:
chmod +x "/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin/mvn"
In my case, I added the following 2 commands to ~/.zshrc (which is what I am using)
export PATH="/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin:$PATH"
# Otherwise we get a "permission denied"
chmod +x "/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin/mvn"
Now, I can call mvn from the terminal.
On linux (Ubuntu) when installed by toolbox, it might be something like this:
/home/<username>/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/211.7142.45/plugins/maven/lib/..
In Windows You may find Idea location by env variable
PS > Get-ChildItem env:"Intellij IDEA"
Name Value
---- -----
IntelliJ IDEA C:\Users\unknownuser\AppData\Local\JetBrains\IntelliJ IDEA 2020.3.4\bin;
then use M2_HOME env variable to store related maven path
C:\Users\unknownuser\AppData\Local\JetBrains\IntelliJ IDEA 2020.3.4\plugins\maven\lib\maven3
and use it in the path
%M2_HOME%\bin
Mine under windows is under a weird location:
C:\Users\changeMe\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\222.3345.118\plugins\maven\lib\maven3
Note that on Windows, from a Terminal console using CMD, you can execute mvn command using CTRL+Enter in IntelliJ :
As of the feature description under https://blog.jetbrains.com/idea/2020/07/run-ide-features-from-the-terminal/, this feature is also supported for MacOs with Cmd+Enter.
Run highlighted command using IDE (default shortcut: Ctrl + Enter or Cmd + Enter)
Debug highlighted command using IDE (default shortcut: Ctrl + Shift + Enter or Cmd + Shift + Enter)

Running ios-sim with Jenkins

I'm trying to start my app from the command line using ios-sim but this is what I get:
Started by user User
Building in workspace /Users/Shared/Jenkins/Home/jobs/UI Testing/workspace
[workspace] $ /bin/sh -xe /var/folders/h4/ws64t3bx2nnds4pg3345xrr000009c/T/hudson6341279754557259451.sh
+ /Users/myUser/Desktop/ios-sim launch /Users/Shared/Jenkins/Home/jobs/Project_Monkey_Build/workspace/build/Debug-iphonesimulator/ProjectMonkey.app
[DEBUG] Could not start simulator session: Error Domain=DTiPhoneSimulatorErrorDomain Code=5
"Operation failed with underlying error 4294956486." UserInfo=0x1001b1760
{NSLocalizedDescription=Operation failed with underlying error 4294956486.,
NSUnderlyingError=0x1001a3390 "The operation couldn’t be completed. (OSStatus error -10810.)"}
It looks like a permission problem as I can run the same command from terminal and it works fine. I've also tried to give full 777 permission to ios-sim and the MonkeyTalk directory,but still nothing.
Any idea?
It might be related to the Jenkins process not having a "display". Try running Jenkins as a user logged in to the desktop, then run the ios-sim again.
Unload Jenkins from launchd:
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
Then run Jenkins from a terminal:
sudo su jenkins -c "JENKINS_HOME=/Users/Shared/Jenkins/Home /Library/Application\ Support/Jenkins/jenkins-runner.sh"
If this works, you can make Jenkins always run as a logged in user by moving the launchd job config file from /Library/LaunchDaemons/org.jenkins-ci.plist to ~/Library/LaunchAgents/org.jenkins-ci.plist
I know this post was from a while ago, and not sure if anyone is checking it, but I also ran into this issue recently and it turned out that there was a duplicate app already in the iphone simulator creating an issue and not letting the new app run.
I reset the simulator and it then worked. I then added the applescript to reset the simulator each time before running ios-sim. this script can be found here...
How can I reset the iOS Simulator from the command line?
Scroll down the answer that has 13 up votes next to it, not the one that was checked marked.
Hope this helps someone in the future..
It looks like the only workaround it's to run the command as super user:
sudo /Users/myUser/Desktop/ios-sim launch /Users/Shared/Jenkins/Home/jobs/Project_Monkey_Build/workspace/build/Debug-iphonesimulator/ProjectMonkey.app
I was also facing the same problem and found that jenkins user is not correctly set up to run test case on simulator. Follow instruction given on below website:
http://pivotallabs.com/ios-ci-jenkins/
see the section "SETTING UP THE JENKINS USER".
hope it will work for you as well.

Resources