I'm looking for a way to get the path to the user's home folder that will work on any sys target. The only way I can think of is to use the HOME/UserProfile environment variable, but I can't find a cross-target way to get environment variable values. Is there another way?
You can use Sys.getEnv() to obtain the value of the environment variable, and Sys.systemName() to check which OS you're running on:
var home = Sys.getEnv(if (Sys.systemName() == "Windows") "UserProfile" else "HOME");
Related
I've been looking around my machine to see where the postman environment variables are stored. I've looked under AppData\Local\Postman, and C:\Users\username\Postman folders, and haven't found a config file that has a last modified date matching my change of environment variables.
I know I can export the environment variables, but I want to search over the current variables. And the exports don't include the current values, unless they replace the initial value, which I want to keep.
There are still ways to get around this. But I want to write a simple command to fetch some current environment variables via cmd, ex using grep.
So is there a way to check for the current environment variables? Where are they stored?
I don't think this will be a successful attempt. Postman seems to use a database, e.g. leveldb, according to information I found here. That will be stored as a binary file on your disk.
You can, however, have a look into the DB by going to View => Developer => Show DevTools and then going to Storage => IndexedDB => variable_sessions => workspace. I can find a current value for an environment variable like this:
But I don't see a way to search in this other than by keys which are uuids and not variable names or values.
All in all, exporting your environments into a text file might be the easiest option.
I would like to use an environment variable within template.html so that I can change the content in the head for all pages based on where I'm running the app. Is this possible?
I never found a way to put environment variables in template.html, but I passed what I needed through server.js, picked it up in _layout.svelte, and included it in a <svelte:head> element.
https://dlang.org/library/std/process/environment.html allows getting a particular environment variable.
But I see no way to get all environment variables or the list of all environment variable names.
What is the right way to retrieve the full environment in D?
In fact, I want to pass some environment variables to a child process. What is the right way to do it?
There is no need to get all variables to pass to a child process; that is the default. If you are using the std.process library, you can pass null for environment to keep the existing one entirely, or a set of just the keys and values you want to change to get just them changed, and the rest inherited.
I am trying to set up my grails config locations but I am not sure what to put instead of userHome, I changed the app name to file_down which is what my app is called. So how does it work ?
grails.config.locations = [ "classpath:${file_down}-config.properties",
"classpath:${file_down}-config.groovy",
"file:${userHome}/.grails/${file_down}-config.properties",
"file:${userHome}/.grails/${file_down}-config.groovy"]
First and for maintaining default settings, you don't have to modify those statements; they will be resolved to their appropriate values when the app is running because that location needs to get to the ".grails" directory. If you want to see what the value is, add this statement in some controller or a gsp page (no println and quotes are needed then):
println "${System.properties.'user.home'}"
And that will tell you what the path resolves to, it would be something like c:\Users\katkut for example for a username being katkut. If you have your .grails folder in some other place then go ahead and put the absolute path as you wish instead, but, I hope you are maintaining the default installation settings.
One more thing. If userHome gives you null when you try to print it, just replace it with user.home as you see in the above statement, I believe they are the same, but the latter is accessible inside your .groovy and .gsp files.
I'm trying to store URL's in my environment variables. So for instance
ENV['SET_COOKIE_URL'] = 'http://domain.com/setcookie'
In my application layout page, I'm trying to do this:
window.top.location = '<%= ENV["SET_COOKIE_URL"] %>';
When I try this, it always returns '' (empty string).
Can you not store and output URL's in environment variables?
If you just added this environment variable, perhaps re-starting your server would help pickup the environment change. I don't see any reason why you won't be able to use that environment variable in your view other than just re-booting your server.