Snapcraft fails if directory has spaces in it

I happened to be sat in a directory which had spaces in the name, and wanted to run snapcraft from it. I got a bizarre and obscure message which took me a while to debug. Perhaps we need to do some quoting or maybe detect this situation and error nicely?

/tmp/tmpe1_fngzn: 3: export: Demo/emoji/stage/usr/share/perl5/: bad variable name

To reproduce:-

alan@hal:~$ mkdir "My Demo"
alan@hal:~$ cd My\ Demo/
alan@hal:~/My Demo$ git clone https://github.com/popey/emoji.git
Cloning into 'emoji'...
remote: Counting objects: 210, done.
remote: Total 210 (delta 0), reused 0 (delta 0), pack-reused 210
Receiving objects: 100% (210/210), 561.49 KiB | 555.00 KiB/s, done.
Resolving deltas: 100% (100/100), done.
Checking connectivity... done.
alan@hal:~/My Demo$ cd emoji/
alan@hal:~/My Demo/emoji$ snapcraft
Preparing to pull emoji 
Pulling emoji 
Downloading 'node-v6.10.2-linux-x64.tar.gz'[=============================================================================================================================================================] 100%
npm --cache-min=Infinity install
/tmp/tmpe1_fngzn: 3: export: Demo/emoji/stage/usr/share/perl5/: bad variable name
Command '['/bin/sh', '/tmp/tmpe1_fngzn', 'npm', '--cache-min=Infinity', 'install']' returned non-zero exit status 2.

Rename the “My Demo” folder to have no spaces, and snapcraft works fine.

1 Like

Yes o erroring out nicely, yes on quoting too

I ran across the same problem today (snapcraft, version 2.34). Your post saved me a lot of head-banging!

1 Like