Find $HOME or Windows equivalent with FreePascal - configuration-files

My purpose is to deploy user configuration files under:
$HOME/.appname for Unix/Linux.
\Documents and Settings\(user)\Application Data\AppName for Windows.
What are the API's or group of functions that I can use, with the appropriate {$IFDEF}'s, so I can deploy my config files on the appropriate places?

Better use the correct function:
http://www.freepascal.org/docs-html/rtl/sysutils/getappconfigdir.html
result:=getappconfigdir(false)

You'll likely end up using the GetEnvironmentVariable function. Under Unix-like OSs, you will use the HOME environment variable. Under Windows, you'll use the APPDATA environment variable.

Related

In powershell, how can I define all env vars for the next command similar to python's Popen abilities?

In powershell, how can I...
explicitly define all the env vars for the next command?
I don't want any system env vars if possible,
After this command runs I dont want anything we have done to affect further processes in the shell.
As an example, in python we have the equivalent ability in Popen to pass a dictionary of the full environment to the subprocess, and I'm hoping there might be something similar in Powershell.
I think this link explains what you need: Windows user environment variable vs. system environment variable
[Environment]::GetEnvironmentVariable("TEMP", "Machine")

How can I use "~" or "$HOME" in VisualStudioCode settings on Windows

I'm using settings sync between multiple windows pc with different usernames.
Some settings with path such as vim.autoSwitchInputMethod.obtainIMCmd might be C:/Users/myname/im-select.exe. However it cannot work if I replace the value to ~/im-select.exe or $HOME/im-select.exe or ${env:HOME}/im-select.exe.
So how should I set the value to make it work among all different pcs? Or how to make vscode to read environment variables ?

how to specify new environment location for conda create

the default location for packages is .conda folder in my home directory. however, on the server I am using, there is a very strict limit of how much space I can use, which basically avoids me from putting anything under my home directory. how can I specify the location for the virtual environment that I want to create? Thanks! server is running Ubuntu.
Use the --prefix or -p option to specify where to write the environment files. For example:
conda create --prefix /tmp/test-env python=2.7
Will create the environment named /tmp/test-env which resides in /tmp/ instead of the default .conda.
like Paul said, use
conda create --prefix=/users/.../yourEnvName python=x.x
if you are located in the folder in which you want to create your virtual environment, just omit the path and use
conda create --prefix=yourEnvName python=x.x
conda only keep track of the environments included in the folder envs inside the anaconda folder. The next time you will need to activate your new env, move to the folder where you created it and activate it with
source activate yourEnvName
While using the --prefix option works, you have to explicitly use it every time you create an environment. If you just want your environments stored somewhere else by default, you can configure it in your .condarc file.
Please see: https://conda.io/docs/user-guide/configuration/use-condarc.html#specify-environment-directories-envs-dirs
If you want to use the --prefix or -p arguments, but want to avoid having to use the environment's full path to activate it, you need to edit the .condarc config file before you create the environment.
The .condarc file is in the home directory; C:\Users\<user> on Windows. Edit the values under the envs_dirs key to include the custom path for your environment. Assuming the custom path is D:\envs, the file should end up looking something like this:
ssl_verify: true
channels:
- defaults
envs_dirs:
- C:\Users\<user>\Anaconda3\envs
- D:\envs
Then, when you create a new environment on that path, its name will appear along with the path when you run conda env list, and you should be able to activate it using only the name, and not the full path.
Command line screenshot
In summary, if you edit .condarc to include D:\envs, and then run conda env create -p D:\envs\myenv python=x.x, then activate myenv (or source activate myenv on Linux) should work.
Hope that helps!
P.S. I stumbled upon this through trial and error. I think what happens is when you edit the envs_dirs key, conda updates ~\.conda\environments.txt to include the environments found in all the directories specified under the envs_dirs, so they can be accessed without using absolute paths.
You can create it like this
conda create --prefix C:/tensorflow2 python=3.7
and you don't have to move to that folder to activate it.
# To activate this environment, use:
# > activate C:\tensorflow2
As you see I do it like this.
D:\Development_Avector\PycharmProjects\TensorFlow>activate C:\tensorflow2
(C:\tensorflow2) D:\Development_Avector\PycharmProjects\TensorFlow>
(C:\tensorflow2) D:\Development_Avector\PycharmProjects\TensorFlow>conda --version
conda 4.5.13
I ran into a similar situation. I did have access to a larger data drive. Depending on your situation, and the access you have to the server you can consider
ln -s /datavol/path/to/your/.conda /home/user/.conda
Then subsequent conda commands will put data to the symlinked dir in datavol
You can modify the default paths for environments by modifying CONDA_ENVS_PATH:
For macOS and Linux: CONDA_ENVS_PATH=~/my-envs:/opt/anaconda/envs
For Windows: set CONDA_ENVS_PATH=C:\Users\joe\envs;C:\Anaconda\envs
the documentation is here:
https://conda.io/projects/conda/en/latest/user-guide/configuration/use-condarc.html#specify-environment-directories-envs-dirs
Use -p option to specify the path to your env.
For Linux/macOS, env location info is stored in ~/.conda/environments.txt.
Use conda info --envs to list all your envs.

TFS2015 Release Management Powershell DSC Variable Use

I am using TFS2015 Release Management and Powershell DSC to manage the deployment of applications - previously I was using RM2013.
One thing I have noticed is that in RM2013, in my Powershell DSC scripts I was able to access variables such as $applicationPath - which was populated with the TFS Build Drop location, for use in the DSC scripts and MOF creation.
In RM2015 it doesn't appear that this works? I have tried using the variables listed here: https://msdn.microsoft.com/en-us/Library/vs/alm/Build/scripts/variables
However none of these ever seem to be populated?
Is there actually a way of using these RM2015 system & build variables from within a PS DSC script now?
Kind regards
Try to use the corresponding generated environment variables (for example $env:Build.DefinitionName).
If it not work try more ways such as $env:Build_DefinitionName or $(Build.BuildNumber) and $(Build_BuildNumber)
Just as the relevant documentation mentioned:
Any text input can reference a variable by using the $(variable_name)
syntax and will be substituted with the actual value at run-time. All
variables are also exported to the environment as upppercase and any .
are replaced with _. In scripts you can reference variables via the
environment, i.e. %VARIABLE_NAME%, $VARIABLE_NAME, $env:VARIABLE_NAME,
depeding on the operating system.

No such host is known using AquaQ

I am trying to set up a production environment for KDB using AquaQ.
I have set up the appropriate Environment Variables and modified the process.csv file to have my IP in it. When I try and load torq.q I get the error:
cannot create alias on windows os.
Below is what's in the error log following
2014.12.30D15:40:06.203625000|hoffmanpc|hdb2|ERR|fileload|failed to load C:\TORQFULL\TORQ\src\code/handlers/logusage.q : c: No such host is known.
You're running on windows right? As far as I'm aware, TorQ is specifically designed and tested for Linux and OSX, not windows.
Seems the error above is due to the file paths having forward slashes vs backslashes. If you could manually fix the hard-coded filepaths to be in windows format it might work. Best best is to contact AquaQ themselves
Terry you were right actually. It turns out q requires this "/" in paths not "\". I had "\" in the path for the environment variables. Johnny Press answered this for me here