Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage can't create timestamped file, thus can't find it. #1

Open
drhuffman12 opened this issue Jun 10, 2023 · 6 comments
Open

Coverage can't create timestamped file, thus can't find it. #1

drhuffman12 opened this issue Jun 10, 2023 · 6 comments

Comments

@drhuffman12
Copy link

Running bin/crkcov errors out with the following:

$ bin/crkcov
--: 1: kcov: not found
Unhandled exception: Error opening directory: 'coverage': No such file or directory (File::NotFoundError)
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/crystal/system/unix/dir.cr:6:5 in 'open'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/dir.cr:30:12 in 'initialize'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/dir.cr:28:3 in 'new'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/dir.cr:42:5 in 'children'
  from lib/crystal-kcov/src/runner.cr:104:7 in 'get_latest_coverage'
  from lib/crystal-kcov/src/runner.cr:26:7 in 'run'
  from lib/crystal-kcov/src/crystal-kcov.cr:3:1 in '__crystal_main'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/crystal/main.cr:115:5 in 'main_user_code'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/crystal/main.cr:101:7 in 'main'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/crystal/main.cr:127:3 in 'main'
  from /lib/x86_64-linux-gnu/libc.so.6 in '??'
  from /lib/x86_64-linux-gnu/libc.so.6 in '__libc_start_main'
  from bin/crkcov in '_start'
  from ???
@drhuffman12
Copy link
Author

drhuffman12 commented Jun 10, 2023

I thought it was from an old build that needed updating. Changing my docker from:

FROM crystallang/crystal:nightly-alpine-build

..to:

FROM crystallang/crystal 

seemed to heko, but not really. This time, I got:

$ docker-compose run app bash
Creating ai4cr_redo_app_run ... done
root@a7f756def876:/app# bin/crkcov
--: 1: kcov: not found
Unhandled exception: Error opening file with mode 'r': 'coverage/coverage/app-20230610-225722/coverage.json': No such file or directory (File::NotFoundError)
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/crystal/system/unix/file.cr:11:7 in 'open'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/file.cr:120:5 in 'new'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/file.cr:654:5 in 'open'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/file.cr:653:3 in 'open'
  from /home/drhuffman12/_tmp_/github/drhuffman12/ai4cr_redo/lib/crystal-kcov/src/runner.cr:114:43 in 'get_latest_coverage'
  from /home/drhuffman12/_tmp_/github/drhuffman12/ai4cr_redo/lib/crystal-kcov/src/runner.cr:26:7 in 'run'
  from /home/drhuffman12/_tmp_/github/drhuffman12/ai4cr_redo/lib/crystal-kcov/src/crystal-kcov.cr:3:1 in '__crystal_main'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/crystal/main.cr:115:5 in 'main_user_code'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/crystal/main.cr:101:7 in 'main'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/crystal/main.cr:127:3 in 'main'
  from /lib/x86_64-linux-gnu/libc.so.6 in '??'
  from /lib/x86_64-linux-gnu/libc.so.6 in '__libc_start_main'
  from bin/crkcov in '_start'
  from ???

Adding the coverage folder didn't work either; it gave me basically the same thing:


root@a7f756def876:/app# bin/crkcov
--: 1: kcov: not found
Unhandled exception: Error opening file with mode 'r': 'coverage/coverage/app-20230610-230020/coverage.json': No such file or directory (File::NotFoundError)
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/crystal/system/unix/file.cr:11:7 in 'open'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/file.cr:120:5 in 'new'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/file.cr:654:5 in 'open'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/file.cr:653:3 in 'open'
  from /home/drhuffman12/_tmp_/github/drhuffman12/ai4cr_redo/lib/crystal-kcov/src/runner.cr:114:43 in 'get_latest_coverage'
  from /home/drhuffman12/_tmp_/github/drhuffman12/ai4cr_redo/lib/crystal-kcov/src/runner.cr:26:7 in 'run'
  from /home/drhuffman12/_tmp_/github/drhuffman12/ai4cr_redo/lib/crystal-kcov/src/crystal-kcov.cr:3:1 in '__crystal_main'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/crystal/main.cr:115:5 in 'main_user_code'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/crystal/main.cr:101:7 in 'main'
  from /home/drhuffman12/.asdf/installs/crystal/1.7.2/share/crystal/src/crystal/main.cr:127:3 in 'main'
  from /lib/x86_64-linux-gnu/libc.so.6 in '??'
  from /lib/x86_64-linux-gnu/libc.so.6 in '__libc_start_main'
  from bin/crkcov in '_start'
  from ???

Help! :)

@Vici37
Copy link
Member

Vici37 commented Jun 14, 2023

Hello! Thank you for creating the first issue of crystal-kcov!

--: 1: kcov: not found

This line seems ominous, do you have the kcov executable built and on the $PATH in your docker container? My own test image Dockerfile looks like:

FROM crystallang/crystal

# add repo that allows us to download libevent-2.1-6
RUN echo "deb http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse" >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y apt-utils git cmake make binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev gcc g++ python3 libevent-2.1-6
RUN git clone https://github.com/SimonKagstrom/kcov
WORKDIR kcov
RUN cmake .
RUN make
RUN make install
WORKDIR /
RUN rm -rf kcov

Note about the above - I haven't updated my local kcov version in awhile, those may not be the correct dependencies to install with apt-get install. You can refer to this for an updated list.

Locally, when I remove kcov from my $PATH, I can reproduce your first error (not sure what would be creating the coverage directory afterwards).

@drhuffman12
Copy link
Author

👀

@Vici37
Copy link
Member

Vici37 commented Jun 15, 2023

As an addition, this is something this tool should check for and provide a nicer error message about.

@drhuffman12
Copy link
Author

What is elfutils and how to install?

@Vici37
Copy link
Member

Vici37 commented Jun 26, 2023

No idea 😅 A quick google search shows it to be a collection of utilities for interacting with ELF binary format, and DWARF debug info (I found this blog post which helps explain it a little).

Regarding needing the headers to build kcov, I haven't found anything special I needed to do to have those. I just rebuild my test image that includes kcov in the base image that crystal ships, and discovered that the explicit install of libevent-2.16 isn't needed anymore, so my test image Dockerfile that includes kcov is now:

FROM crystallang/crystal

RUN apt-get update
RUN apt-get install -y apt-utils git cmake make binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev gcc g++ python3
RUN git clone https://github.com/SimonKagstrom/kcov
WORKDIR kcov
RUN cmake .
RUN make
RUN make install
WORKDIR /
RUN rm -rf kcov

This builds and runs correctly (for my own project / self hosted CI, at least).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants