snapcraft fails in a directory with spaces

Bug #1720230 reported by Leo Arias
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
Fix Released
High
Unassigned

Bug Description

Mark Lee found that snapcraft fails with a very very dark error when it is run in a directory with spaces.

To reproduce:

$ mkdir "with spaces"
$ cd "with spaces"
$ snapcraft init
$ snapcraft

$ snapcraft
Preparing to pull my-part
Pulling my-part
Preparing to build my-part
Building my-part
/tmp/tmpnwpk1s18: 3: export: spaces/stage/usr/share/perl5/: bad variable name
Full output: https://paste.ubuntu.com/25635330/

The problem here is that in snapcraft.internal.common.run we save some environment variables to a script that we then use as a proxy to run a command. Some of those variables are not escaped, with makes the syntax of the script invalid.

For example, this is the contents of the script in one of our tests:

export PATH="/root/Test App-linux-x64/parts/desktop-gtk2/install/usr/sbin:/root/Test App-linux-x64/parts/desktop-gtk2/install/usr/bin:/root/Test App-linux-x64/parts/desktop-gtk2/install/sbin:/root/Test App-linux-x64/parts/desktop-gtk2/install/bin:$PATH"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/root/Test App-linux-x64/parts/desktop-gtk2/install/lib:/root/Test App-linux-x64/parts/desktop-gtk2/install/usr/lib:/root/Test App-linux-x64/parts/desktop-gtk2/install/lib/x86_64-linux-gnu:/root/Test App-linux-x64/parts/desktop-gtk2/install/usr/lib/x86_64-linux-gnu"
export LD_LIBRARY_PATH="/root/Test App-linux-x64/parts/desktop-gtk2/install/usr/lib/x86_64-linux-gnu/mesa-egl:$LD_LIBRARY_PATH"
export PATH="/root/Test App-linux-x64/stage/usr/sbin:/root/Test App-linux-x64/stage/usr/bin:/root/Test App-linux-x64/stage/sbin:/root/Test App-linux-x64/stage/bin:$PATH"
export LDFLAGS="$LDFLAGS -L/root/Test App-linux-x64/parts/desktop-gtk2/install/lib -L/root/Test App-linux-x64/parts/desktop-gtk2/install/usr/lib -L/root/Test App-linux-x64/parts/desktop-gtk2/install/lib/x86_64-linux-gnu -L/root/Test App-linux-x64/parts/desktop-gtk2/install/usr/lib/x86_64-linux-gnu"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/root/Test App-linux-x64/parts/desktop-gtk2/install/usr/share/pkgconfig"
export PERL5LIB=/root/Test App-linux-x64/stage/usr/share/perl5/
export SNAPCRAFT_PART_INSTALL=/root/Test App-linux-x64/parts/desktop-gtk2/install
export SNAPCRAFT_PARALLEL_BUILD_COUNT=4
export SNAPCRAFT_STAGE=/root/Test App-linux-x64/stage
export SNAPCRAFT_PROJECT_NAME=testapp
export SNAPCRAFT_PROJECT_VERSION=1.0.0
export SNAPCRAFT_PROJECT_GRADE=devel

The error comes from the PERL5LIB var, but all the ones after that one are not escaped.

Revision history for this message
Leo Arias (elopio) wrote :

Setting priority to high because this will make many projects fail with a very bad error message. Not critical just because it has an (ugly) workaround: copy the files to a dir without a space in the name.

Revision history for this message
Cris Dywan (kalikiana) wrote :
Changed in snapcraft:
status: New → In Progress
Changed in snapcraft:
status: In Progress → Fix Committed
milestone: none → 2.35
Changed in snapcraft:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.