Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

package & install fails with local gem paths #2921

Closed
phemmer opened this issue Mar 9, 2014 · 5 comments
Closed

package & install fails with local gem paths #2921

phemmer opened this issue Mar 9, 2014 · 5 comments

Comments

@phemmer
Copy link

phemmer commented Mar 9, 2014

Bundler 1.2 added the ability for bundle package --all to include local and git gems. However when installing the generated package it fails in multiple different ways.
By multiple different ways, I don't mean the result is random, I mean the behavior is very different based on changes that shouldn't have any impact (I would think).

Here's a script which duplicates the issue (bug.sh):

#!/bin/bash
rm -fr /tmp/bundler-pi 2>/dev/null

set -x
mkdir -p /tmp/bundler-pi
cd /tmp/bundler-pi

mkdir -p mygem/lib
echo 'puts "mygem loaded"' > mygem/lib/mygem.rb
cat > mygem/mygem.gemspec <<'EOI'
Gem::Specification.new 'mygem', '0.1.2' do |s|
    s.summary = 'example gem'
    s.author = 'nobody'
    s.files = %x{find . -type f}.split("\n")
end
EOI

mkdir -p myapp/lib
echo 'require "mygem"' > myapp/lib/myapp.rb
pushd myapp
bundle init
echo 'gem "mygem", :path => "/tmp/bundler-pi/mygem"' >> Gemfile
if [ "$1" != "" ]; then
    echo 'gem "example", :git => "[email protected]:robotarmy/example.git"' >> Gemfile
fi
bundle install
bundle package --all
popd

# here we simulate tarballing the app and deploying it to another host
rm -fr mygem
mv myapp myapp_deployment
pushd myapp_deployment

bundle install --deployment --local

When run as bug.sh you get the following output (snipped to relevant bit):

+ bundle install --deployment --local
Using mygem (0.1.2) from source at /tmp/bundler-pi/myapp_deployment/vendor/cache/mygem
Using bundler (1.5.3)
Cannot write a changed lockfile while frozen.
Updating files in vendor/cache
Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
/usr/lib64/ruby/2.0.0/fileutils.rb:1552:in `stat': No such file or directory - /tmp/bundler-pi/mygem/. (Errno::ENOENT)
    from /usr/lib64/ruby/2.0.0/fileutils.rb:1552:in `block in fu_each_src_dest'
    from /usr/lib64/ruby/2.0.0/fileutils.rb:1568:in `fu_each_src_dest0'
    from /usr/lib64/ruby/2.0.0/fileutils.rb:1550:in `fu_each_src_dest'
    from /usr/lib64/ruby/2.0.0/fileutils.rb:434:in `cp_r'
    from /home/phemmer/.gem/ruby/2.0.0/gems/bundler-1.5.3/lib/bundler/source/path.rb:81:in `cache'

Here you can see the output first shows it's using the gem from the vendor/cache as it should. Then it fails when it tries to use the non-cached version which is missing.


However by changing one little bit, adding a gem from git (installs the 'robotarmy/example' gem), the error message is completely different.
Run as bug.sh 1:

+ bundle install --deployment --local
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.

You have added to the Gemfile:
* source: source at /tmp/bundler-pi/mygem

You have deleted from the Gemfile:
* source: source at /tmp/bundler-pi/myapp_deployment/vendor/cache/mygem

You have changed in the Gemfile:
* mygem from `source at /tmp/bundler-pi/mygem` to `no specified source`

I get this behavior with version 1.3.5 and 1.5.3.

# bundle config
Settings are listed in order of priority. The top value will be used.

# ruby -v
ruby 2.0.0p451 (2014-02-24 revision 45167) [x86_64-linux]

# gem -v
2.0.3

No RVM

@indirect
Copy link
Member

indirect commented Mar 9, 2014

I believe that package —all currently does not work for :path gems. I’d like to fix this as soon as I have time, and in the meantime pull requests to fix the issue are welcome.

On Mar 9, 2014, at 4:17 PM, Patrick Hemmer [email protected] wrote:

Bundler 1.2 added the ability for bundle package --all to include local and git gems. However when installing the generated package it fails in multiple different ways.

