Unable to install gems - tar is corrupt - ruby-on-rails

brandon$ bundle
Fetching source index for http://rubygems.org/
Using rake (0.9.2.2)
Using log4r (1.1.9)
Using XMLCanonicalizer (1.0.1)
Using multi_json (1.0.3)
Using activesupport (3.1.1)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.1)
Using erubis (2.7.0)
Using rack (1.3.5)
Using rack-cache (1.1)
Using rack-mount (0.8.3)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.0.3)
Using actionpack (3.1.1)
Using mime-types (1.17.1)
Using polyglot (0.3.2)
Gem::Package::FormatError: corrupt gem (Gem::Package::TarInvalidError: tar is corrupt, name contains null byte) in /Users/brandon/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/cache/treetop-1.4.10.gem
An error occured while installing treetop (1.4.10), and Bundler cannot continue.
Make sure that `gem install treetop -v '1.4.10'` succeeds before bundling.
I have removed ruby and rvm, installed rbenv and reinstalled ruby. This is with 1.9.3-rc1, but the same thing happens in 1.9.2-p290. I have tried removing /Users/brandon/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/cache/ to no avail. I am not sure where to turn at this point.
Also, it doesn't always happen with the treetop gem. Other times it is with activemodel or other gems.

It looks like you are having trouble with the connection (assuming you are behind a firewall).
Try to use other internet connection (like mobile broadband).

Related

"bundle install" not creating Gemfile.lock when issued from a Rails console system command

