<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="fn main() {
    struct Example;

    trait BaseTrait { fn toString(&amp;self) -&gt; ~str { ~&quot;BaseTrait&quot; } }

    trait DerivedTrait : BaseTrait {
        fn new() -&gt; Self;
        fn toString(&amp;self) -&gt; ~str { ~&quot;DerivedTrait&quot; }
    }

    impl BaseTrait for Example { }

    impl DerivedTrait for Example { fn new() -&gt; Example { Example } }

    let bug: Example = DerivedTrait::new();
    println(fmt!(&quot;%s&quot;, bug.toString()));
}"><pre class="notranslate"><span class="pl-k">fn</span> <span class="pl-en">main</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">struct</span> <span class="pl-smi">Example</span><span class="pl-kos">;</span>

    <span class="pl-k">trait</span> <span class="pl-smi">BaseTrait</span> <span class="pl-kos">{</span> <span class="pl-k">fn</span> <span class="pl-en">toString</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-smi">self</span><span class="pl-kos">)</span> -&gt; ~<span class="pl-smi">str</span> <span class="pl-kos">{</span> ~"<span class="pl-v">BaseTrait</span>" <span class="pl-kos">}</span> <span class="pl-kos">}</span>

    <span class="pl-k">trait</span> <span class="pl-smi">DerivedTrait</span> <span class="pl-kos">:</span> <span class="pl-smi">BaseTrait</span> <span class="pl-kos">{</span>
        <span class="pl-k">fn</span> <span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">Self</span><span class="pl-kos">;</span>
        <span class="pl-k">fn</span> <span class="pl-en">toString</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-smi">self</span><span class="pl-kos">)</span> -&gt; ~<span class="pl-smi">str</span> <span class="pl-kos">{</span> ~"<span class="pl-v">DerivedTrait</span>" <span class="pl-kos">}</span>
    <span class="pl-kos">}</span>

    <span class="pl-k">impl</span> <span class="pl-smi">BaseTrait</span> <span class="pl-k">for</span> <span class="pl-smi">Example</span> <span class="pl-kos">{</span> <span class="pl-kos">}</span>

    <span class="pl-k">impl</span> <span class="pl-smi">DerivedTrait</span> <span class="pl-k">for</span> <span class="pl-smi">Example</span> <span class="pl-kos">{</span> <span class="pl-k">fn</span> <span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">Example</span> <span class="pl-kos">{</span> <span class="pl-v">Example</span> <span class="pl-kos">}</span> <span class="pl-kos">}</span>

    <span class="pl-k">let</span> bug<span class="pl-kos">:</span> <span class="pl-smi">Example</span> = <span class="pl-smi">DerivedTrait</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-en">println</span><span class="pl-kos">(</span><span class="pl-en">fmt</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"%s"</span>, bug.toString<span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">klutzy@#rust was kind enough to give me debug output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ rustc.exe --version
d:\stone\rust\build-32\i686-pc-mingw32\stage2\bin\rustc.exe 0.8-pre
host: i686-pc-mingw32

$ RUST_LOG=rustc=1 rustc.exe x.rs
x.rs:32:20: 32:32 error: multiple applicable methods in scope
x.rs:32         println(fmt!(&quot;%s&quot;, bug.toString()));
                                   ^~~~~~~~~~~~
note: in expansion of fmt!
x.rs:32:9: 32:34 note: expansion site
task &lt;unnamed&gt; failed at 'report_static_candidate: bad item {crate: 0, node: 120}', D:\stone\rust\src\librustc\middle\typeck\check\method.rs:1306
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1 to get further details and report the results to github.com/mozilla/rust/issues
task &lt;unnamed&gt; failed at 'explicit failure', d:\stone\rust\src\librustc\rustc.rs:376"><pre class="notranslate"><code class="notranslate">$ rustc.exe --version
d:\stone\rust\build-32\i686-pc-mingw32\stage2\bin\rustc.exe 0.8-pre
host: i686-pc-mingw32

$ RUST_LOG=rustc=1 rustc.exe x.rs
x.rs:32:20: 32:32 error: multiple applicable methods in scope
x.rs:32         println(fmt!("%s", bug.toString()));
                                   ^~~~~~~~~~~~
note: in expansion of fmt!
x.rs:32:9: 32:34 note: expansion site
task &lt;unnamed&gt; failed at 'report_static_candidate: bad item {crate: 0, node: 120}', D:\stone\rust\src\librustc\middle\typeck\check\method.rs:1306
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1 to get further details and report the results to github.com/mozilla/rust/issues
task &lt;unnamed&gt; failed at 'explicit failure', d:\stone\rust\src\librustc\rustc.rs:376
</code></pre></div>
<p dir="auto">We thought it was related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="18652624" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/8808" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/8808/hovercard" href="https://github.com/rust-lang/rust/issues/8808">#8808</a>, this might be a duplicate.</p>
<p dir="auto">Let me start off by saying, <em>any time that <code class="notranslate">LD_LIBRARY_PATH</code> must be used is a bug</em>. Not just a user experience bug, but an absolute bug. The <em>sole</em> purpose of <code class="notranslate">LD_LIBRARY_PATH</code> is for <em>local administrators</em> to override the default for debugging or something, it must never be used by upstream or by distro, in any package. Never, ever, ever.</p>
<p dir="auto">Now, looking at distro policies:</p>
<ul dir="auto">
<li>All setuid/setgid/setcap executables must have no relative rpaths, because the executable may be hard-linked to load arbitrary code.</li>
<li>There must not be absolute rpaths to the build directory after installation (relative rpaths are okay, subject to the previous rule), because unprivileged users can write to the build directory to load.</li>
<li>The standard directories, (<code class="notranslate">/lib/</code>, <code class="notranslate">/lib64/</code>, <code class="notranslate">/usr/lib/</code>, and <code class="notranslate">/usr/lib64/</code>), must never be specified in an rpath. (Note, however, that if you install a <em>library</em> to the standard paths, you <em>must</em> run ldconfig afterward)</li>
<li>It is possible to extend the list of standard directories by adding a file to <code class="notranslate">/etc/ld.so.conf.d/</code>, but this is the job of the distro, not upstream.</li>
<li>If a library is installed <em>outside</em> the standard directories (either because it is private, or because it is being installed as an unprivileged user), you <em>must</em> emit an rpath.</li>
<li>Rust can avoid the problem of .so version changes in basic library packages such as libc, simply by including the SONAME of all the system libraries in the hash (this doesn't strictly <em>need</em> to be done now, only if such a change happens, and <em>could</em> be pushed to the distros problem (there probably should be a way to specify that anyway), but it shouldn't be hard so it might as well be done now so that an answer can be given to distros who ask).</li>
</ul>
<p dir="auto">Finally, a brief mention of Windows. Prior discussion has claimed that Windows does not support rpaths, but this is missing one criticial thing: Windows binaries have a <em>hard-coded</em> rpath of <code class="notranslate">.</code>, because each binaries bundling its own libraries has been the <em>normal</em> route, not the exception.</p>
<p dir="auto">The result of misunderstanding the implications of rpath has been much breakage, and telling users to use environment variables that are only intended for debugging.</p>