I'm having troubles with an application written in Java and built with gradle on Monterey.
I can build it and make a package to install it on macOS. After the installation I can see the right Icon in the Applications folder, but everytime I try to run it this dialog come out:
I think I tried everything to make it work on this OS.
On every other version of MacOS it works well.
I thought the problem could be regarding some permission, so I allowed permissions to every application like this:
but it still doesn't work.
Tried to run it via Terminal but I'm having this error:
The application cannot be opened for an unexpected reason, error=Error
Domain=NSOSStatusErrorDomain Code=-10810 "kLSUnknownErr: Unexpected internal error"
UserInfo={_LSFunction=_LSLaunchWithRunningboard, _LSLine=2732,
NSUnderlyingError=0x600000d3ecd0 {Error Domain=RBSRequestErrorDomain Code=5 "Launch
failed." UserInfo={NSLocalizedFailureReason=Launch failed.,
NSUnderlyingError=0x600000d3e520 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or
directory" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}}}
and I didn't find a solution for this.
I thought it could be a problem of signature of the application or something like that, but trying with these commands in a Teminal to find a solution of any type it still doesn't run.
codesign -v "MyApp.app"
codesign -s "MyCompany" MyApp.app
sudo xattr -r -d com.apple.quarantine MyApp.app
sudo chmod -R 755 MyApp.app
sudo codesign --force --deep --sign - MyApp.app
sudo xattr -d -r com.apple.quarantine /Applications/MyApp.app
Nothing happened and I'm at the starting situation of not working app on Monterey.
It's not a problem of Intel or M1 chip.
What could be the solution to this problem?
I searched all internet but didn't find a solution for this.
Thank you for the help.
On asking java -version -
java -version
bash: /home/user/jdk-8u221-linux-x64/jdk1.8.0_221/bin/java: Permission denied
it says permission denied , but on using sudo it gives.
Due to which intelliJ is also not able to build project .
How to get access or how do I provide priveleg to the user
also showing problem in intellij -
You could try this command
sudo chmod a+x /usr/bin/java
I have a script called foo.sh in my home folder.
When I navigate to this folder, and enter ./foo.sh, I get
-bash: ./foo.sh: Permission denied.
When I use sudo ./foo.sh, I get
sudo: foo.sh: command not found.
Why does this happen and how I can fix it?
Permission denied
In order to run a script the file must have an executable permission bit set.
In order to fully understand Linux file permissions you can study the documentation for the chmod command. chmod, an abbreviation of change mode, is the command that is used to change the permission settings of a file.
To read the chmod documentation for your local system , run man chmod or info chmod from the command line. Once read and understood you should be able to understand the output of running ...
ls -l foo.sh
... which will list the READ, WRITE and EXECUTE permissions for the file owner, the group owner and everyone else who is not the file owner or a member of the group to which the file belongs (that last permission group is sometimes referred to as "world" or "other")
Here's a summary of how to troubleshoot the Permission Denied error in your case.
$ ls -l foo.sh # Check file permissions of foo
-rw-r--r-- 1 rkielty users 0 2012-10-21 14:47 foo.sh
^^^
^^^ | ^^^ ^^^^^^^ ^^^^^
| | | | |
Owner| World | |
| | Name of
Group | Group
Name of
Owner
Owner has read and write access rw but the - indicates that the executable permission is missing
The chmod command fixes that. (Group and other only have read permission set on the file, they cannot write to it or execute it)
$ chmod +x foo.sh # The owner can set the executable permission on foo.sh
$ ls -l foo.sh # Now we see an x after the rw
-rwxr-xr-x 1 rkielty users 0 2012-10-21 14:47 foo.sh
^ ^ ^
foo.sh is now executable as far as Linux is concerned.
Using sudo results in Command not found
When you run a command using sudo you are effectively running it as the superuser or root.
The reason that the root user is not finding your command is likely that the PATH environment variable for root does not include the directory where foo.sh is located. Hence the command is not found.
The PATH environment variable contains a list of directories which are searched for commands. Each user sets their own PATH variable according to their needs.
To see what it is set to run
env | grep ^PATH
Here's some sample output of running the above env command first as an ordinary user and then as the root user using sudo
rkielty#rkielty-laptop:~$ env | grep ^PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
rkielty#rkielty-laptop:~$ sudo env | grep ^PATH
[sudo] password for rkielty:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
Note that, although similar, in this case the directories contained in the PATH the non-privileged user (rkielty) and the super user are not the same.
The directory where foo.sh resides is not present in the PATH variable of the root user, hence the command not found error.
The other solutions I've seen here so far are based on some system definitions, but it's in fact possible to have sudo use the current PATH (with the env command) and/or the rest of the environment (with the -E option) just by invoking it right:
sudo -E env "PATH=$PATH" <command> [arguments]
In fact, one can make an alias out of it:
alias mysudo='sudo -E env "PATH=$PATH"'
(It's also possible to name the alias itself sudo, replacing the original sudo.)
Check for secure_path on sudo
[root#host ~]# sudo -V | grep 'Value to override'
Value to override user's $PATH with: /sbin:/bin:/usr/sbin:/usr/bin
If $PATH is being overridden use visudo and edit /etc/sudoers
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
Check that you have execute permission on the script. i.e. chmod +x foo.sh
Check that the first line of that script is #!/bin/sh or some such.
For sudo you are in the wrong directory. check with sudo pwd
You can also create a soft link to your script in one of the directories (/usr/local/bin for example) in the super user PATH. It'll then be available to the sudo.
chmod +x foo.sh
sudo ln -s path-to-foo.sh /usr/local/bin/foo
Have a look at this answer to have an idea of which directory to put soft link in.
It seems that linux will say "command not found" even if you explicitly give the path to the file.
[veeam#jsandbox ~]$ sudo /tmp/uid.sh;echo $?
sudo: /tmp/uid.sh: command not found
1
[veeam#jsandbox ~]$ chmod +x /tmp/uid.sh
[veeam#jsandbox ~]$ sudo /tmp/uid.sh;echo $?
0
It's a somewhat misleading error, however it's probably technically correct. A file is not a command until its executable, and so cannot be found.
Try chmod u+x foo.sh instead of chmod +x foo.sh if you have trouble with the guides above. This worked for me when the other solutions did not.
Regarding "command not found" when using sudo far less hackier way would be to edit secure_path.
It is perfectly described here:
https://superuser.com/questions/927512/how-to-set-path-for-sudo-commands
Ok this is my solution:
in ~/.bash_aliases just add the following:
# ADDS MY PATH WHEN SET AS ROOT
if [ $(id -u) = "0" ]; then
export PATH=$PATH:/home/your_user/bin
fi
Voila!
Now you can execute your own scripts with sudo or set as ROOT without having to do an export PATH=$PATH:/home/your_user/bin everytime.
Notice that I need to be explicit when adding my PATH since HOME for superuser is /root
If you are not so comfortable with the command line and are using Ubuntu you can solve the problem as follows:
Open the folder window where the file is located
Right click on the executable file and choose Properties
Go to the Permissions tab and highlight Allow executing file as program
With this solution you allow the user to execute the file as a program and you don't need sudo (or change the PATH environment variable for root).
It seems sudo command not found
to check whether the sudo package is installed on your system, type sudo , and press Enter . If you have sudo installed the system will display a short help message, otherwise you will see something like sudo: command not found
To install sudo, run one of the following commands using root account:
apt-get install sudo # If your system based on apt package manager
yum install sudo # If your system based on yum package manager
I have multiple app apks downloaded into my laptop. I want to use java to write a script, so that all apks can be installed to my device automatically. Anybody can help me out with this?
Thanks!
if you are Using Linux
#!/bin/sh
for file in /dir/*
do
adb install $file
done
you can install using adb like
adb install application1.apk & adb install application2.apk & adb install applicaiton3
you can install using
for %f in (D:\Directory\*.apk) do adb install "%f"
using MAC
for file in apk/*;
do
./adb install $file;
done
and a final solution using batch file created By Osman Vielma
#echo Preparing to install all .apk files in "C:\Directory\" folder to device
#pause
#for /f "delims=|" %%f in ('dir /b "C:\Directory\"*.apk') do #"C:\Directory_ADB\ADB\adb.exe" install -r "C:\Directory\%%f"
#echo End of Batch File
#pause
I'm trying to run chimpchat from Java code and I get this error:
Unexpected exception 'Cannot run program
"/home/asco/adt-bundle-linux-x86_64/sdk/platform-tools": error=13,
Permission denied' while attempting to get adb version from
'/home/asco/adt-bundle-linux-x86_64/sdk/platform-tools
I can run adb from the shell as a normal user. I've chmod 777'ed the adb program.
What can I do? I run Linux Mint 14 (64bit) (have ia32-libs installed) and use java7-openjdk-amd64.
When I tried to open the Android SDK from Eclipse I also received the error
"...Permission denied' while attempting to get adb version from '..."
initially, I tried
sudo apt-get install ia32-libs
but it did not fix the problem. i had them already.
What fixed the problem was
sudo chmod -R 777 /name-of-root-directory-containing-SDK
Recommendation! Place SDK, JDK and all other manually installed non-system resources in their own root directory.
[ example: /resource ]
Permissions set on this directory make no change to any critical files.
Warning!
Erroneous use of chmod -R on system directories can lead to "must reinstall OS from scratch"
it then complains about not finding the adb program
you need to install ia32-libs package:
sudo apt-get install ia32-libs
The error is specifying the directory that contains adb, rather than the adb executable itself. Check the permissions on the directory, and that your program is attempting to run the proper command (it may be trying to run the directory, which clearly won't work...).