Skip to content

Commit 284e491

Browse files
authored
Merge pull request #239 from ComputerScienceHouse/develop
Merging develop to master (Removed CSH Hacks section and added CSH motto to footer of site)
2 parents 21b430c + bca5ef7 commit 284e491

File tree

3 files changed

+50
-21
lines changed

3 files changed

+50
-21
lines changed

_includes/footer.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@
3030
<div class="col-12 text-center spaced">
3131
<img src="https://assets.csh.rit.edu/pubsite/rit_csh.png" />
3232
</div>
33+
<div class="text-center spaced col-12"><i>Getting more done after 2am than most people do all day.</i></div>
3334
<div class="text-md-left col-12 col-lg-4">
3435
3536
</div>
3637
<div class="col-12 col-lg-4">
37-
&copy; 2019 Computer Science House
38+
&copy; 2020 Computer Science House
3839
</div>
3940
<div class="text-md-right col-12 col-lg-4">
4041
<a href="https://github.com/computersciencehouse/cshpublicsite">
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: "Debugging Error: NotPresent with Rust in Docker"
3+
description: "A friend's Docker container was exiting with Error: NotPresent and no other information. I embarked on a deep dive for an ultimately simple cause."
4+
layout: post
5+
date: 2020-05-19
6+
image: https://assets.csh.rit.edu/pubsite/projects/carbon.png
7+
image-sm: https://assets.csh.rit.edu/pubsite/projects/carbon.png
8+
author: Galen Guyer
9+
author-image: https://cdn.galenguyer.com/img/avatars/headshot.jpg
10+
author-email: [email protected]
11+
author-social:
12+
github: https://github.com/galenguyer/
13+
categories: [docker, rust]
14+
---
15+
16+
<a href='https://galenguyer.com/blog/2020/05/19/docker-rust-notpresent'>Check out this post on Galen's blog!</a>
17+
18+
<p>Today, a friend posted the following snippet in Slack:</p>
19+
<pre> [~/Documents/shelflife] [±docker✗] $ docker run -v -it --rm --name my-running-app shelflife-rust-docker
20+
Error: NotPresent</pre>
21+
<p>The first guess was that they had deleted the docker image and forgot to rebuild it. That wasn't the case, leading me to dive into this cryptic error message that we assumed was some hidden Rust or Docker error. We weren't able to find any example of this error message for Rust or Docker online, so I knew this would be a fun challenge.</p>
22+
23+
<p>The first thing I did was to make sure the path to the binary was working, as it'd be silly if this wasn't working because <code>/usr/local/bin</code> wasn't in the container's PATH. I changed the last line in the Dockerfile from <code>CMD ["shelflife"]</code> to <code>ENTRYPOINT ["/usr/local/bin/shelflife"]</code>. The error persisted, which meant it wasn't a PATH error. Of course this couldn't be easy.</p>
24+
25+
<p>The next step in diagnosis was to get a shell on the container. That would typically be done via <code>docker exec</code>, but that only works on a running container, which we didn't have. To get around this, I changed the last line of the Dockerfile to <code>ENTRYPOINT ["/bin/bash"]</code>, which makes <code>docker run -it</code> drop you into an interactive bash shell. This means I could easily see what was going on and run commands from inside the container.</p>
26+
27+
<p>Now that I had a shell, I navigated to <code>/usr/local/bin/</code> and ran <code>./shelflife</code> to check if there was any output docker was hiding. Unfortunately, there wasn't. I was at roughly the same place as when I started - a cryptic error message and no idea where it was coming from. At least now I was decently sure it wasn't not a docker issue.</p>
28+
29+
<p>I'd run into issues with dynamically linked libraries not being installed in the past, so I used <code>ldd</code> (List Dynamic Dependencies) to make sure all the dependencies existed. Everything looked fine, and I double-checked by manually installing the library packages for everything <code>ldd</code> said was linked. Everything was already installed, but the error persisted.</p>
30+
31+
<p>The last thing I tried was installing <code>strace</code>, a tool for tracing system calls, and running <code>strace ./shelflife</code>. This gave me a huge output full of system calls, but near the bottom was something that looked familiar, the text "NotPresent". Now I knew I was on the right path! The relevant output that got me to the final answer was the following:</p>
32+
33+
<pre>getcwd("/usr/local/bin", 512) = 15
34+
statx(0, NULL, AT_STATX_SYNC_AS_STAT, STATX_ALL, NULL) = -1 EFAULT (Bad address)
35+
statx(AT_FDCWD, "/usr/local/bin/.env", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7ffc04639b10) = -1 ENOENT (No such file or directory)
36+
statx(AT_FDCWD, "/usr/local/.env", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7ffc04639930) = -1 ENOENT (No such file or directory)
37+
statx(AT_FDCWD, "/usr/.env", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7ffc04639750) = -1 ENOENT (No such file or directory)
38+
statx(AT_FDCWD, "/.env", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7ffc04639570) = -1 ENOENT (No such file or directory)
39+
write(2, "Error: ", 7Error: ) = 7
40+
write(2, "NotPresent", 10NotPresent) = 10
41+
write(2, "\n", 1
42+
) = 1
43+
sigaltstack({ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=8192}, NULL) = 0
44+
munmap(0x7fb5000f2000, 8192) = 0
45+
exit_group(1) = ?
46+
+++ exited with 1 +++</pre>
47+
48+
<p>There it is! Right before exiting, there's several checks for a <code>.env</code> file that all fail. This error didn't happen when run locally, because my friend already made a <code>.env</code> file. However, I never created one, and more critically, the Dockerfile never copied their version of the file into the image. Once we created a <code>.env</code> file and added <code>COPY .env .</code> to the Dockerfile, it started as intended! This wasn't an issue with Docker or Rust at all, but a library giving an unhelpful error message. We couldn't find any documentation of this online, so I hope this post might serve to help anyone else who runs into this issue!</p>

index.html

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,6 @@
4545
</div>
4646
</div>
4747

48-
<div id="csh-hacks-wrapper">
49-
<div class="container spaced">
50-
<div class="row">
51-
<div class="col-12 col-lg-6 order-6 order-lg-0">
52-
<h2>September 26 - 27, 2020</h2>
53-
<p>
54-
CSH Hacks is an event where developers, designers, engineers
55-
and more come together to work on their ideas, solve challenges,
56-
learn new skills, and network with companies &amp; each other.
57-
The event is open to all majors and universities!
58-
</p>
59-
<a class="btn btn-primary" target="_blank" rel="noopener" href="https://hacks.csh.rit.edu">Learn More</a>
60-
</div>
61-
<div class="col-12 col-lg-6 order-0 order-lg-6">
62-
<img src="https://s3.csh.rit.edu/cshacks-assets/csh_hacks_logo.svg" alt="CSH Hacks logo">
63-
</div>
64-
</div>
65-
</div>
66-
</div>
67-
6848
<div class="container spaced" id="post-list">
6949
<div class="row">
7050
<div class="col-12">

0 commit comments

Comments
 (0)