I have an odd use-case where I need to issue "bundle install" (as a system() command) from a Rails application on another freshly-made Rails application without a Gemfile.lock.
I'm aware that this is usually done from the command line but I need to do it within Rails.
As a point of reference, this is easily achievable with irb. It fetches the gems based on the Gemfile as expected and generates a Gemfile.lock.
For some reason, when I am in a Rails console (from another app) and I issue the same series of commands, the bundle command does not actually fetch or update the gems and does not generate the Gemfile.lock.
As tadman pointed out, I believe this is due to the environment changing between irb and rails console. The bundle install command, when executed from system(), is acting on the Rails app that launched the Rails console instead of the target application.
Even when trying to match ENV variables in the Rails console to the ones in irb I still cannot figure it out (see attempts below).
Steps to test this:
cd && rails new myapp --skip-bundle
From another/full Rails app launch rails console
Dir.chdir("/home/user/myapp")
system("bundle install")
This will not actually fetch the gems in myapp and it will not create Gemfile.lock
With irb (successful):
1.9.3p429 :002 > Dir.chdir("/home/user/myapp")
=> 0
1.9.3p429 :003 > system("bundle install")
Updating git://github.com/plataformatec/devise.git
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.0)
Using i18n (0.6.4)
Using minitest (4.7.5)
Using multi_json (1.7.7)
Using atomic (1.1.10)
Using thread_safe (0.1.0)
Using tzinfo (0.3.37)
Using activesupport (4.0.0.beta1)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.0.beta1)
Using mime-types (1.23)
Using polyglot (0.3.3)
Using treetop (1.4.14)
Using mail (2.5.4)
Using actionmailer (4.0.0.beta1)
Using activemodel (4.0.0.beta1)
Using activerecord-deprecated_finders (0.0.3)
Using arel (4.0.0)
Using activerecord (4.0.0.beta1)
Using bcrypt-ruby (3.0.1)
Using bundler (1.3.5)
Using coffee-script-source (1.6.2)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using json (1.8.0)
Using rdoc (3.12.2)
Using thor (0.18.1)
Using railties (4.0.0.beta1)
Using coffee-rails (4.0.0)
Using orm_adapter (0.4.0)
Using warden (1.2.1)
Using devise (2.2.4) from git://github.com/plataformatec/devise.git (at rails4)
Using google-analytics-rails (0.0.4)
Using hike (1.2.3)
Using jbuilder (1.0.2)
Using jquery-rails (3.0.1)
Using tilt (1.4.1)
Using sprockets (2.10.0)
Using sprockets-rails (2.0.0)
Using rails (4.0.0.beta1)
Using sass (3.2.9)
Using sass-rails (4.0.0)
Using sqlite3 (1.3.7)
Using turbolinks (1.2.0)
Using uglifier (2.1.1)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
With rails console (unsuccessful):
[1] pry(main)> Dir.chdir("/home/erik/facebook")
=> 0
[2] pry(main)> system("bundle install")
Using rake (10.1.0)
Using i18n (0.6.4)
Using minitest (4.7.5)
Using multi_json (1.7.7)
Using atomic (1.1.10)
Using thread_safe (0.1.0)
Using tzinfo (0.3.37)
Using activesupport (4.0.0.beta1)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.0.beta1)
Using mime-types (1.23)
Using polyglot (0.3.3)
Using treetop (1.4.14)
Using mail (2.5.4)
Using actionmailer (4.0.0.beta1)
Using activemodel (4.0.0.beta1)
Using activerecord-deprecated_finders (0.0.3)
Using arel (4.0.0)
Using activerecord (4.0.0.beta1)
Using addressable (2.3.5)
Using annotate (2.5.0)
Using json (1.8.0)
Using mini_portile (0.5.0)
Using nokogiri (1.6.0)
Using uuidtools (2.1.4)
Using aws-sdk (1.11.1)
Using bcrypt-ruby (3.0.1)
Using browser (0.1.6)
Using xpath (2.0.0)
Using capybara (2.1.0)
Using ffi (1.9.0)
Using childprocess (0.3.9)
Using coderay (1.0.9)
Using coffee-script-source (1.6.2)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rdoc (3.12.2)
Using thor (0.18.1)
Using railties (4.0.0.beta1)
Using coffee-rails (4.0.0)
Using diff-lcs (1.2.4)
Using gherkin (2.12.0)
Using cucumber (1.3.2)
Using cucumber-rails (1.3.0)
Using curb (0.8.4)
Using database_cleaner (1.0.1)
Using orm_adapter (0.4.0)
Using warden (1.2.1)
Using devise (2.1.3)
Using dotenv (0.8.0)
Using eco-source (1.1.0.rc.1)
Using eco (1.0.0)
Using ejs (1.0.0)
Using launchy (2.3.0)
Using email_spec (1.4.0)
Using factory_girl (4.2.0)
Using factory_girl_rails (4.2.1)
Using foreman (0.63.0)
Using hike (1.2.3)
Using jquery-rails (3.0.1)
Using kgio (2.8.0)
Using messengerjs-rails (1.3.3)
Using method_source (0.8.1)
Using pg (0.15.1)
Using protected_attributes (1.0.2)
Using slop (3.4.5)
Using pry (0.9.12.2)
Using pry-rails (0.3.1)
Using bundler (1.3.5)
Using tilt (1.4.1)
Using sprockets (2.10.0)
Using sprockets-rails (2.0.0)
Using rails (4.0.0.beta1)
Using rails-backbone (0.7.2)
Using rails_serve_static_assets (0.0.1)
Using rails_stdout_logging (0.0.1)
Using rails_12factor (0.0.2)
Using rails_on_heroku (0.0.2)
Using raindrops (0.11.0)
Using rspec-core (2.13.1)
Using rspec-expectations (2.13.0)
Using rspec-mocks (2.13.1)
Using rspec (2.13.0)
Using rspec-rails (2.13.2)
Using rubyzip (0.9.9)
Using sass (3.2.9)
Using sass-rails (4.0.0)
Using websocket (1.0.7)
Using selenium-webdriver (2.33.0)
Using shoulda-matchers (2.2.0)
Using simplecov-html (0.7.1)
Using simplecov (0.7.1)
Using uglifier (2.1.1)
Using unicorn (4.6.3)
Using valid_email (0.0.4)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
EDIT 1: After tadman's consideration, I've tried this which throws a strange bundle error:
[6] pry(main)> system({"BUNDLE_GEMFILE" => nil}, "bundle install")
git://github.com/plataformatec/devise.git (at rails4) is not checked out. Please run `bundle install`
And:
[6] pry(main)> system({"BUNDLE_GEMFILE" => "/home/user/myapp/Gemfile"}, "bundle install")
git://github.com/plataformatec/devise.git (at rails4) is not checked out. Please run `bundle install`
Thank you!
Solved with:
Bundler.with_clean_env { Dir.chdir("/path/to/myapp") { `bundle install` } }
All credit goes to irc user indirect on #bundler for this.
in my case work with Bundler.with_clean_env { Dir.chdir "/path/to/myapp" { bundle install } }
note that is the same but without "(" and ")"

