Why does "rosgenmsg" in ROS Toolbox fail when working in a directory with a long absolute path name?

17 次查看(过去 30 天)
I am working in a directory named C:\some\directory\structure\with\quite\a\few\folders\which\leads\to\a\very\long\absolute\path\in\total and I am trying to generate a MATLAB interface for the custom ROS messages in the 'custom' directory inside this. Calling:
>> rosgenmsg('custom')
fails however with:
Identifying message files in folder 'C:/some/directory/structure/with/quite/a/few/folders/which/leads/to/a/very/long/absolute/path/in/total/custom'..Done.
Validating message files in folder 'C:/some/directory/structure/with/quite/a/few/folders/which/leads/to/a/very/long/absolute/path/in/total/custom'..Done.
[3/3] Generating MATLAB interfaces for custom message packages... Done.
Running catkin build in folder 'C:/some/directory/structure/with/quite/a/few/folders/which/leads/to/a/very/long/absolute/path/in/total/custom/matlab_msg_gen_ros1/win64'.
Build in progress. This may take several minutes...Error using ros.internal.ROSProjectBuilder/buildPackage (line 534)
Error building package: build log.
Error in rosgenmsg (line 377)
buildPackage(builder, [], 'install', catkinMakeArgs); %other messages might need to be present in the same directory
Looking in the build log, at the bottom I see:
-- Generating done
-- Build files have been written to: C:/some/directory/structure/with/quite/a/few/folders/which/leads/to/a/very/long/absolute/path/in/total/custom/matlab_msg_gen_ros1/win64/build
ninja: no work to do.
ninja: build stopped: .
ninja: error: mkdir(CMakeFiles/Project__setup_util.py_exec_install_python.dir/catkin_generated/add_python_executable/Project__setup_util.py_exec_install_python): No such file or directory
Base path: C:\some\directory\structure\with\quite\a\few\folders\which\leads\to\a\very\long\absolute\path\in\total\custom\matlab_msg_gen_ros1\win64
Source space: C:\some\directory\structure\with\quite\a\few\folders\which\leads\to\a\very\long\absolute\path\in\total\custom\matlab_msg_gen_ros1\win64\src
Build space: C:\some\directory\structure\with\quite\a\few\folders\which\leads\to\a\very\long\absolute\path\in\total\custom\matlab_msg_gen_ros1\win64\build
Devel space: C:\some\directory\structure\with\quite\a\few\folders\which\leads\to\a\very\long\absolute\path\in\total\custom\matlab_msg_gen_ros1\win64\devel
Install space: C:\some\directory\structure\with\quite\a\few\folders\which\leads\to\a\very\long\absolute\path\in\total\custom\matlab_msg_gen_ros1\win64\install
####
#### Running command: "ninja build.ninja" in "C:\some\directory\structure\with\quite\a\few\folders\which\leads\to\a\very\long\absolute\path\in\total\custom\matlab_msg_gen_ros1\win64\build"
####
####
#### Running command: "ninja install install -j12 -l12" in "C:\some\directory\structure\with\quite\a\few\folders\which\leads\to\a\very\long\absolute\path\in\total\custom\matlab_msg_gen_ros1\win64\build"
####
Invoking "ninja install install -j12 -l12" failed

采纳的回答

MathWorks Support Team
The following line in the build log appears to tell us what is going wrong exactly:
ninja: error: mkdir(CMakeFiles/Project__setup_util.py_exec_install_python.dir/catkin_generated/add_python_executable/Project__setup_util.py_exec_install_python): No such file or directory
During the build process an attempt is made to create a directory which would have gotten the following absolute path name:
c:\some\directory\structure\with\quite\a\few\folders\which\leads\to\a\very\long\absolute\path\in\total\custom\matlab_msg_gen_ros1\win64\build\CMakeFiles\Project__setup_util.py_exec_install_python.dir\catkin_generated\add_python_executable\Project__setup_util.py_exec_install_python\
This path is 282 characters in total, that is longer than the 260 which all Windows API functions are guaranteed to be able to work with. Theoretically, working with longer paths is possible on Windows 10 but not all applications do in fact support this. MATLAB as a matter of fact does not, and neither do other tools in the ROS toolchain; so then the build fails.
To work around this issue work in a working directory which is does not have a long absolute path to start with. You can also use a tool like "subst" to map your long path to a drive letter. For example in a Windows cmd.exe prompt run:
subst W: C:\some\directory\structure\with\quite\a\few\folders\which\leads\to\a\very\long\absolute\path\in\total
and then in MATLAB use W:\ as your working directory.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Custom Message Support 的更多信息

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by