简体   繁体   中英

“bundle install” for Ruby 1.8.7 on Ubuntu Raring Ringtail 13.04

I'm not a rubyist and there might be something obvious I'm missing.

I've wrote an application in Ruby 1.8.7, I'm trying to package it in Vagrant (running Raring 13.04), but I've to run "bundle install" to install the requirements and even though gem1.8 does exist, running bundle install still install the gems for Ruby 1.9.3. And then my program fails at runtime...

Any idea about how to solve this?

UPDATE 1

The related Gemfile (thanks to the first answerers):

ruby '1.8.7'

# ...
gem 'trollop'

but for ruby1.8 myfile.rb an error is raised

no such file to load -- trollop (LoadError)

After investigation, the problem looks in bundle install :

Your Ruby version is 1.9.3, but your Gemfile specified 1.8.7

I don't get how to solve the problem.

UPDATE 2

After following the advices from @klaffenboeck things have changed. I'm using RVM and have Ruby 1.8.7 when entering in the project folder. Bundler seems to install things correctly, however the require seems to fail... Path problem?

See here for detail about Vagrant / RVM setup: https://rvm.io/integration/vagrant

UPDATE 3

Problem solved, I was missing a:

require 'rubygems'

before all gems (it worked locally but not in Vagrant).

Bundler will install gems (by default) for whichever Ruby is in your PATH .

Try /usr/bin/env ruby -v or which ruby to figure out which one that is; my guess is you're running bundler with Ruby 1.8.

Adding

ruby '1.8.7'

on top of your Gemfile will help diagnose.

Not aware of this problem in general, but try to put the ruby-version at the top of your gemfile:

#Gemfile
ruby '1.8.7'

# followed by your gems

Edit:

this is most likely because your Gemfile.lock states ruby 1.9.3 - run bundle update

Try running gem uninstall bundler , then gem1.8 install bundler .

Your bundle command seems to be running under Ruby 1.9.3. You can verify which ruby executable bundler is using with head -n 1 $(which bundle) . You want it to be ruby1.8.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM