1

Is it possible to pass environmental variable as a parameter to executable? I tried this, but I get a string "job_$JOB_ID" in my app instead of "job_123"

enter image description here

Another question that can be a workaround for me: Is there a way to access this config dialog parameters as a text file? So that I cen edit Program arguments in text editor instead of CLion UI. Those configs must be stored somewhere in CLion app folder

1
  • 1
    Why involve CLion at all? Can you make your target program read the environment or a text file? You will only need to pass it a path to the config file. Commented Aug 16, 2019 at 22:16

1 Answer 1

2
+50

If you are looking to pass a environment variable that is defined by in run config, then it is not possible.

If you want to edit the configuration in file. Then usually it is stored in .idea/workspace.xml. This has all the run configurations and everything stored.

I don't have clion but have PyCharm, any a sample from same is

...
...
    <configuration name="scrape2" type="PythonConfigurationType" factoryName="Python" temporary="true">
      <module name="scripts" />
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs>
        <env name="PYTHONUNBUFFERED" value="1" />
      </envs>
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/deprecated" />
      <option name="IS_MODULE_SDK" value="true" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/deprecated/scrape2.py" />
      <option name="PARAMETERS" value="" />
      <option name="SHOW_COMMAND_LINE" value="false" />
      <option name="EMULATE_TERMINAL" value="false" />
      <option name="MODULE_MODE" value="false" />
      <option name="REDIRECT_INPUT" value="false" />
      <option name="INPUT_FILE" value="" />
      <method v="2" />
    </configuration>
...

You can see the environment variables are defined inside envs.

You can pass a externally defined environment variable using ${ENVNAME}. See below thread on SO

How to pass an environment variable as a command line parameter in Run/Debug configuration in PyCharm?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.