nw.js icon indicating copy to clipboard operation
nw.js copied to clipboard

Setting --user-data-dir to custom location still causes AppData folder to be created

Open starsoccer opened this issue 7 years ago • 16 comments

NWJS Version : 0.27.1 Operating System : Windows 10

Expected behavior

If user-data-dir is set to a custom location, no folder should be created in AppData\Local%appname%

Actual behavior

Empty folders are created in AppData\Local%appname%. Specifically a User Data and a User Data\CrashPad folder are created

How to reproduce

  1. Create a simple app with NWJS and then set the --user-data-dir to a custom location.
  2. Run the app
  3. Close the app
  4. Check AppData\Local%appname% to see if a folder exists

starsoccer avatar Dec 14 '17 02:12 starsoccer

I can reproduce this issue on Linux/Windows with nwjs-sdk-v0.27.1.

Christywl avatar Dec 14 '17 02:12 Christywl

Is this bug fixed yet? nw.js version 0.31.4 still has this problem, that's annoying. By the way, nw.exe --user-data-dir=%APPDATA%\myapp works well with cmd.exe, but "chromium-args":"--user-data-dir=%APPDATA%\\myapp" in the package.json didnt work. It just creates a folder named %APPDATA% in the current directory but not converts to system path, is that a bug or I'm using it in a wrong way?

keenghost avatar Jun 29 '18 19:06 keenghost

I would like to add a [Feature Request] to simply not write the app_name (where app_name is the name field value in the package.json) not only from the \Local\AppData location, but do not write it anywhere if possible.

Here is a thread on the Google Group explaining more details with Roger: https://groups.google.com/forum/#!topic/nwjs-general/bQdFZEVXcBs

rowenbuzz avatar Mar 22 '19 01:03 rowenbuzz

Is this bug fixed yet? nw.js version 0.31.4 still has this problem, that's annoying. By the way, nw.exe --user-data-dir=%APPDATA%\myapp works well with cmd.exe, but "chromium-args":"--user-data-dir=%APPDATA%\\myapp" in the package.json didnt work. It just creates a folder named %APPDATA% in the current directory but not converts to system path, is that a bug or I'm using it in a wrong way?

I'm having the same issue. The environment variables aren't being expanded, but are being used as literals. nwjs:0.32.4

zkrige avatar May 16 '19 08:05 zkrige

@rogerwang is there a plan to fix this? Or at least offer an nwjs api/setting to use %APPDATA% rather than %LOCALAPPDATA% which is the default now. This bug makes it impossible to have the user-data-dir in each users roaming folder.

mikekilburn avatar Mar 15 '20 19:03 mikekilburn

Version: 0.45.5

{
  "name": "test",
  "version": "0.0.1",
  "main": "app.js"
  "chromium-args": [
    "--user-data-dir=./data"
  ]
}

Does not work for me.

f3l1x avatar May 07 '20 12:05 f3l1x

@rogerwang here is a pull request that fixes this issue. https://github.com/nwjs/nw.js/pull/7477 . At Mitel we use nwjs for our UC client and need to have local storage in the roaming folder (%APPDATA%) rather than %LOCALAPPDATA%. Please have a look.

mikekilburn avatar May 15 '20 02:05 mikekilburn

Has this issue been fixed? From the PR it looks like it's all done.

TheRealDannyyy avatar Jul 01 '20 13:07 TheRealDannyyy

I just tested this out and it's still broken. @rogerwang This is a P3 issue, would you mind fixing it if you got the time to?

My steps to reproduce (sample: package.zip):

  1. Run blank app (includes "--user-data-dir=test")
  2. Close running app
  3. Notice "test" folder being created as expected
  4. Notice "UserdirTEST" folder also being created, despite using custom path [C:\Users\YOURNAMEHERE\AppData\Local\UserdirTEST]

TheRealDannyyy avatar Jul 01 '20 14:07 TheRealDannyyy

@TheRealDannyyy yes its working really well ;). Be careful to use single quotes to handle paths with spaces. Here is an example with single quotes in two places. "chromium-args": "--user-data-dir='%APPDATA%'\TheProduct\'User Data'"

mkilburn60 avatar Jul 01 '20 14:07 mkilburn60

@mkilburn60 Based on my test case it doesn't. It seems like crashpad is causing a userdir to be created inside the appdata folder.

TheRealDannyyy avatar Jul 01 '20 14:07 TheRealDannyyy

@TheRealDannyyy note you two backslash for each of the path separators but this page removes one when it renders.

mkilburn60 avatar Jul 01 '20 14:07 mkilburn60

@TheRealDannyyy thats true - crash dumps still go to the default.

mkilburn60 avatar Jul 01 '20 14:07 mkilburn60

@TheRealDannyyy I'm guessing the same fix would need to be applied to --crash-dumps-dir

mkilburn60 avatar Jul 01 '20 14:07 mkilburn60

@TheRealDannyyy the expansion is applied to the whole command line so try setting --crash-dumps-dir to %APPDATA%

mkilburn60 avatar Jul 01 '20 14:07 mkilburn60

Hi guys, is the problem still not solved? when installing our application, a folder like nw_817_813871837 (numbers may vary) is created in c:/Program Files, it is empty. If you turn off (close) the application this folder disappears. If you uninstall and reinstall the folder is not created. If you install another version of the application, the folder appears again. Sometimes it is not deleted after closing. Windows defender reacts to all this. Very much need help, in our application windows defender plays a big role

webstorybegin avatar Dec 14 '23 09:12 webstorybegin