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

Permission Denied Error when Running 'make' in '/Document/test' directory #5

Closed
EkenoSamson opened this issue Sep 17, 2023 · 11 comments

Comments

@EkenoSamson
Copy link

I'm encountering an issue when trying to run 'make' in the /Document/test directory while following the YouTube video(C-Language: C Ninja, in Pyjama! - #0. Lab Setup!) at 12:44

c-ninja@c-ninja-linux ~/Documents/test
% make
riscv64-unknown-elf-gcc -O0 -ggdb -nostdlib -march=rv32i -mabi=ilp32 -Wl,-Tmain.ld main.s -o main.elf
/usr/lib/riscv64-unknown-elf/bin/ld: cannot open output file main.elf: Permission denied
collect2: error: ld returned 1 exit status

I have also attached the screen of my terminal.
Screenshot from 2023-09-17 12-21-06

Here are the details when I run uname -a in my terminal.
Screenshot from 2023-09-17 12-26-32

I am using ubuntu.
image

@EkenoSamson
Copy link
Author

EkenoSamson commented Sep 17, 2023

When I use sudo make and provide the required password, it successfully generates the desired output. It appears that this resolves the issue.
Screenshot from 2023-09-17 12-35-40

@EkenoSamson
Copy link
Author

Using the terminal in the Vscode after connecting using the Remote Explorer.
Screenshot from 2023-09-17 13-08-04

@streetdogg
Copy link
Contributor

Thank you, @EkenoSamson for opening the issue!

It looks to me that the c-ninja user doesn't have the write access to the path ~/Documents/test. Could you help run the following command and share the output?

ls -al

Unfortunately, I did not try the setup on a Linux machine. I will try to reproduce the error on that. In the meantime, can I also request you, to try adding the c-ninja user to the sudo group using the commands below?

sudo usermod -aG sudo c-ninja

I am hoping the make command will work as expected after this.

@Pankaj-Patil-97
Copy link

Pankaj-Patil-97 commented Sep 17, 2023

This is happening because while mounting test folder to container's ~/Documents/ directory, user files are being mounted as owned by root while preserving file permissions.
This issue and issue comment will help - moby/moby#3124 (comment)

fileperm

The permissions for test folder indicate write permissions for others are not enabled hence not allowing other users to create output file main.elf

Please run to give other users write access in the folder

sudo chmod +007 ../test/

Post that, again run make and we should be able to see the o/p

done

@EkenoSamson
Copy link
Author

EkenoSamson commented Sep 17, 2023

the following is the output after I ran ls -la command.
Screenshot from 2023-09-17 17-30-20

After adding c-ninja to the sudo group using sudo usermod -aG sudo c-ninja and trying make
Screenshot from 2023-09-17 17-37-59

@7022106205
Copy link

Screenshot from 2023-09-22 17-18-58

I tried entering my Ubuntu Login Password, but its not taking. Is there any different password?

@streetdogg
Copy link
Contributor

@7022106205: The password for the c-ninja user is c. Your login password won't work within the docker image 😊

Let us know if this helped.

@7022106205
Copy link

@7022106205: The password for the c-ninja user is c. Your login password won't work within the docker image 😊

Let us know if this helped.

It worked, thank you.

@streetdogg
Copy link
Contributor

@EkenoSamson:

Can you try the following and see if this resolves the permission issue? I tried this locally on an Ubuntu machine and seemed to work well -

c-ninja@c-ninja-linux ~/Documents
% sudo chown -R c-ninja .

I am able to execute the make command without sudo as below:

docker-0001

@EkenoSamson
Copy link
Author

@streetdogg
I tried it and it's working. Thank you.
Screenshot from 2023-10-04 13-57-39

@streetdogg
Copy link
Contributor

Awesome! Thanks!

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

4 participants