Android Studio: 'sudo' is not recognized as an internal or external command, operable program or batch file
Asked Answered
M

1

0

As a possible solution to my Android Studio "could not expand zip" problem, I would like to run this command from the Terminal window in Android Studio:

sudo chmod -R 777 /your/project/path

However, when I try it, I get this error:

'sudo' is not recognized as an internal or external command, operable program or batch file.

How to solve? (I am running Android Studio 2.1.2 on Windows 7.)

Marga answered 20/6, 2016 at 11:48 Comment(0)
N
3

sudo is a *nix utility, not something you'll find on Windows. Ditto chmod.

With that said, the command in question is just adjusting privileges on the project folder using a simple bitmask. From the chmod man page:

-R, --recursive change files and directories recursively
Numeric mode:

From one to four octal digits
Any omitted digits are assumed to be leading zeros.

The first digit = selects attributes for the set user ID (4) and set group ID (2) and save text image (1)S
The second digit = permissions for the user who owns the file: read (4), write (2), and execute (1)
The third digit = permissions for other users in the file's group: read (4), write (2), and execute (1)
The fourth digit = permissions for other users NOT in the file's group: read (4), write (2), and execute (1)

The octal (0-7) value is calculated by adding up the values for each digit

In your command, the first digit is missing so is assumed to be 0. The second, third and fourth are 7, which translates into read/write/execute access for the directory owner, anyone else in the file's group, and anyone else not in the file's group. The -R switch recursively applies those privileges to every file and folder within /your/project/path.

On Windows, the equivalent command is within Explorer. Navigate to /your/project (not /your/project/path) and right-click /path. Choose Properties and a properties dialog will appear. Switch to the Security tab within that dialog.

From here, there are a few ways you could do this. You could simply click your user account from the Group or user names list, hit the Edit button at the bottom of the list, and give yourself any missing privileges.

For a more thorough privilege adjustment, including the recursion your sudo command gives you, choose Advanced instead of Edit. A new dialog, Advanced Security Settings for /path, will appear. Press Change Permissions. The same dialog will reappear, but Change Permissions will be replaced by an Add button and an Edit button. At the bottom, there will be a checkbox labeled Replace all child object permissions with inheritable permissions from this object. Make sure that's checked - that's the -R. Now select your username from the list and choose Edit. Check every checkbox and hit OK. Keep hitting OK all the way back out of the dialogs. With any luck that will be enough to solve your permissions problem.

If you'd like a simpler fix, just run Android Studio as admin, as suggested by the accepted answer in your question. That's somewhat less likely to break things than manually adjusting permissions and is usually enough to work around permissions-related issues in the first place.

Also worth noting, the accepted answer suggests making sure you have write permissions on the android-sdk and Android Studio directories. Only the sudo answer suggests tweaking privileges on /your/project/path. For the sake of the answer I have focused on the Windows equivalent of the command you asked about; you may want to do similar privilege adjustment on android-sdk and Android Studio rather than just /your/project/path.

Finally, be sure android-sdk isn't installed in %PROGRAMFILES%, as write access can be a problem there:

Click Start > All Programs > Accessories , right-click Notepad , and click Run as administrator . For protection against malware, Windows 7 doesn't allow normal processes to change files in the Program Files folder.

Android Studio can safely be installed there, but android-sdk cannot.

Nuclear answered 20/6, 2016 at 12:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.