What determines the user.dir variable when using C...
# box-products
j
What determines the user.dir variable when using CommandBox? For me, it is set to the location of server.json, but for a colleague he is saying it's set to his installation of CommandBox.
b
@John Liljegren Are you asking about the Java System Property of that name?
Copy code
env show user.dir
That is set by Java itself when box is started and is the working directory box was started in.
You really shouldn't need to use it for anything. Can you clarify what your need is here?
The explanation for the difference simply be that you started CommandBox in your web root and your colleague started CommandBox in the folder where box lives. But again, CommandBox can be started anywhere, so you shouldn't rely on that java system property for anything meaningful.
CommandBox has its own internal tracking of what its working directory is if you need that.
j
Sorry for the delay - so I'm using it currently in the .config.json file to set up a custom tags folder mapping:
Copy code
"customTagPaths":[
        {
            "physical":"${user.dir}\CustomTags",
            "primary":"physical",
            "archive":""
        }
    ],
b
Yeah, you don't want to use that at all there
You can't count on this having any useful value based on where box was ran
You can get the web root from
${serverInfo.webroot}
which maybe helpful if customtags is inside of that folder
j
it's at least relative to that, so i'll try that
j
thanks!
b
CFConfig settings which point to disk paths have always been a bit of a pain
What I don't know is what will happen if you do something like
Copy code
"physical":"${serverInfo.webroot}../CustomTags",
that would boil down to how Lucee handles a path like
/var/www/foo/../CustomTags
in the config
j
appears to be working in acf2021... thanks again!