Answers.Body: <p>If you use environment variables, you have to be aware that you can't add anything to it in your fields. What this means is that <code>$ASSET_ADHOC_PATH/website</code> in your CP will not be parsed. If you use environment variables, the only thing you should have in the field is the variable, nothing else.</p>
  
  <p>To do what you are trying to do, you might want to <a href="https://docs.craftcms.com/v3/config/#aliases" rel="noreferrer">consider Aliases</a>. These are great for the Control Panel because you can add to them so <code>@aliasName/website</code> will be parsed 
  and work the way you expect.</p>
  
  <p>So in your case (and to get you going) with this <code>ASSET_ADHOC_PATH</code> variable set in your <code>.env</code> file, add the below in your <code>config/general.php</code>:</p>
  
  <pre class="lang-php prettyprint-override"><code>'aliases' =&gt; [
      '@assetAdHocPath' =&gt; getenv('ASSET_ADHOC_PATH')
  ],
  </code></pre>
  
  <p>Then in your volume settings use <code>@assetAdHocPath/website</code> and this should now work for you.</p>
  
  <p>For the second part of the question, I'm guessing you may be trying to access an <code>ENV</code> in your template in which case you would use <code>{{ getenv('ASSET_ADHOC_PATH') }}</code> OR if you go the aliases way, <code>{{ alias('@assetAdHocPath') }}</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-23T17:30:52.067Z
Answers.Text: Thanks, worked like a charm and learnt something new. Also, FYI for anyone else, aliases must go within one of the existing options in `general.php` to show up (i.e. in `*`, `dev`, `production` or `staging`).
Answers.UserDisplayName: theAdhocracy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-23T18:15:56.797Z
Answers.Text: Yes sorry, I should have been more specific with that though if you’re going to use ENVs, it safe to put this in ‘*’. Glad you’re sorted!
Answers.UserDisplayName: Oli
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-06T00:50:25.570Z
Answers.Text: @theAdhocracy this fixed the issue I was having with my aliases not showing up. Needed to move the aliases block down into the '*' config. Thanks!
Answers.UserDisplayName: Panda4Man
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-23T11:56:34.157Z
Answers.LastActivityDate: 2019-06-23T18:16:28.743Z
Answers.LastEditDate: 2019-06-23T18:16:28.743Z
Answers.UserDisplayName: Oli
Body: <p>I have a volume called "Website" with a File System Path that uses an environment variable, <strong>$ASSET_ADHOC_PATH</strong>. The variable has been setup in my .env file as follows:</p>
  
  <pre><code>ASSET_ADHOC_PATH="/home/theadhoc/craftcms/web/assets/theadhocracy"
  </code></pre>
  
  <p>The Volume has the following in the File System Path input:</p>
  
  <pre><code>$ASSET_ADHOC_PATH/website
  </code></pre>
  
  <p>That should resolve to my actual folder location, but when I upload a file it just creates a folder at:</p>
  
  <pre><code>/home/theadhoc/craftcms/web/$ASSET_ADHOC_PATH/website
  </code></pre>
  
  <p>If I get rid of the environment variable and use the literal value then it works fine (which is what I'm doing for now) but I'd like to get to the bottom of why this isn't working as I would expect.</p>
  
  <p><strong>EDIT:</strong> Just in case this helps, I've discovered I have the same issue when using (different) environment variables in the Base URL field too. Am I missing a step in setting up env vars? Do I need to add them to general.php or something as well? They seem to resolve without issue in the dropdown list, which accurately displays the variable contents.</p>
  
Tags: <assets><environmentvariables><volumes>
Title: Asset Volume using Environment Variable on File System Path as literal string on upload
ThreadText: # Asset Volume using Environment Variable on File System Path as literal string on upload
  
  (Asked by: username_0 on 2019-06-23)
  
  I have a volume called "Website" with a File System Path that uses an environment variable, **$ASSET\_ADHOC\_PATH**. The variable has been setup in my .env file as follows:
  
  ```
  ASSET_ADHOC_PATH="/home/theadhoc/craftcms/web/assets/username_0"
  
  ```
  
  The Volume has the following in the File System Path input:
  
  ```
  $ASSET_ADHOC_PATH/website
  
  ```
  
  That should resolve to my actual folder location, but when I upload a file it just creates a folder at:
  
  ```
  /home/theadhoc/craftcms/web/$ASSET_ADHOC_PATH/website
  
  ```
  
  If I get rid of the environment variable and use the literal value then it works fine (which is what I'm doing for now) but I'd like to get to the bottom of why this isn't working as I would expect.
  
  **EDIT:** Just in case this helps, I've discovered I have the same issue when using (different) environment variables in the Base URL field too. Am I missing a step in setting up env vars? Do I need to add them to general.php or something as well? They seem to resolve without issue in the dropdown list, which accurately displays the variable contents.
  
  **Tags:** assets, environmentvariables, volumes
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-06-23. Score: 5 | Accepted answer
  
  If you use environment variables, you have to be aware that you can't add anything to it in your fields. What this means is that `$ASSET_ADHOC_PATH/website` in your CP will not be parsed. If you use environment variables, the only thing you should have in the field is the variable, nothing else.
  
  To do what you are trying to do, you might want to [consider Aliases](https://docs.craftcms.com/v3/config/#aliases). These are great for the Control Panel because you can add to them so `@aliasName/website` will be parsed
  and work the way you expect.
  
  So in your case (and to get you going) with this `ASSET_ADHOC_PATH` variable set in your `.env` file, add the below in your `config/general.php`:
  
  ```php
  'aliases' => [
      '@assetAdHocPath' => getenv('ASSET_ADHOC_PATH')
  ],
  
  ```
  
  Then in your volume settings use `@assetAdHocPath/website` and this should now work for you.
  
  For the second part of the question, I'm guessing you may be trying to access an `ENV` in your template in which case you would use `{{ getenv('ASSET_ADHOC_PATH') }}` OR if you go the aliases way, `{{ alias('@assetAdHocPath') }}`.
  
  > **Comments:**
  > **username_0**: Thanks, worked like a charm and learnt something new. Also, FYI for anyone else, aliases must go within one of the existing options in `general.php` to show up (i.e. in `*`, `dev`, `production` or `staging`).  
  > **username_1**: Yes sorry, I should have been more specific with that though if you’re going to use ENVs, it safe to put this in ‘*’. Glad you’re sorted!  
  > **username_2**: @username_0 this fixed the issue I was having with my aliases not showing up. Needed to move the aliases block down into the '*' config. Thanks!  
  
  ---
  
  