By multiple different ways, I don't mean the result is random, I mean the behavior is very different based on changes that shouldn't have any impact (I would think).

Here's a script which duplicates the issue (bug.sh):

#!/bin/bash
rm -fr /tmp/bundler-pi 2>/dev/null

set -x
mkdir -p /tmp/bundler-pi
cd /tmp/bundler-pi

mkdir -p mygem/lib
echo 'puts "mygem loaded"' > mygem/lib/mygem.rb
cat > mygem/mygem.gemspec <<'EOI'
Gem::Specification.new 'mygem', '0.1.2' do |s|
s.summary = 'example gem'
s.author = 'nobody'
s.files = %x{find . -type f}.split("\n")
end
EOI

mkdir -p myapp/lib
echo 'require "mygem"' > myapp/lib/myapp.rb
pushd myapp
bundle init
echo 'gem "mygem", :path => "/tmp/bundler-pi/mygem"' >> Gemfile
if [ "$1" != "" ]; then
echo 'gem "example", :git => "[email protected]:robotarmy/example.git"' >> Gemfile
fi
bundle install
bundle package --all
popd

here we simulate tarballing the app and deploying it to another host

rm -fr mygem
mv myapp myapp_deployment
pushd myapp_deployment

bundle install --deployment --local
When run as bug.sh you get the following output (snipped to relevant bit):

  • bundle install --deployment --local
    Using mygem (0.1.2) from source at /tmp/bundler-pi/myapp_deployment/vendor/cache/mygem
    Using bundler (1.5.3)
    Cannot write a changed lockfile while frozen.
    Updating files in vendor/cache
    Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
    /usr/lib64/ruby/2.0.0/fileutils.rb:1552:in stat': No such file or directory - /tmp/bundler-pi/mygem/. (Errno::ENOENT) from /usr/lib64/ruby/2.0.0/fileutils.rb:1552:inblock in fu_each_src_dest'
    from /usr/lib64/ruby/2.0.0/fileutils.rb:1568:in fu_each_src_dest0' from /usr/lib64/ruby/2.0.0/fileutils.rb:1550:infu_each_src_dest'
    from /usr/lib64/ruby/2.0.0/fileutils.rb:434:in cp_r' from /home/phemmer/.gem/ruby/2.0.0/gems/bundler-1.5.3/lib/bundler/source/path.rb:81:incache'
    Here you can see the output first shows it's using the gem from the vendor/cache as it should. Then it fails when it tries to use the non-cached version which is missing.

However by changing one little bit, adding a gem from git (installs the 'robotarmy/example' gem), the error message is completely different.
Run as bug.sh 1:

  • bundle install --deployment --local
    You are trying to install in deployment mode after changing
    your Gemfile. Run bundle install elsewhere and add the
    updated Gemfile.lock to version control.

You have added to the Gemfile:

  • source: source at /tmp/bundler-pi/mygem

You have deleted from the Gemfile:

  • source: source at /tmp/bundler-pi/myapp_deployment/vendor/cache/mygem

You have changed in the Gemfile:

  • mygem from source at /tmp/bundler-pi/mygem to no specified source
    I get this behavior with version 1.3.5 and 1.5.3.

bundle config

Settings are listed in order of priority. The top value will be used.

ruby -v

ruby 2.0.0p451 (2014-02-24 revision 45167) [x86_64-linux]

gem -v

2.0.3
No RVM


Reply to this email directly or view it on GitHub.

@phemmer
Copy link
Author

phemmer commented Mar 9, 2014

The "what's new" for version 1.2 explicitly states that it does.

Edit:
Unless you mean it was supposed to work, but is knowingly broken.

@indirect
Copy link
Member

indirect commented Mar 9, 2014

When I say "currently does not work", I mean that it has been broken by a bug. Sorry it's not working right now. :(

On Sun, Mar 9, 2014 at 4:26 PM, Patrick Hemmer [email protected]
wrote:

The "what's new" for version 1.2 explicitly states that it does.

Reply to this email directly or view it on GitHub:
#2921 (comment)

@skull-squadron
Copy link

If the path happens to be a git repo, just use gem 'somegem', git: 'file:///tmp/bundler-pi/mygem'

@indirect
Copy link
Member

fixed in 0efe021.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants