$bin/rails plugin new blorgh --mountable
当我在终端上输入时,我得到:@H_301_5@
bash: bin/rails: No such file or directory
当我尝试$rails它可以正常工作.@H_301_5@
我一直在使用命令行几个月,还有Rails.我知道$符号,但我对此之后“bin”的含义感到困惑.我习惯在$之后输入“Rails”,但本教程说使用“bin”…@H_301_5@
bin /是什么意思?@H_301_5@
解决方法
运行bundle install –binstubs,它会工作.你只需要做一次,Bundler会记住你要求它(对于那个项目).@H_301_5@
更长的答案@H_301_5@
当您使用bundle -binstubs安装bundle时,Bundler会将所有特定于bundle的binstub安装到bin /子目录(相对于Gemfile),而不是将它们放入gemset的全局binstub路径中.@H_301_5@
您通常会这样做:@H_301_5@
>确保您正在运行的rails binstub是Gemfile中的那个(而不是以后与Bundler分开安装到gemset中的不同版本),以及
>改进执行时间(因为它在功能上等同于捆绑exec rails除了减去一个子进程调用之外).@H_301_5@
全局binstubs与Bundler binstubs@H_301_5@
如果你键入哪个rails,你会得到一个很长的路径,比如/usr/local/rvm/gems/jruby-1.7.18/bin/rails,其中的内容是:cat` which rails`@H_301_5@
#!/usr/bin/env jruby_executable_hooks # # This file was generated by RubyGems. # # The application 'railties' is installed as part of a gem,and # this file is here to facilitate running it. # require 'rubygems' version = ">= 0" if ARGV.first str = ARGV.first str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding if str =~ /\A_(.*)_\z/ version = $1 ARGV.shift end end gem 'railties',version load Gem.bin_path('railties','rails',version)
运行bundler –binstubs之后,如果你使用bin / rails,你会得到类似的东西:@H_301_5@
#!/usr/bin/env jruby # # This file was generated by Bundler. # # The application 'rails' is installed as part of a gem,and # this file is here to facilitate running it. # require 'pathname' ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",Pathname.new(__FILE__).realpath) require 'rubygems' require 'bundler/setup' load Gem.bin_path('railties','rails')
关键的区别在于bin / version设置了BUNDLE_GEMFILE环境变量,它需要bundler / setup,这就是告诉Bundler用gem路径做的事情. bin / rails脚本具有捆绑器感知功能,并且可以识别您的Gemfile,因此它可以立即为您的环境做好准备.@H_301_5@