Why does bundler keep installing gems I already have? - ruby-on-rails

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...

Related

Gem installer error when setting up ruby on rails (Windows 7)

I'm getting an error trying to set up a Ruby on Rails site. I've never used Ruby before, so everything is clean out of the installer.
I've installed Ruby 1.9.3 and RubyGems 2.0.3. I then installed rails using gem and created a blank site with rails new. At some point I also installed the DevKit as instructed here - I can't remember when exactly, but I was explicitly asked to at some point. I then tried to start it using rails server, but it's asking me to use bundle install to install some missing gems. Easy enough, but when I try that I get the following output:
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.0.4)
Using i18n (0.6.1)
Using multi_json (1.7.3)
Using activesupport (3.2.13)
Using builder (3.0.4)
Using activemodel (3.2.13)
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.2)
Using tilt (1.4.1)
Using sprockets (2.2.2)
Using actionpack (3.2.13)
Using mime-types (1.23)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.5.3)
Using actionmailer (3.2.13)
Using arel (3.0.2)
Using tzinfo (0.3.37)
Using activerecord (3.2.13)
Using activeresource (3.2.13)
Using bundler (1.3.5)
Using coffee-script-source (1.6.2)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.3)
Installing json (1.7.7)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
"C:/Ruby/Ruby 1.9.3/bin/ruby.exe" extconf.rb
C:/Ruby/Ruby 1.9.3/bin/ruby.exe: invalid option -1 (-h will show valid options) (RuntimeError)
Gem files will remain installed in C:/Ruby/Ruby 1.9.3/lib/ruby/gems/1.9.1/gems/json-1.7.7 for inspection.
Results logged to C:/Ruby/Ruby 1.9.3/lib/ruby/gems/1.9.1/gems/json-1.7.7/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.7.7), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.7'` succeeds before bundling.
I get the same error when running either gem install json -v '1.7.7' or just gem install json. This particular error has proved itself resistant to Googling, so I thought I'd try asking here. Any help would be appreciated!
Well, it turns out the problem was that the path to my Ruby install has spaces in it. This is apparently strongly disrecommended in a number of places, but the error message was unrelated enough that it took me a while to put two and two together.

Can't run bundle update because of json 1.7.5

I can't seem to run bundle update on my Windows 7 machine with Ruby 1.9.3p194. I've installed the latest DevKit as well. bundle complains about the lack of a make command, I can't find make on my hard drive (I searched). How do I get this to work?
C:\website>bundle update
Fetching gem metadata from http://rubygems.org/.........
Using rake (0.9.2.2)
Using i18n (0.6.1)
Using multi_json (1.3.6)
Using activesupport (3.2.8)
Using builder (3.0.2)
Using activemodel (3.2.8)
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.8)
Using mime-types (1.19)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.4)
Using actionmailer (3.2.8)
Using arel (3.0.2)
Using tzinfo (0.3.33)
Using activerecord (3.2.8)
Using activeresource (3.2.8)
Using bundler (1.1.5)
Using coffee-script-source (1.3.3)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Installing json (1.7.5) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
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.7.5 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.7.5/ext/json/ext/generator/gem_make.out
An error occured while installing json (1.7.5), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.5'` succeeds before bundling.
ruby dk.rb install --force in the DevKit directory did the trick.
Some gems require compilation, which is the case of json gem.
You can solve compilation issues for most gems by installing RubyInstaller's DevKit, available from the downloads page
Once downloaded, please follow the installation instructions from RubyInstaller wiki page.
After installation, open a new command prompt and try installing the offending gem again:
gem install json
It should succeed.
That is considering DevKit was properly installed. As discussed on the RubyInstaller mailing list, you can force DevKit installation:
ruby dk.rb install --force
In the DevKit directory.

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.

Unable to install gems - tar is corrupt

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).

How to import RoR project to Netbeans

I have very simple (in fact empty ) project which i have created by rails new MyProject command from command-line. So, i want to import it to NetBeans IDE. I click "new project" -> "RoR" -> "from existing source", select Ruby 1.9.2 (instead of embedded JRuby) in the wizard form. After that i have got errors [see the picture below]:
So.. i click OK. And then try to run the RoR application from NetBeans clicking on the run-button and i got the following error in the log-panel:
/home/ses/.rvm/rubies/ruby-1.9.2-p136/bin/ruby: No such file or directory -- script/server (LoadError)
So how to handle these two problems?
p.s. my application is working when i launch it from the console.
i use ruby-1.9.2 and RoR 3.0 and Netbeans 6.9.1 and Ubuntu 10.10
and, replying the comment to my question. yes, i performed following commands:
bundle install
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.7)
Using tzinfo (0.3.24)
Using actionpack (3.0.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.15)
Using actionmailer (3.0.3)
Using arel (2.0.7)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using bundler (1.0.10)
Using mysql2 (0.2.6)
Using thor (0.14.6)
Using railties (3.0.3)
Using rails (3.0.3)
bundle pack
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.7)
Using tzinfo (0.3.24)
Using actionpack (3.0.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.15)
Using actionmailer (3.0.3)
Using arel (2.0.7)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using bundler (1.0.10)
Using mysql2 (0.2.6)
Using thor (0.14.6)
Using railties (3.0.3)
Using rails (3.0.3)
Updating .gem files in vendor/cache
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
Updating .gem files in vendor/cache
and following this page http://wiki.netbeans.org/FaqRubyRakeFetchingFailed
i did rake -D
this is what I did to get it working (had same problem):
New project > with existing sources
Tools > Ruby Platforms > select Ruby 1.9.2-p136 > Gem Manager > New Gems > rails > install
restart netbeans
open project (if it's not already opened) and right click > bundler > install
run
first of all, what you should't do is expect the debugger to work. because it's not going to work on netbeans, not on rails 3 (there are some hacks but they have problems).
secondly, Ruby on Rails Support Discontinued in NetBeans IDE. I loved the way Netbeans worked with rails 2.x, but I migrated to RubyMine because of it's support for Rails 3
hope this helps

Resources