简体   繁体   English

在Ubuntu Raring Ringtail 13.04上针对Ruby 1.8.7的“捆绑安装”

[英]“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. 我已经用Ruby 1.8.7编写了一个应用程序,试图将其打包到Vagrant中(运行Raring 13.04),但是我必须运行“捆绑安装”来安装要求,即使gem1.8确实存在,运行bundle install仍会为Ruby 1.9.3安装gems。 And then my program fails at runtime... 然后我的程序在运行时失败了...

Any idea about how to solve this? 关于如何解决这个问题的任何想法?

UPDATE 1 更新1

The related Gemfile (thanks to the first answerers): 相关的Gemfile(由于第一个答复者):

ruby '1.8.7'

# ...
gem 'trollop'

but for ruby1.8 myfile.rb an error is raised 但是对于ruby1.8 myfile.rb会引发错误

no such file to load -- trollop (LoadError)

After investigation, the problem looks in bundle install : 经过调查,问题出在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 更新2

After following the advices from @klaffenboeck things have changed. 遵循@klaffenboeck的建议后,情况发生了变化。 I'm using RVM and have Ruby 1.8.7 when entering in the project folder. 我正在使用RVM,并在项目文件夹中输入Ruby 1.8.7。 Bundler seems to install things correctly, however the require seems to fail... Path problem? Bundler似乎正确安装了东西,但是需求似乎失败了...路径问题?

See here for detail about Vagrant / RVM setup: https://rvm.io/integration/vagrant 请参阅此处以了解有关Vagrant / RVM设置的详细信息: https : //rvm.io/integration/vagrant

UPDATE 3 更新3

Problem solved, I was missing a: 问题解决了,我错过了:

require 'rubygems'

before all gems (it worked locally but not in Vagrant). 先于所有宝石(它在本地有效,但在Vagrant中无效)。

Bundler will install gems (by default) for whichever Ruby is in your PATH . Bundler将为PATH Ruby安装gems(默认情况下)。

Try /usr/bin/env ruby -v or which ruby to figure out which one that is; 尝试使用/usr/bin/env ruby -vwhich ruby找出哪个是; my guess is you're running bundler with Ruby 1.8. 我的猜测是您正在使用Ruby 1.8运行捆绑程序。

Adding 新增中

ruby '1.8.7'

on top of your Gemfile will help diagnose. 在您的Gemfile上将有助于诊断。

Not aware of this problem in general, but try to put the ruby-version at the top of your gemfile: 通常不知道此问题,但尝试将ruby-version放在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 这很可能是因为您的Gemfile.lock状态为ruby 1.9.3-运行bundle update

Try running gem uninstall bundler , then gem1.8 install bundler . 尝试运行gem uninstall bundler ,然后运行gem1.8 install bundler

Your bundle command seems to be running under Ruby 1.9.3. 您的bundle命令似乎在Ruby 1.9.3下运行。 You can verify which ruby executable bundler is using with head -n 1 $(which bundle) . 您可以通过head -n 1 $(which bundle)验证使用哪个ruby可执行文件捆绑程序。 You want it to be ruby1.8. 您希望它是ruby1.8。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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