ueno / ruby-gpgme

a ruby interface to GnuPG Made Easy (GPGME).
GNU Lesser General Public License v2.1
232 stars 99 forks source link

Gem installation fails when directory path contains spaces #122

Open eddgrant opened 6 years ago

eddgrant commented 6 years ago

Hi folks,

Sorry, bit of a dull one here, I'm experiencing an issue whereby I'm unable to install gpgme when my gem path contains a space. I'm very much a noob in ruby terms so I'm not entirely sure what's going on but it seems to be related specifically to this gem, as opposed to a general bundler/ rubygems isssue.

The following should hopefully demonstrate the problem:

#!/usr/bin/env bash

DIRECTORY_PATH="/tmp/directory with spaces in its path"
mkdir -p "${DIRECTORY_PATH}"
echo "Created directory: ${DIRECTORY_PATH}"

cd "${DIRECTORY_PATH}"
echo "entered directory ${DIRECTORY_PATH}"

echo "2.5.1" > .ruby-version
echo "Written .ruby-version file"

cat << EOF > Gemfile
source 'https://rubygems.org' do
  gem 'gpgme', '2.0.16'
end
EOF
echo "Written Gemfile"

bundle install --path .gems

For me, this results in the following error:

Fetching gpgme 2.0.16
Installing gpgme 2.0.16 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /tmp/directory with spaces in its path/.gems/ruby/2.5.0/gems/gpgme-2.0.16/ext/gpgme
/home/egrant/.rbenv/versions/2.5.1/bin/ruby -r ./siteconf20181004-4958-cy1oya.rb extconf.rb
************************************************************************
IMPORTANT!  gpgme gem uses locally built versions of required C libraries,
namely libgpg-error, libassuan, and gpgme.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall gpgme gem as
follows:

    gem install gpgme -- --use-system-libraries

************************************************************************
Extracting libgpg-error-1.27.tar.bz2 into tmp/x86_64-linux-gnu/ports/libgpg-error/1.27... OK
Running 'configure' for libgpg-error 1.27... OK
Running 'compile' for libgpg-error 1.27... ERROR, review '/tmp/directory with spaces in its
path/.gems/ruby/2.5.0/gems/gpgme-2.0.16/ext/gpgme/tmp/x86_64-linux-gnu/ports/libgpg-error/1.27/compile.log' to see what happened. Last lines are:
========================================================================
make  all-am
make[3]: Entering directory '/tmp/directory with spaces in its
path/.gems/ruby/2.5.0/gems/gpgme-2.0.16/ext/gpgme/tmp/x86_64-linux-gnu/ports/libgpg-error/1.27/libgpg-error-1.27/src'
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I..  -DLOCALEDIR=\"/tmp/directory with spaces in its
path/.gems/ruby/2.5.0/gems/gpgme-2.0.16/ports/x86_64-linux-gnu/libgpg-error/1.27/share/locale\"    -fPIC  -Wall -Wpointer-arith -Wno-psabi -fvisibility=hidden -MT
libgpg_error_la-posix-lock.lo -MD -MP -MF .deps/libgpg_error_la-posix-lock.Tpo -c -o libgpg_error_la-posix-lock.lo `test -f 'posix-lock.c' || echo './'`posix-lock.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -DLOCALEDIR=\"/tmp/directory with spaces in its
path/.gems/ruby/2.5.0/gems/gpgme-2.0.16/ports/x86_64-linux-gnu/libgpg-error/1.27/share/locale\" -fPIC -Wall -Wpointer-arith -Wno-psabi -fvisibility=hidden -MT
libgpg_error_la-posix-lock.lo -MD -MP -MF .deps/libgpg_error_la-posix-lock.Tpo -c posix-lock.c -o libgpg_error_la-posix-lock.o
gcc: error: with: No such file or directory
gcc: error: spaces: No such file or directory
gcc: error: in: No such file or directory
gcc: error: its: No such file or directory
gcc: error: path/.gems/ruby/2.5.0/gems/gpgme-2.0.16/ports/x86_64-linux-gnu/libgpg-error/1.27/share/locale": No such file or directory
Makefile:813: recipe for target 'libgpg_error_la-posix-lock.lo' failed
make[3]: *** [libgpg_error_la-posix-lock.lo] Error 1
make[3]: Leaving directory '/tmp/directory with spaces in its
path/.gems/ruby/2.5.0/gems/gpgme-2.0.16/ext/gpgme/tmp/x86_64-linux-gnu/ports/libgpg-error/1.27/libgpg-error-1.27/src'
Makefile:578: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/tmp/directory with spaces in its
path/.gems/ruby/2.5.0/gems/gpgme-2.0.16/ext/gpgme/tmp/x86_64-linux-gnu/ports/libgpg-error/1.27/libgpg-error-1.27/src'
Makefile:474: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/tmp/directory with spaces in its path/.gems/ruby/2.5.0/gems/gpgme-2.0.16/ext/gpgme/tmp/x86_64-linux-gnu/ports/libgpg-error/1.27/libgpg-error-1.27'
Makefile:405: recipe for target 'all' failed
make: *** [all] Error 2
========================================================================
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
  --with-opt-dir
  --without-opt-dir
  --with-opt-include
  --without-opt-include=${opt-dir}/include
  --with-opt-lib
  --without-opt-lib=${opt-dir}/lib
  --with-make-prog
  --without-make-prog
  --srcdir=.
  --curdir
  --ruby=/home/egrant/.rbenv/versions/2.5.1/bin/$(RUBY_BASE_NAME)
  --clean
  --use-system-libraries
/tmp/directory with spaces in its path/.gems/ruby/2.5.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:402:in `block in execute': Failed to complete compile task
(RuntimeError)
  from /tmp/directory with spaces in its path/.gems/ruby/2.5.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:373:in `chdir'
  from /tmp/directory with spaces in its path/.gems/ruby/2.5.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:373:in `execute'
  from /tmp/directory with spaces in its path/.gems/ruby/2.5.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:115:in `compile'
  from /tmp/directory with spaces in its path/.gems/ruby/2.5.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:154:in `cook'
  from extconf.rb:79:in `block in <main>'
  from extconf.rb:65:in `tap'
  from extconf.rb:65:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /tmp/directory with spaces in its path/.gems/ruby/2.5.0/gems/gpgme-2.0.16 for inspection.
Results logged to /tmp/directory with spaces in its path/.gems/ruby/2.5.0/extensions/x86_64-linux/2.5.0-static/gpgme-2.0.16/gem_make.out

An error occurred while installing gpgme (2.0.16), and Bundler cannot continue.
Make sure that `gem install gpgme -v '2.0.16'` succeeds before bundling.

In Gemfile:
  gpgme

To my untrained eye it looks like spaces aren't being accommodated when the GCC command is being built e.g.

gcc: error: with: No such file or directory
gcc: error: spaces: No such file or directory
gcc: error: in: No such file or directory
gcc: error: its: No such file or directory
gcc: error: path/.gems/ruby/2.5.0/gems/gpgme-2.0.16/ports/x86_64-linux-gnu/libgpg-error/1.27/share/locale": No such file or directory

I have tried the same thing locally against a directory with no spaces in the path and it works fine, the unfortunate thing being I can't change the path on the particular system this is being deployed to.

Most grateful for any assistance / knowledge of any workarounds on this one.

Cheers,

Edd

jakyns commented 5 years ago

I found it too yesterday and still can't find out now

utkarsh2102 commented 5 years ago

I can reproduce this! Do we have a fix for this yet, @dansketcher?