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

Symlink error when running simulation example #49

Open
rdlynx19 opened this issue Jan 6, 2025 · 4 comments · May be fixed by #50
Open

Symlink error when running simulation example #49

rdlynx19 opened this issue Jan 6, 2025 · 4 comments · May be fixed by #50
Assignees

Comments

@rdlynx19
Copy link

rdlynx19 commented Jan 6, 2025

Hello,
I followed the instructions on the README to setup the docker container in VS Code. After building and opening the container in VS Code, when I run the test commands:

cd
cd PX4-Autopilot/
make px4_sitl gz_x500

I get the following error in the VS Code terminal:

ros@tokyo:~/PX4-Autopilot$ make px4_sitl gz_x500
[0/1] cd /home/ros/PX4-Autopilot/build/px4_sitl_default/src/modul...EL=gz_x500 /home/ros/PX4-Autopilot/build/px4_sitl_default/bin/px4
ERROR [px4] Error creating symlink /home/ros/PX4-Autopilot/build/px4_sitl_default/etc -> /home/ros/PX4-Auto
FAILED: src/modules/simulation/gz_bridge/CMakeFiles/gz_x500 /home/ros/PX4-Autopilot/build/px4_sitl_default/src/modules/simulation/gz_bridge/CMakeFiles/gz_x500 
cd /home/ros/PX4-Autopilot/build/px4_sitl_default/src/modules/simulation/gz_bridge && /usr/bin/cmake -E env PX4_SIM_MODEL=gz_x500 /home/ros/PX4-Autopilot/build/px4_sitl_default/bin/px4
ninja: build stopped: subcommand failed.
make: *** [Makefile:232: px4_sitl] Error 1

I tried running the command as sudo but it still does not work.

ros@tokyo:~/PX4-Autopilot$ sudo make px4_sitl gz_x500
[0/1] cd /home/ros/PX4-Autopilot/build/px4_sitl_default/src/modul...EL=gz_x500 /home/ros/PX4-Autopilot/build/px4_sitl_default/bin/px4
ERROR [px4] get_server_running: failed to create lock file: /tmp/px4_lock-0, reason=Permission denied
ERROR [px4] Failed to get server status
FAILED: src/modules/simulation/gz_bridge/CMakeFiles/gz_x500 /home/ros/PX4-Autopilot/build/px4_sitl_default/src/modules/simulation/gz_bridge/CMakeFiles/gz_x500 
cd /home/ros/PX4-Autopilot/build/px4_sitl_default/src/modules/simulation/gz_bridge && /usr/bin/cmake -E env PX4_SIM_MODEL=gz_x500 /home/ros/PX4-Autopilot/build/px4_sitl_default/bin/px4
ninja: build stopped: subcommand failed.
make: *** [Makefile:232: px4_sitl] Error 1

I would appreciate your help in solving this issue.

@edouardrolland
Copy link
Owner

@rdlynx19 After a quick look, it might be because the /tmp directory is not writable by your user:

Check if it is writable with this:

ls -ld /tmp

You should see something like this:
drwxrwxrwt 10 root root 4096 Jan 7 10:00 /tmp

If not, fix it with:

sudo chmod 1777 /tmp

Also, check for leftover PX4 lock files in /tmp. Look for them with:

ls -l /tmp/px4_lock-*

If any exist, remove them (ensure no other PX4 instances are running):

sudo rm /tmp/px4_lock-*

It’s recommended not to run PX4 SITL with sudo. Instead, run it as your user:

make px4_sitl gz_x500

If the issue persists, clean and rebuild the project:

make clean
make px4_sitl_default
make px4_sitl gz_x500

Finally, ensure your user has proper ownership of the PX4 directory:

sudo chown -R $USER:$USER /home/ros/PX4-Autopilot

Let me know if this resolves your issue!

@edouardrolland edouardrolland self-assigned this Jan 7, 2025
@rdlynx19
Copy link
Author

rdlynx19 commented Jan 7, 2025

Hi @edouardrolland
I checked the command

