Part local source 'is not a directory'

sorry to post for something so simple but I am not finding the solution and seem to just have some misunderstanding. I have not used snap much and I am trying to basically follow this this tutorial but use my local ROS workspace as the source. my snapcraft.yaml looks like this

plugin: colcon
source-type: local
source: /local_ros_workspace/
build-packages: [make, gcc, g++]
site-packages: [ros-foxy-ros2launch]

but when building I get an error that the source is not a directory, using --debug and playing around with the path I can see that it does not actually appear to be working in my computers directory and instead seems to be in in the directory created by snapcraft with parts, prime, project, etc…

how do I use a local folder as source for a part?

does your source really live at the toplevel of your rootfs disk ? typically the source dir is somewhere relative to the snap/ dir in your project source …

thanks for your comment, I’ll be a little over specific to hopefully avoid error but yes I believe it is

after these steps the ROS workspace is just a folder in the root directory, in this folder is where I run colcon build to build the ros packages so I figured it would be the best place to point the source. However, inside of this folder is another called src and inside of this is more folders for each ROS package I have made. so: home/workspace/src/package_name again this is in my local PC and made before I ever started using snap which is why it is not in any directory to do with snap.

Are you saying that I should move or copy it into the snap directory or is there something else I need to do in my snapcraft.yaml to make this local source visible?

I didn’t get it to work with local but worked fine (or at least my issue seems to be elsewhere) just using git after pushing the whole src directory, better workflow anyways.

1 Like

well, typically your snap/ dir would live somewhere in the top level of your source tree. when snapcraft builds in a VM (the default) or container it actually copies “./” into that container/VM to build. it will not copy /foobar and will not find that dir in the container …

one way you could do what you wanted in the beginning would be to use --destructive-mode which makes snapcraft build directly on your host (and install all build dependencies on it, possibly mangle your system through third party build scripts etc etc … ) … and your host release would have to match exactly the base you use in your snapcraft.yaml …

… it might mess up your machine, but technically it would be possible :slight_smile:

(many snap developers i know simply use a permanent lxd container, use lxc shell <containername> and do their actual work in there, then you can indeed happily use --destructive-mode)

2 Likes