Closed maxlein closed 3 years ago
The error indicates that you haven't sourced the local_setup.bash
, although you have RUN bash -c ". /opt/ros/$ROS_DISTRO/setup.bash"
. I suggest you could try something like:
RUN echo "source $ROS2_WS/ros2-linux/local_setup.bash" >> $HOME/.bashrc
Edited: I saw you have both
RUN echo "source $ROS2_WS/ros2-linux/local_setup.bash" >> $HOME/.bashrc
RUN bash -c ". /opt/ros/$ROS_DISTRO/setup.bash"
How did you install the ROS2, binary package or debian?
It's pretty much the Dockerfile from your repo.
So the ROS2 binaries are downloaded and sourced.
But I also tried from the foxy image itself -> FROM ros:foxy
And also sourcing right before install like so:
RUN bash -c ". /opt/ros/$ROS_DISTRO/setup.sh" && npm install
And always getting the same error.
I am getting the same error. I tried sourcing $ROS2_WS/ros2-linux/local_setup.bash
and /opt/ros/$ROS_DISTRO/setup.bash
using both a Dockerfile and by overriding the entrypoint script.
Also, I'm using FROM ros:foxy
Would you please add echo $AMENT_PREFIX_PATH
into the Docker file before starting to install the ros2-web-bridge
and see whether the variable has been set properly. So we could identify if the rclnodejs
causes this error, thanks!
AMENT_PREFIX_PATH looks like that:
echo $AMENT_PREFIX_PATH
/opt/ros/foxy
That's a little weird, from the error log:
console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/ ') + '/include/')
^
TypeError: Cannot read property 'replace' of undefined
It means AMENT_PREFIX_PATH
is not a string, which indicates the variable is not set yet. As the error only happens in Docker, I suspect it's caused by the configuration of docker?
The error originates from https://github.com/RobotWebTools/rclnodejs/blob/develop/binding.gyp#L63 when compiling with GYP file.
Yes but I don't know enough about how gyp works. Why is the env var not set when using gyp?
I was able to get it to work using this:
RUN /bin/bash -c "source \"/opt/ros/$ROS_DISTRO/setup.bash\" && npm install"
Great! @barnesew thanks for sharing your solution! As many developers met this issue when using Docker and reported the same issue on Github, would you please submit a PR to add a Troubleshooting section into README to describe the problem and how to solve it, I think that will help a lot, thanks!
I was able to get it to work using this:
RUN /bin/bash -c "source \"/opt/ros/$ROS_DISTRO/setup.bash\" && npm install"
Do you know can we install it for galactic or not?
I was able to get it to work using this:
RUN /bin/bash -c "source \"/opt/ros/$ROS_DISTRO/setup.bash\" && npm install"
It could be great if you share your Dockerfile with us. I still have problems when install ros2-web-bridge in Dockerfile. Thanks
I am trying to create a Dockerfile for easy startup of the bridge and I encountered this error during call to
npm install
:I am running foxy on ubuntu focal. On my native setup I can install and run it.
This is the Dockerfile I am using. It may help others too.