Why do I get an error when running bundle install?

I spent the past couple of hours, in addition to scouring Stack Overflow, trying to find a solution to this problem, but I haven't been able to solve anything when runningbundle install.
Here is the error message:
Alexander-MacBook-Pro:HealthApp Alex$ bundle install
Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies......
Using rake (10.0.3)
Using i18n (0.6.4)
Using multi_json (1.6.1)
Using activesupport (3.2.11)
Using builder (3.0.4)
Using activemodel (3.2.11)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.5)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.1)
Using tilt (1.3.4)
Using sprockets (2.2.2)
Using actionpack (3.2.11)
Using mime-types (1.21)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.4.4)
Using actionmailer (3.2.11)
Using arel (3.0.2)
Using tzinfo (0.3.36)
Using activerecord (3.2.11)
Using activeresource (3.2.11)
Using bcrypt-ruby (3.0.1)
Using sass (3.2.6)
Using bootstrap-sass (2.3.0.1)
Using bundler (1.3.5)
Using cancan (1.6.9)
Using coffee-script-source (1.6.0)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.3)
Using json (1.7.7)
Using rdoc (3.12.2)
Using thor (0.17.0)
Using railties (3.2.11)
Using coffee-rails (3.2.2)
Using commonjs (0.2.6)
Using orm_adapter (0.4.0)
Using warden (1.2.1)
Using devise (2.2.3)
Using sass-rails (3.2.6)
Using font-awesome-sass-rails (3.0.2.2)
Using haml (4.0.0)
Using jquery-rails (2.2.1)
Using jquery-ui-rails (3.0.1)
Using kaminari (0.14.1)
Using less (2.2.2)
Using less-rails (2.2.6)
Installing libv8 (3.11.8.13)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/Alex/.rvm/rubies/jruby-1.7.4/bin/jruby extconf.rb
NotImplementedError: C extension support is not enabled. Pass -Xcext.enabled=true to JRuby or set JRUBY_OPTS or modify .jrubyrc to enable.
(root) at /Users/Alex/.rvm/rubies/jruby-1.7.4/lib/ruby/shared/mkmf.rb:8
require at org/jruby/RubyKernel.java:1054
(root) at /Users/Alex/.rvm/rubies/jruby-1.7.4/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
(root) at extconf.rb:1
Gem files will remain installed in /Users/Alex/.rvm/gems/jruby-1.7.4/gems/libv8-3.11.8.13 for inspection.
Results logged to /Users/Alex/.rvm/gems/jruby-1.7.4/gems/libv8-3.11.8.13/ext/libv8/gem_make.out
An error occurred while installing libv8 (3.11.8.13), and Bundler cannot
continue.
Make sure that `gem install libv8 -v '3.11.8.13'` succeeds before bundling.
Running gem install libv8 -v '3.11.8.13' doesn't help much.
Add the following to your ~/.jrubyrc (create it if it does not exist):
cext.enabled=true
Then run the bundle install command again.

Why does bundler keep installing gems I already have?

I have updated my system to Mountain Lion, built a new version of Ruby and, as far as I know, reinstalled all my old gems. However, whenever I cd into an old app and run the bundle command it takes an age because it is re-installing gems I know that I have on my system:
Using rake (0.9.2.2)
Using i18n (0.6.0)
Using multi_json (1.0.4)
Installing activesupport (3.2.1)
Using builder (3.0.0)
Installing activemodel (3.2.1)
Using erubis (2.7.0)
Installing journey (1.0.1)
Using rack (1.4.1)
Using rack-cache (1.1)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Installing sprockets (2.1.2)
Installing actionpack (3.2.1)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Installing mail (2.4.1)
Installing actionmailer (3.2.1)
Installing arel (3.0.0)
Using tzinfo (0.3.31)
Any thoughts, suggestions or ideas of what to look for would be really appreciated.
My first answer, but I would suggest using RVM to manage ruby versions and gemsets.
Check out RVM
After that, just create a .rvmrc file that you can find examples online. The power of the .rvmrc is that it runs whenever you "cd" into an app with that file present. So it will set your RVM with the appropriate Ruby Version and the appropriate Gemset (with all your gems) and never have to worry about versions and gems being conflicted or overlapped or not there etc...

