Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When I start Eclipse from the Unity launcher I get this message:

Could not find the folder 'tools' inside SDK '/home/engine/android-sdks/'

But when I type in the terminal

sudo eclipse

it works properly, and after running

sudo chown -R $USER:$USER ~

I got this:

/home/engine/.gvfs : Permission denied

after that I tried :

engine@Engine:~$ ls -al /home/engine/android-sdks/

and I got this :

total 36
drwxrwxr-x  5 engine engine  4096 Jul 31 22:17 .
drwx------ 57 engine engine 20480 Aug 11 10:26 ..
drwxrwxr-x  2 engine engine  4096 Jul 31 22:17 add-ons
drwxrwxr-x  2 engine engine  4096 Jul 31 22:17 platforms
drwxrwxr-x  2 engine engine  4096 Jul 31 22:17 temp

thanks Eliah Kagan

Is there any reason for this?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

There may be two things going on here:

  • Ownership: Files located in the user's home directory may be owned by root, when they should be owned by the user.

  • Location: Files may be located in root's home directory (/root) when they should be located in the user's home directory. (The OP figured this out, but accepted this answer, so I've augmented it to include this for the benefit of others experiencing this problem.)

Fixing Ownership

sudo eclipse runs Eclipse as root, but it still uses your (that is, not root's) home directory to save its files. Since it runs as root, files it creates are owned by root, and users other than root cannot access them. The result is that if you've run sudo eclipse once, Eclipse can only be run via sudo eclipse afterwards, until the problem is fixed.

This is not actually a permissions problem, it is an ownership problem, and the solution is to retake ownership on the affected files and folders. It's usually safe to be the owner of all the files inside your home folder. So, with Eclipse not running, run this command:

sudo chown -R $USER:$USER ~

$USER will be expanded by the shell to your username, so you can run that command exactly as-is. Alternatively, if you want to replace $USER with your actual username (in this case, engine), that works too.

How that command works:

  • chown is the command for changing ownership on files and directories.
  • ~ is shell shorthand for your home directory.
  • -R means it's not just changing ownership of your home directory, but that the operation is to apply recursively, to all files contained anywhere within your home directory.
  • The first $USER means you will be the owner of the files. The second $USER (after the :) means your user's group (the group created with your user account, to be the default group-owner of your files) will be the group owner.

For future reference:

  • If you must run a graphical application as root, you should use a graphical sudo frontend like gksu/gksudo or kdesudo. This sets the $HOME environment variable to /root--root's home directory. (It also makes a copy of ~/.Xauthority.)
  • However, it's best not to run complex applications like Eclipse or Firefox as root at all, for security reasons. Some graphical utilities must run as root to work, but Eclipse is not an administration tool, and you should never need to run it as root. If you do, something is wrong.

Fixing Location

As @Engine wrote:

The problem wasn't the whole directory, but only the folder /tools in android-sdks. I copied it from the root folder and then I gave my user the ownerships rights with:

chown -R $USER:USER ~

That is to say that, when eclipse had been run as root, it had (at least at some point) used root's home directory (not the user's home directory), and the Android SDK had been stored inside root's home directory.

  • Either that, or the Android SDK could have been manually installed as root beforehand.

For the benefit of others with this problem:

  • The tools folder can be copied from inside /root with:

    sudo cp -R /root/android-sdks/tools ~/android-sdks/
    
  • Or you can move the tools folder (rather than copying) with:

    sudo mv /root/android-sdks/tools ~/android-sdks/
    

Then fix ownership as described above. Or, just for the relocated tools folder, with:

sudo chown -R $USER:$USER ~/android-sdks/tools
share|improve this answer

Yes, I know this issue.

Check/change permissions for the folder. (Use 755.)

share|improve this answer
    
This is an ownership problem rather than a permissions problem. It might be possible to work around it by changing the permissions, but that would likely produce additional problems. Instead, ownership of the files should be changed back from root to engine. –  Eliah Kagan Aug 11 '12 at 21:37
    
755 ? sorry but I'm really new in Linux, can explainor write the full cmd :) thanks –  Engine Aug 11 '12 at 22:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.