Fix bug where the app crashes due to priviledges of making directory #791

Closed
opened 2026-05-07 06:35:23 +00:00 by b24johka · 10 comments
Collaborator

image

For some reason the app crashes due to not having priviledges to create directory, we can resolve this by changing the priviledges of the frontend directory. However, that is just a temporary fix and we need somehow make the script to create the frontend directory with the right priviledges from the installation script.

![image](/attachments/1025b61a-cf14-4fb1-af19-7eaefc2b4f14) For some reason the app crashes due to not having priviledges to create directory, we can resolve this by changing the priviledges of the frontend directory. However, that is just a temporary fix and we need somehow make the script to create the frontend directory with the right priviledges from the installation script.
Collaborator

Has anyone else experienced this issue?

Has anyone else experienced this issue?
Collaborator

I can not recreate this issue on the team1_week5 branch, i've tried running npm start as a admin and non admin and it works with no visible defects or bugs for both
.

I can not recreate this issue on the team1_week5 branch, i've tried running npm start as a admin and non admin and it works with no visible defects or bugs for both .
Collaborator

This happens to me every time I clone the repo and run the install script. I use ubuntu

This happens to me every time I clone the repo and run the install script. I use ubuntu
Collaborator

@b23albst wrote in #791 (comment):

This happens to me every time I clone the repo and run the install script. I use ubuntu

How did you fix it? Do we need to add something to the script?

@b23albst wrote in https://git.webug.se/Andras/BoundlessFlowCampus2K/issues/791#issuecomment-8575: > This happens to me every time I clone the repo and run the install script. I use ubuntu How did you fix it? Do we need to add something to the script?
Author
Collaborator

The fix is to do chown MY_USER frontend
Which is the Unix command to change the ownership folder frontend to the user being specified.
Unsure why the directory isnt being created with ownership to the user from the installation script.

The fix is to do **chown MY_USER frontend** Which is the Unix command to change the ownership folder frontend to the user being specified. Unsure why the directory isnt being created with ownership to the user from the installation script.
Author
Collaborator

This might be a Linux only problem, we dont know really. And as previously stated, to recreate this issue you have to make clone the repository from scratch.

This might be a Linux only problem, we dont know really. And as previously stated, to recreate this issue you have to make clone the repository from scratch.
Collaborator

I think more specifically the fix is to change the ownership of frontend/node_modules. This directory is created by the "npm install" command in the installation script and has root as owner (I'm guessing since install script is run with sudo). However, this might just be something specific to some versions/distros (I have ubuntu 22.04) since not every linux user has this problem

I think more specifically the fix is to change the ownership of frontend/node_modules. This directory is created by the "npm install" command in the installation script and has root as owner (I'm guessing since install script is run with sudo). However, this might just be something specific to some versions/distros (I have ubuntu 22.04) since not every linux user has this problem
Author
Collaborator

So i did multiple tests and found out that there might just be some lack of experience from using Linux (From my side atleast).
I am unsure why this bug appeared for the first time for me yesterday, maybe i was just lucky with my usage.

Recreating the project with not using any sudo commands for mkdir, git clone, UnixInstallation.sh, npm start will create all files with privileges to the current user. Thus, terminating the error and the issue.

image

However, i am not able to run UnixRebuild.sh without sudo. (Might be because docker is installed using sudo).

I also tried creating everything from scratch only using sudo. This will actually allow for npm start without using sudo.
This works flawelessly. I cant see anywhere in installation.sh or rebuildscript.sh how sudo is being enforced in anyway.
I will try to get someone else with the same issue to try this out and see if this solves the issue.

Main takeaway: use sudo for everything or nothing. if theres a mismatch where a user tries to access root privileges we get problems.

So i did multiple tests and found out that there might just be some lack of experience from using Linux (From my side atleast). I am unsure why this bug appeared for the first time for me yesterday, maybe i was just lucky with my usage. Recreating the project with not using any sudo commands for **mkdir**, **git clone**, **UnixInstallation.sh**, **npm** start will create all files with privileges to the current user. Thus, terminating the error and the issue. ![image](/attachments/d2fad404-1008-466f-b44b-1d078d973419) However, i am not able to run **UnixRebuild.sh** without sudo. (Might be because docker is installed using sudo). I also tried creating everything from scratch only using sudo. This will actually allow for **npm start** without using sudo. This works flawelessly. I cant see anywhere in **installation.sh** or **rebuildscript.sh** how sudo is being enforced in anyway. I will try to get someone else with the same issue to try this out and see if this solves the issue. Main takeaway: use **sudo** for **everything** or **nothing**. if theres a mismatch where a user tries to access root privileges we get problems.
Collaborator

Review on #791

Whats done

I tested making new clones of the repo and running the install script, as well as the rebuild script with and without sudo

Tested on ubuntu

  • When running the install script with sudo, root becomes the owner of the directory frontend/node-modules, which means sudo is required for npm start as well.
  • Installing without sudo is possible and then the user becomes owner of previously mentioned directory. Then npm start can be run without sudo.
  • As root privileges are required by docker, sudo is required for running the rebuild script.

What needs to be done

  • scripts/README.md
    • I suggest changing the line about the unix install script to not include sudo.
      image
    • If we want to be diligent, we could also document this problem in the script usage readme

Conclusion

  • Error occurs when trying to run "npm start" without being the owner of frontend/node-modules, which happens when sudo is used for the install script.
# Review on #791 ## Whats done I tested making new clones of the repo and running the install script, as well as the rebuild script with and without sudo ### Tested on ubuntu + When running the install script with sudo, root becomes the owner of the directory frontend/node-modules, which means sudo is required for npm start as well. + Installing without sudo is possible and then the user becomes owner of previously mentioned directory. Then npm start can be run without sudo. + As root privileges are required by docker, sudo is required for running the rebuild script. ## What needs to be done + scripts/README.md + I suggest changing the line about the unix install script to not include sudo. ![image](/attachments/a5d2eaa9-f46a-4c25-ba70-ee661f56fdf3) + If we want to be diligent, we could also document this problem in the script usage readme ## Conclusion + Error occurs when trying to run "npm start" without being the owner of frontend/node-modules, which happens when sudo is used for the install script.
7.8 KiB
Collaborator

An issue has been made for this problem: #877

An issue has been made for this problem: https://git.webug.se/Andras/BoundlessFlowCampus2K/issues/877
Sign in to join this conversation.
No milestone
No project
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Andras/BoundlessFlowCampus2K#791
No description provided.