bcrypt-ruby failed to build gem native extension

I'm new to RoR and hit a snag with installing the bcrypt-ruby (v 3.0.1) gem (from gemfile) when following RailsTutorial.org. In looking through other responses on the site, what's not clear to me is if this a is version incompatibility issue, a missing ruby-dev environment, something to do with Xcode, an extra space in the "ruby extconf.rb" or something else. Any suggestions would be greatly appreciated. Thanks.
My environment = OS X v 10.8, Ruby 1.9.3p194 and Rails 3.2.6.
tj$ bundle install
Fetching gem metadata from https://rubygems.org/........
Using rake (0.9.2.2)
Using i18n (0.6.0)
Using multi_json (1.3.6)
Using activesupport (3.2.6)
Using builder (3.0.0)
Using activemodel (3.2.6)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.1)
Using rack-cache (1.2)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.3)
Using actionpack (3.2.6)
Using mime-types (1.19)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.4)
Using actionmailer (3.2.6)
Using arel (3.0.2)
Using tzinfo (0.3.33)
Using activerecord (3.2.6)
Using activeresource (3.2.6)
Using addressable (2.3.1)
Using annotate (2.5.0)
Installing bcrypt-ruby (3.0.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/tj/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
creating Makefile
make
sh: make: command not found
Gem files will remain installed in /Users/tj/.rvm/gems/ruby-1.9.3- p194#rails3tutorial2ndEd/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /Users/tj/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/bcrypt- ruby-3.0.1/ext/mri/gem_make.out
An error occured while installing bcrypt-ruby (3.0.1), and Bundler cannot continue.
Make sure that `gem install bcrypt-ruby -v '3.0.1'` succeeds before bundling.
It looks to me like you don't have make on your system. If you're using a Mac, you need to install the Xcode command line tools.

I'm having trouble installing missing gems in Rails

I'm having problems starting my Rails web server. I try to enter "rails server" in the cmd prompt but I get the following error:
C:\Ruby193\demo>rails server
←[31mCould not find gem 'jquery-rails (>= 0) x86-mingw32' in the gems available
on this machine.←[0m
←[33mRun `bundle install` to install missing gems.←[0m
but whenever I then do a bundle install to install the missing gem, I get this error:
C:\Ruby193\demo>bundle install
Fetching gem metadata from https://rubygems.org/.........
Using rake (0.9.2.2)
Using i18n (0.6.0)
Using multi_json (1.2.0)
Using activesupport (3.2.3)
Using builder (3.0.0)
Using activemodel (3.2.3)
Using erubis (2.7.0)
Using journey (1.0.3)
Using rack (1.4.1)
Using rack-cache (1.2)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.2)
Using actionpack (3.2.3)
Using mime-types (1.18)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.4)
Using actionmailer (3.2.3)
Using arel (3.0.2)
Using tzinfo (0.3.33)
Using activerecord (3.2.3)
Using activeresource (3.2.3)
Using bundler (1.1.3)
Using coffee-script-source (1.3.1)
Using execjs (1.3.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Installing json (1.6.6) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extensio
.
C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
make
'make' is not recognized as an internal or external command,
operable program or batch file.
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.6
6 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.6.6/ext/json/ext/g
nerator/gem_make.out
An error occured while installing json (1.6.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.6.6'` succeeds before bundling.
I then tried to install json without any luck. Any suggestions?
Since you're on Windows, you need to install the Development Kit to be able to build gems with native extensions.
https://github.com/oneclick/rubyinstaller/wiki/development-kit

Resources