Ruby-on-rails 捆绑程序:找不到命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3914694/
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:21:53  来源:igfitidea点击:

Bundler: Command not found

ruby-on-railsbundler

提问by raphael_turtle

I am hosting on a vps, ubuntu 10.04, rails 3, ruby and mysql installed correctly by following some tutorials. If I run bundle checkor bundle installI get the error '-bash: bundle: command not found'. From gem list --localI see 'bundler (1.0.2, 1.0.0)' is installed.

我在 vps、ubuntu 10.04、rails 3、ruby 和 mysql 上托管,按照一些教程正确安装。如果我运行bundle checkbundle install收到错误“-bash: bundle: command not found”。从gem list --local我看到'bundler (1.0.2, 1.0.0)' 已安装。

I don't know what's going wrong...

我不知道怎么回事...

gem environmentreturns:

gem environment返回:

 RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.8.7 (2010-04-19 patchlevel 253) [i686-linux]
  - INSTALLATION DIRECTORY: /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby
  - EXECUTABLE DIRECTORY: /opt/ruby-enterprise-1.8.7-2010.02/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8
     - /root/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

and echo $PATHreturns:

echo $PATH返回:

/opt/myruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/bin/gem:/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/:/root/.gem/ruby/1.8

and which gemreturns:

which gem返回:

/usr/bin/gem

locate bundlereturns:

locate bundle返回:

/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/

采纳答案by Peter Brown

You need to add the ruby gem executable directory to your path

您需要将 ruby​​ gem 可执行目录添加到您的路径中

export PATH=$PATH:/opt/ruby-enterprise-1.8.7-2010.02/bin

回答by xxjjnn

My problem was that I did:

我的问题是我做了:

sudo gem install bundler

So I had installed as root rather than as myself. So I uninstalled as root, then installed as myself:

所以我以 root 而不是我自己的身份安装。所以我以 root 身份卸载,然后以我自己的身份安装:

sudo gem uninstall bundler
gem install bundler
rbenv rehash

(last command for if you are using rbenv)

(如果您使用 rbenv 的最后一条命令)

And it worked. The "correct" path wasin .bashrc(or other shell profile), at least according to

它奏效了。“正确的”路径.bashrc(或其他外壳配置文件),至少根据

$PATH
=> zsh: /Users/myself/.rbenv/shims:/Users/myself/.rbenv/bin: ... etc

but it was expecting it to be installed for myself - not for root. In my case, its rightful installation place is in ~/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/bundler

但它希望它是为我自己安装的——而不是为 root 安装的。就我而言,它的正确安装位置在~/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/bundler

回答by Lars Moelleken

... also for Debian GNU/Linux 6.0 :)

...也适用于 Debian GNU/Linux 6.0 :)

export PATH=$PATH:/var/lib/gems/1.8/bin

回答by Cody

I did this (Ubuntu latest as of March 2013 [ I think :) ]):

我这样做了(Ubuntu 最新的截至 2013 年 3 月 [我认为 :)]):

sudo gem install bundler

Credit goes to Ray Baxter.

归功于Ray Baxter

If you need gem, I installed Ruby this way (though this is chronically taxing):

如果您需要 gem,我会以这种方式安装 Ruby(尽管这会长期造成负担):

mkdir /tmp/ruby && cd /tmp/ruby
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz
tar xfvz ruby-1.9.3-p327.tar.gz
cd ruby-1.9.3-p327
./configure
make
sudo make install

回答by Mark Evans

My solution was to make sure I selected a version of Ruby for that repo.

我的解决方案是确保我为该存储库选择了一个 Ruby 版本。

Example: chruby 2.2.2or rvm use 2.2.2

示例:chruby 2.2.2rvm use 2.2.2

λ bundle install
zsh: command not found: bundle

λ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]

### Notice the system Ruby version isn't included in chruby

λ chruby
  ruby-1.9.3-p551
  ruby-2.1.2
  ruby-2.2.1

### Select a version via your version manager

λ chruby 1.9.3

### Ensure your version manager properly selects a version (*)

λ chruby
 * ruby-1.9.3-p551
   ruby-2.1.2
   ruby-2.2.1

λ bundle install
Fetching gem metadata from https://rubygems.org/.........

回答by spectralsun

I'm running ubuntu 11.10 and bundle executable was located in:

我正在运行 ubuntu 11.10 并且捆绑可执行文件位于:

/var/lib/gems/1.8/bin

回答by illegaldisease

Probably distro-proof path is adding this to your .bashrc or .zshrc, whatever your shell is :

无论您的 shell 是什么,可能都是防发行版的路径将它添加到您的 .bashrc 或 .zshrc 中:

PATH="$(ruby -e 'print Gem.default_dir')/bin:$PATH"

or if you have installed your gems user-wide, use :

或者,如果您已在用户范围内安装了 gem,请使用:

PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"

回答by Ginglis

On my Arch Linux install, gems were installed to the ~/.gem/ruby/2.6.0/bindirectory if installed as user, or /root/.gem/ruby/2.6.0/binif installed via sudo. Just append the appropriate one to your $PATHenvironment variable:

在我的 Arch Linux 安装中,~/.gem/ruby/2.6.0/bin如果以用户身份安装,或者/root/.gem/ruby/2.6.0/bin通过sudo. 只需将适当的附加到您的$PATH环境变量中:

export PATH=$PATH:/home/your_username/.gem/ruby/2.6.0/bin

回答by Donato

For rbenv users:

对于 rbenv 用户:

$ rbenv versions
2.6.0
$ rbenv global 2.6.0
$ ruby -v
ruby 2.6.0p0
$ gem install bundler
$ rbenv rehash
$ bundle
$ rails -v
Command 'rails' not found
$ rbenv rehash
$ rails -v
Rails 4.2.11.1

回答by unedujoe

Step 1:Make sure you are on path actual workspace.For example, workspace/blog $: Step2:Enter the command: gem install bundler. Step 3: You should be all set to bundle install or bundle update by now

第1步:确保你在路径实际工作区。例如,workspace/blog $: Step2:输入命令:gem install bundler。第 3 步:您现在应该都设置为捆绑安装或捆绑更新