ls -ld /tmp

and it returns me an output similar to the one you mentioned.
I have also cleaned the leftover PX4 files in the /tmp directory

Running make px4_sitl gz_x500 still throws the same error

I am unable to clean the project, on running make clean I get a bunch of Permission denied messages. (there are more but I can't seem to copy all of them)

rm: cannot remove '/home/ros/PX4-Autopilot/build/px4_sitl_default/mavlink/uAvionix/testsuite.h': Permission denied
rm: cannot remove '/home/ros/PX4-Autopilot/build/px4_sitl_default/mavlink/checksum.h': Permission denied
rm: cannot remove '/home/ros/PX4-Autopilot/build/px4_sitl_default/mavlink/protocol.h': Permission denied
rm: cannot remove '/home/ros/PX4-Autopilot/build/px4_sitl_default/mavlink/mavlink_helpers.h': Permission denied
rm: cannot remove '/home/ros/PX4-Autopilot/build/px4_sitl_default/mavlink/minimal/mavlink_msg_heartbeat.h': Permission denied
rm: cannot remove '/home/ros/PX4-Autopilot/build/px4_sitl_default/mavlink/minimal/minimal.h': Permission denied
rm: cannot remove '/home/ros/PX4-Autopilot/build/px4_sitl_default/mavlink/minimal/mavlink_msg_protocol_version.h': Permission denied
rm: cannot remove '/home/ros/PX4-Autopilot/build/px4_sitl_default/mavlink/minimal/version.h': Permission denied
rm: cannot remove '/home/ros/PX4-Autopilot/build/px4_sitl_default/mavlink/minimal/mavlink.h': Permission denied
rm: cannot remove '/home/ros/PX4-Autopilot/build/px4_sitl_default/mavlink/minimal/testsuite.h': Permission denied
rm: cannot remove '/home/ros/PX4-Autopilot/build/px4_sitl_default/mavlink/standard/standard.h': Permission denied
rm: cannot remove '/home/ros/PX4-Autopilot/build/px4_sitl_default/mavlink/standard/version.h': Permission denied
rm: cannot remove '/home/ros/PX4-Autopilot/build/px4_sitl_default/mavlink/standard/mavlink.h': Permission denied
rm: cannot remove '/home/ros/PX4-Autopilot/build/px4_sitl_default/mavlink/standard/testsuite.h': Permission denied
rm: cannot remove '/home/ros/PX4-Autopilot/build/px4_sitl_default/parameters.json': Permission denied
rm: cannot remove '/home/ros/PX4-Autopilot/build/px4_sitl_default/.ninja_log': Permission denied
fatal: detected dubious ownership in repository at '/home/ros/PX4-Autopilot'
To add an exception for this directory, call:

        git config --global --add safe.directory /home/ros/PX4-Autopilot
make: *** [Makefile:497: clean] Error 128

Lastly, trying to change the ownership does not return anything

ros@tokyo:~/PX4-Autopilot$ sudo chown -R ros:ros /home/ros/PX4-Autopilot

I think bash gets stuck in some way.

@rdlynx19
Copy link
Author

Hi @edouardrolland
Thanks for your comment. I was trying to look into it today and I noticed the ownership of the PX4 directory was with root and not my $USER
So then I ran

sudo chown -R $USER:$USER /home/ros/PX4-Autopilot

This takes a long time to execute (around 3 minutes), but I think that is because the -R flag makes it recursive and the PX4-Autopilot is a big directory with many sub directories and files.
But this solved the issue.
I also added it to the end of the Dockerfile so it runs while building the container

RUN /bin/bash -c "sudo chown -R ros:ros /home/ros/PX4-Autopilot"

Thanks for your help!

@edouardrolland
Copy link
Owner

edouardrolland commented Jan 13, 2025

@rdlynx19 Glad you found a solution! Sorry I didn't have that much time to help :|
Don't forget to start the repo if you find it useful! And please do a pull request to make your changes available to everyone :)

@rdlynx19 rdlynx19 linked a pull request Jan 13, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants