title: Setting DYLD_LIBRARY_PATH on Mac OS X Sierra (CoolProp)
body: <p>Disclaimer: This question started as a <a href="https://github.com/CoolProp/CoolProp/issues/1430#issuecomment-290430248" rel="nofollow noreferrer">GitHub issue</a>.</p>
  <h1>Question</h1>
  <p>I'll put <a href="https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem">the X question</a> right up front:
  <strong>Does anyone know a way to set <code>DYLD_LIBRARY_PATH</code> in a way that Excel 2016 will recognize on MacOS Sierra?</strong></p>
  <p>The actual problem (Y): <strong>How (else) can the developers of CoolProp allow their dynamic library to be used in Excel?</strong></p>
  <h1>Background</h1>
  <p>I am trying to get Excel 2016 for Mac to recognize the CoolProp plugin using <a href="http://www.coolprop.org/dev/coolprop/wrappers/Excel/index.html#pre-compiled-binaries-for-osx" rel="nofollow noreferrer">these instructions</a>, which basically boil down to using this <code>startup.plist</code>:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
  &lt;plist version=&quot;1.0&quot;&gt;
  &lt;dict&gt;
  &lt;key&gt;Label&lt;/key&gt;
  &lt;string&gt;my.startup&lt;/string&gt;
  &lt;key&gt;ProgramArguments&lt;/key&gt;
  &lt;array&gt;
    &lt;string&gt;sh&lt;/string&gt;
    &lt;string&gt;-c&lt;/string&gt;
    &lt;string&gt;launchctl setenv DYLD_LIBRARY_PATH &quot;/Users/$USER/Library/Group Containers/UBF8T346G9.Office&quot;&lt;/string&gt;
  &lt;/array&gt;
  &lt;key&gt;RunAtLoad&lt;/key&gt;
  &lt;true/&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  <p>to set <code>DYLD_LIBRARY_PATH</code> to a location where Excel can access the dynamic library and copying the <code>libCoolProp.dylib</code> file into that same directory. Unfortunately, it appears that due to SIP, one can no longer set any environment variable which starts with <code>DYLD_</code>.</p>
  <p>To verify this, I have built a test spreadsheet which contains this VBA function and <code>=ENV(&quot;DYLD_LIBRARY_PATH&quot;)</code> in cell A1.</p>
  <pre><code>Public Function Env(Value As Variant) As String
      Env = Environ(Value)
  End Function
  </code></pre>
  <p>I observe this behaviour:</p>
  <pre><code>$ launchctl setenv DYLD_LIBRARY_PATH &quot;/Users/${USER}/Library/Group Containers/UBF8T346G9.Office&quot;
  $ launchctl getenv DYLD_LIBRARY_PATH  # empty output
  $ launchctl setenv DYLDLIBRARYPATH &quot;/Users/${USER}/Library/Group Containers/UBF8T346G9.Office&quot; # Same kind of thing, but no underscores
  $ launchctl getenv DYLDLIBRARYPATH # works fine
  /Users/alchemyst/Library/Group Containers/UBF8T346G9.Office
  </code></pre>
  <p>After running this sequence of commands in my terminal and restarting Excel, I am able to retrieve the contents of &quot;DYLDLIBRARYPATH&quot; using the test spreadsheet. I have also edited the startup.plist and obtained similar results. I appear to be following all the right steps, but it appears that &quot;DYLD_*&quot; is simply not being set when I call setenv. The result is the same if I do it as root.</p>
  <p>So basically I am looking for any way in which I can still use this plugin on the Mac.</p>
  <p>Versions: MacOS Sierra (10.12.3), Excel 2016 (15.32), CoolProp 6.10</p>