XDG_DATA_HOME can't work ubuntu-emulator

Bug #1394858 reported by Bin Li
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
phablet-tools (Ubuntu)
New
Undecided
Unassigned

Bug Description

XDG_DATA_HOME used for saving emulator which user created.

sudo ubuntu-emulator create helloworld --arch=i386 --channel=ubuntu-touch/ubuntu-rtm/14.09

After that the emulator would be saved in below directory.
.local/share/ubuntu-emulator/helloworld.

So I set the XDG_DATA_HOME to /home/emulator/ with export. And move the helloworld into /home/emulator/ubuntu-emulator/.

After that I could list the emulator with 'ubuntu-emulator list' successfully. So the XDG_DATA_HOME take effect.

But when I create a new emulator with 'sudo' I found it still create a new emulator in '.local/share/ubuntu-emulator/' while not in '/home/emulator/ubutnu-emulator'.

Thanks!

Revision history for this message
You-Sheng Yang (vicamo) wrote :

When you execute any command with sudo, it will probably _not_ carry your environment variables set for your normal user. So, when you execute `ubuntu-emulator list` as normal user, that XDG_DATA_HOME variable takes effect and not when you execute `ubuntu-emulator create` as root via sudo.

Revision history for this message
Bin Li (binli) wrote :

Vicamo,

 Yes, that's the reason.

 You cant just write a simple test. when use it with sudo it can't anything. :)
--------------------------------------
$cat test.sh
#!/bin/bash

echo "$XDG_DATA_DIRS"
--------------------------------------

 Could we find another way to set the DATA_HOME? Thanks!

Revision history for this message
You-Sheng Yang (vicamo) wrote :

I think both `sudo -E ...` or `sudo env XDG_DATA_DIRS=$XDG_DATA_DIRS ...` work for your case.

Revision history for this message
Bin Li (binli) wrote :

Vicamo,

 Yes, :)

Revision history for this message
Bin Li (binli) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.