Subject: transformation 'with-source' had no effect on local git checkout directory

From: Jesse Gibbons <[email-masked]>
Date: Wed, 17 Jul 2019 17:52:36 -0600

I could not find this bug in the archives. This bug seems a
bit inconsistent.

How to reproduce:
Note that I use a variable after I discovered this does not happen with
some packages.

   my_package=guile-git

1. clone any repository referenced by a package:
   git clone https://gitlab.com/guile-git/guile-git.git checkout

2. modify the repository. I use a harmless comment, but I initially
saw this bug when I made a much greater change:
   cd checkout
   echo ";;;hello world" >> git/blob.scm

3. (optional) build the package with no flags:
   guix build $my_package

4. build the package with the flag "--with-source=$PWD":
   guix build --with-source=$PWD $my_package

output result:
guix build: warning: transformation 'with-source' had no effect on
[email-masked] /gnu/store/36vgw4w0dh49n5l5vmlnlmiryhay8i52-guile-git-0.2.0

5. check for the edit:
grep ";;hello world" `guix build --with-source=$PWD \
$my_package`/share/guile/site/2.2/git/blob.scm; echo $?

output: guix build: warning: transformation 'with-source' had no effect
on [email-masked] 1

If the git repository was used to build anything grep would have found
my comment and returned 0. If the file in question did not exist grep
would have returned 2.

Should I use --with-git-url instead? Probably not. That does not work
either:

guix build --with-git-url=$PWD $my_package

guix build: error: /home/jesse/Documents/tmp/guile-git/checkout:
invalid Git URL replacement specification

Should I commit? Turns out that doesn't help:
git add git/blob.scm
git commit -m"message"
guix build --with-source=$PWD $my_package

guix build: warning: transformation 'with-source' had no effect on
[email-masked] /gnu/store/36vgw4w0dh49n5l5vmlnlmiryhay8i52-guile-git-0.2.0

Committing doesn't change the response to --with-git-url=$PWD either,
which is logical given the error message:
guix build --with-git-url=$PWD $my_package

guix build: error: /home/jesse/Documents/tmp/guile-git/checkout:
invalid Git URL replacement specification

Finally I try to build after I delete the .git directory, which makes my
working directory no longer a git checkout directory:
rm -rf .git
guix build --with-source=$PWD guile-gdbm-ffi 

gives me the same result:

guix build: warning: transformation 'with-source' had no effect on
[email-masked] /gnu/store/s5k6sc82ylbgxajdjvk7ns7i17dvx62r-guile-gdbm-ffi-20120209.fa1d5b6

I would expect this to be different, but I guess that's not the case.

However, this does not happen when I use source from guix itself:

cp --dereference --recursive `guix build --source \
$my_package` ./$my_package
cd $my_package
chmod --recursive u+w .
guix build --with-source=$PWD $my_package

...
successfully
built /gnu/store/0vjqhdwv1rsa40naziy9prq8v1jgbyxr-guile-git-0.2.0.drv

But it does not work when I use . instead of $PWD:
guix build --with-source=. $my_package

guix build: warning: transformation 'with-source' had no effect on
[email-masked]
/gnu/store/36vgw4w0dh49n5l5vmlnlmiryhay8i52-guile-git-0.2.0

This bug not happen when I try it with the guile-readline package.

Because of this bug, it can be very complicated to develop and install
packages out of a local git clone directory. For example, it becomes
frustrating to check that changes made to the installation process
allow guix to install a package that guix previously couldn't build
before the source is committed and pushed to a remote repository.

I hope this issue has enough information to find a solution.

-Jesse