`--user-data-dir` not work in Windows10 , same to #586
slow-groovin opened this issue · 4 comments
Describe the bug
When setting --user-data-dir
to persist config, it didn't work,
the target dir is empty after start and exit dev.
It's same to #586, two --user-data-dir
appears twice in chrome://version/
Command Line, and the first have effect
Reproduction
same to #586
export default defineRunnerConfig({
// On Windows, the path must be absolute
chromiumArgs: [
`--user-data-dir=D:\\slow-groovin\\Documents\\wxt-learn\\.wxt\\chrome-data`,
`--lang=en`
],
});
Steps to reproduce
No response
System Info
System:
OS: Windows 10 10.0.19045
CPU: (16) x64 AMD Ryzen 7
Memory: 12.99 GB / 30.69 GB
Binaries:
Node: 22.10.0 - D:\Program Files\nodejs\node.EXE
npm: 10.9.0 - D:\Program Files\nodejs\npm.CMD
pnpm: 9.12.3 - D:\Program Files\nodejs\pnpm.CMD
Browsers:
Edge: Chromium (127.0.2651.74)
Internet Explorer: 11.0.19041.4355
Used Package Manager
pnpm
Validations
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
+1
after dig into the code, find out that it did work, but not as sample as the doc said.
without the keepProfileChanges: true flag, web-ext-run will copy the dir you spicified with --user-data-dir
to a temp dir and use that temp dir every time on start.
so if you want to use a seperate dir as chrome profile, and prevent settings lost every time on start,
the following config will work.
export default defineRunnerConfig({
keepProfileChanges: true,
chromiumProfile: "C:\\Users\\xxx\\yyy\\chrome-data",
});
BTW,
that leed to another issue, some chrome preferences will be reset every time, because of chrome-launcher issue/feature:
GoogleChrome/chrome-launcher#335.
they use a sample/fake merge method with existing prefs
this.fs.writeFileSync(preferenceFile, JSON.stringify({...content, ...this.prefs}), 'utf-8');
and unfortunately, web-ext-run hard coded a default pref:
const DEFAULT_PREFS = {
'extensions.ui.developer_mode': true
};
so chrome prefs start with 'extensions.' will lost.
if you want to save some related prefs, for example you want ur extensions icon pinned, you have to set that in runner setings:
export default defineRunnerConfig({
// ... other configs
chromiumPref: {
extensions: {
ui: { developer_mode: true, },
pinned_extensions: ["ur-extension-id"]
}
}
});
@Dollyn Thanks! setting like this meets my requirements.
Additionally, the configurations in the Chrome Pref documentation includes few.
The best way is copy the real valid configurations in the actual Chrome Preference file (the Preference file is located at C:\Users\AppData\Local\Chromium\User Data\Default\Preferences).
Below is my configuration, which is used to modify the DevTools location and language. Note that the value of the configuration must include the escaped colon (exactly as it appears in the Preferences file).
chromiumPref: {
extensions: {
ui: {developer_mode: true,},
pinned_extensions: [""]
},
devtools:{
preferences:{
// "currentDockState": "bottom", //not work
"currentDockState": "\"bottom\"",
},
"synced_preferences_sync_disabled": {
"language": "\"zh\"",
}
},
download: {default_directory: resolve('.wxt/download'),},
}