Closed youpong closed 6 months ago
I'm getting some errors while building it in docker container
make -C src -j
make[1]: Entering directory '/procfetch/src'
g++ -std=c++2a -Wall -Wextra --pedantic-errors -c -o fetch.o fetch.cpp
g++ -std=c++2a -Wall -Wextra --pedantic-errors -c -o main.o main.cpp
g++ -std=c++2a -Wall -Wextra --pedantic-errors -c -o util.o util.cpp
Assembler messages:
Fatal error: can't create main.o: Permission denied
make[1]: *** [<builtin>: main.o] Error 1
make[1]: *** Waiting for unfinished jobs....
Assembler messages:
Fatal error: can't create util.o: Permission denied
make[1]: *** [<builtin>: util.o] Error 1
Assembler messages:
Fatal error: can't create fetch.o: Permission denied
make[1]: Leaving directory '/procfetch/src'
make[1]: *** [<builtin>: fetch.o] Error 1
make: *** [Makefile:12: src] Error 2
I can't reproduce it here. My environment is as follows:
I was able fix that error by doing:
-USER user
-WORKDIR /home/user
+WORKDIR /home/user
+USER user
I was able to run it. After running more errors:
$ sudo docker run --rm -v $PROCFETCH:/procfetch -w /procfetch procfetch make run
make -C src -j run
make[1]: Entering directory '/procfetch/src'
./procfetch
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string: construction from null is not valid
make[1]: Leaving directory '/procfetch/src'
make[1]: *** [Makefile:16: run] Aborted (core dumped)
make: *** [Makefile:12: src] Error 2
I'll try to debug this during night.
I'm using Ubuntu 24.04
and Docker version 26.1.0, build 9714adc
That change in the Dockerfile
works fine in my environment.
If I set a value to the USER
environment variable, does it change the result?
$ USER=$(whoami) src/procfetch
Yupp, It does! Can you update this PR with both the changes?
I’ve updated this PR with both changes. Check it.
Well. In the Docker container environment that we provide, it is acceptable to set the USER
environment variable. Let's introduce it.
However, as this case shows, it is incorrect to assume that the environment variable USER
is always available. Stopping the program in such a case is not a good behavior. We need to add a process to handle the case.
However, as this case shows, it is incorrect to assume that the environment variable USERis always available. Stopping the program in such a case is not a good behavior. We need to add a process to handle the case.
Definitely, we've got a bunch of cases causing the program to halt. I'll create a separate issue for those, then we can start fixing them.
As for getting the username, we could just use the getlogin()
from unistd.h
. Let's think more about it?
Anyways, I'm merging this PR!
The docker image
ubuntu:latest
has been changed to 24.04 LTS. The new image does not install theadduser
command by default, which causes errors when building the docker imageprocfetch
. This pull request contains changes to theDockerfile
.Related Issue(s)
This pull request fixes the issue #146.