Describe the bug
I'm running on a Windows machine and I have changed the ANDROID_SDK_HOME location to point another drive. However, the configFile path from EmulatorDriver (_fixEmulatorConfigIniSkinName function) is using the homeDir as a base for the path instead of the environment variable of the sdk, resulting in an invalid path.
To Reproduce
Expected behavior
The emulator config file should be correctly identified at the new location
Actual behavior
The following error is thrown:
{ Error: ENOENT: no such file or directory, open 'C:\Users\<placeholder_for_user>\.android\avd\Nexus_5X_API_27.avd\config.ini'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.readFileSync (fs.js:551:33)
at EmulatorDriver._fixEmulatorConfigIniSkinName (D:\myApp\node_modules\detox\src\devices\drivers\EmulatorDriver.js:23:33)
at EmulatorDriver.acquireFreeDevice (D:\myApp\node_modules\detox\src\devices\drivers\EmulatorDriver.js:91:16)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Users\\<placeholder_for_user>\\.android\\avd\\Nexus_5X_API_27.avd\\config.ini' }
Let me know if more details are needed.
Thanks
@geraniumdt, I might be a bit busy with the other issues, so if you feel the strength to make a pull request addressing this shortcoming, I'd be very grateful! If not, well, I think I'll find a spare hour somewhere in April-May for that.
@noomorph i think that this issue is on the EmulatorDriver.js:
It uses os.homedir(), we probably could solve this issue using these lines:
const sdkHome = process.env.ANDROID_SDK_HOME || os.homedir()
const configFile = path.normalize(`${sdkHome}/.android/avd/${name}.avd/config.ini`);
Note: path.normalize is just to make sure everything is ok on windows
Edit:
I've made these changes locally and my emulator was found
Most helpful comment
@noomorph i think that this issue is on the EmulatorDriver.js:
https://github.com/wix/Detox/blob/61ad39b7a84a6e73c2c7ecc0199ba3a13c391772/detox/src/devices/drivers/EmulatorDriver.js#L21-L25
It uses
os.homedir(), we probably could solve this issue using these lines:Note:
path.normalizeis just to make sure everything is ok on windowsEdit:
I've made these changes locally and my emulator was found