Ruby-on-rails 捆绑的问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3958092/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 23:25:10  来源:igfitidea点击:

problem with bundle

ruby-on-railsrubyinstallbundle

提问by khanh

I try command bundle install --localbut it show issue:

我尝试命令bundle install --local但它显示问题:

-bash: /usr/local/bin/bundle: /usr/local/bin/ruby: bad interpreter: No such file or directory. 

please help me.

请帮我。

回答by LisaD

The solution that worked for me was entirely different, perhaps because I've been inconsistent about using RVM or not.

对我有用的解决方案完全不同,也许是因为我对使用 RVM 的看法不一致。

I used 'which bundler' to find out where bundler was being launched, it was from /usr/bin/bundler. Noticing that /usr/bin/bundler began with a location and version of ruby that did not exist on my system any more, I did

我使用'which bundler'来找出在哪里启动bundler,它来自/usr/bin/bundler。注意到 /usr/bin/bundler 以我的系统上不再存在的 ruby​​ 的位置和版本开始,我做到了

gem uninstall bundler
gem install bundler

Checking 'which bundler' again confirmed that bundler was now installed within a .rvm environment instead of /usr/bin/bundler, and now references the correct version of ruby; so bundle install now works for my rails project.

再次检查“哪个捆绑程序”确认捆绑程序现在安装在 .rvm 环境中而不是 /usr/bin/bundler,并且现在引用了正确的 ruby​​ 版本;所以 bundle install 现在适用于我的 rails 项目。

回答by zengr

I think you need to export the path of ruby and bundle in your .bashrc (linux).

我认为您需要在 .bashrc (linux) 中导出 ruby​​ 和 bundle 的路径。

Open your .bashrcand add this line:

打开你的.bashrc并添加这一行:

export PATH="$PATH:/usr/bin:/usr/local/bin/"

It should work.

它应该工作。

回答by ken

On my side, I am using rbenv.
When I checked the /usr/local/bin/bundle, it shows it is using the older ruby, thus causing the problem.

在我这边,我正在使用 rbenv。
当我检查 /usr/local/bin/bundle 时,它​​显示它使用的是较旧的 ruby​​,从而导致了问题。

#!/usr/bin/ruby1.9.1

by changing it to point to proper ruby fix the problem

通过将其更改为指向正确的 ruby​​ 来解决问题

#!/home/user/.rbenv/shims/ruby

回答by Roger Marlow

The bundleexecutable is provided by the bundlergem. If you are using rvmthen seeing which bundlein /usr/local/bin/bundleindicates a problem, because use of rvmmeans gems like bundlerare installed under your home directory, usually in ~/.rvm/gems/....

bundle可执行文件是由提供bundler宝石。如果您正在使用,rvm则看到which bundlein/usr/local/bin/bundle表示有问题,因为使用rvm意味着 gemsbundler安装在您的主目录下,通常在~/.rvm/gems/....

# Symptoms of a broken bundler installation:-

# Cannot start Rails...
$ bin/rails s
/Users/rogermarlow/project/config/boot.rb:9:in 'rescue in <top (required)>': uninitialized constant Bundler (NameError)

# bundle not working...
$ bundle install
zsh: /usr/local/bin/bundle: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin: no such file or directory
#    ^----- that path does not look right, rvm does not put gems there
$ which bundle
/usr/local/bin/bundle
# ^--- I want bundle from something under ~/.rvm/gems

# First check rvm is in effect:
$ rvm reload
RVM reloaded!
$ which ruby
/Users/rogermarlow/.rvm/rubies/ruby-2.3.4/bin/ruby
# ^--looks good, it is an rvm path, not /usr/local/bin/...

# Now fix bundler
$ gem uninstall bundler    # just in case
$ gem install bundler
Fetching: bundler-1.16.1.gem (100%)
Successfully installed bundler-1.16.1
1 gem installed
$ which bundle
/Users/rogermarlow/.rvm/gems/ruby-2.3.4@project/bin/bundle
$ ^--- that is better, bundle is on a path controlled by rvm

# bundle now working
$ bundle install
Fetching gem metadata from http://rubygems.org/..........
*snip*

# rails now working
$ bin/rails s
=> Booting Thin
=> Rails 4.2.7.1 application starting in development on http://localhost:3000
*snip*

回答by rahul patil

For newly created gem-set gem bundler is missing for me,

对于我缺少新创建的 gem-set gem bundler,

Before bundler install path for it, /usr/local/bin/bundler

在 bundler 的安装路径之前,/usr/local/bin/bundler

Installed bundler to resolve issue.

安装捆绑程序以解决问题。

gem install bundler --no-ri --no-rdoc

Bundler path changes to, /home/root/.rvm/gems/ruby-2.2.1@drag-drop-list/bin/bundler

捆绑程序路径更改为,/home/root/.rvm/gems/ruby-2.2.1@drag-drop-list/bin/bundler

回答by Jose Eduardo Quintero Key

Encountering this same problem, I found bundler installation in /var/lib/gems/2.3.0/gems/bundler-1.16.1;
Then i fixed the error by creating a symbolic link like this:

遇到同样的问题,我在中找到了 bundler 安装/var/lib/gems/2.3.0/gems/bundler-1.16.1;
然后我通过创建这样的符号链接来修复错误:

ln -s /var/lib/gems/2.3.0/gems/bundler-1.16.1/ /usr/lib/ruby/gems/2.3.0/gems/bundler-1.16.1

ln -s /var/lib/gems/2.3.0/gems/bundler-1.16.1/ /usr/lib/ruby/gems/2.3.0/gems/bundler-1.16.1

I did this because I needed this version of ruby.

我这样做是因为我需要这个版本的 ruby​​。